1 21 22 package org.armedbear.j; 23 24 import java.awt.AWTEvent ; 25 import java.awt.event.KeyEvent ; 26 import java.awt.event.MouseEvent ; 27 import javax.swing.JPopupMenu ; 28 29 public final class ListTagsMode extends AbstractMode implements Constants, Mode 30 { 31 private static final ListTagsMode mode = new ListTagsMode(); 32 33 private ListTagsMode() 34 { 35 super(LIST_TAGS_MODE, LIST_TAGS_MODE_NAME); 36 setProperty(Property.VERTICAL_RULE, 0); 37 setProperty(Property.SHOW_LINE_NUMBERS, false); 38 setProperty(Property.SHOW_CHANGE_MARKS, false); 39 setProperty(Property.HIGHLIGHT_MATCHING_BRACKET, false); 40 setProperty(Property.HIGHLIGHT_BRACKETS, false); 41 } 42 43 public static final ListTagsMode getMode() 44 { 45 return mode; 46 } 47 48 public JPopupMenu getContextMenu(Editor editor) 49 { 50 return null; 51 } 52 53 public Formatter getFormatter(Buffer buffer) 54 { 55 return new ListTagsFormatter(buffer); 56 } 57 58 protected void setKeyMapDefaults(KeyMap km) 59 { 60 km.mapKey(KeyEvent.VK_UP, 0, "tagUp"); 61 km.mapKey(KeyEvent.VK_KP_UP, 0, "tagUp"); 62 km.mapKey(KeyEvent.VK_DOWN, 0, "tagDown"); 63 km.mapKey(KeyEvent.VK_KP_DOWN, 0, "tagDown"); 64 km.mapKey(KeyEvent.VK_ENTER, 0, "jumpToTag"); 65 km.mapKey(KeyEvent.VK_ENTER, CTRL_MASK, "jumpToTagAndKillList"); 66 km.mapKey(KeyEvent.VK_G, CTRL_MASK | SHIFT_MASK, "jumpToTag"); 67 km.mapKey(VK_DOUBLE_MOUSE_1, 0, "mouseJumpToTag"); 68 km.mapKey(VK_MOUSE_2, 0, "mouseJumpToTag"); 69 } 70 71 public static void jumpToTag() 72 { 73 final Editor editor = Editor.currentEditor(); 74 final Buffer buffer = editor.getBuffer(); 75 if (buffer instanceof ListTagsBuffer) 76 ((ListTagsBuffer)buffer).jumpToTag(editor, false); 77 } 78 79 public static void jumpToTagAndKillList() 80 { 81 final Editor editor = Editor.currentEditor(); 82 final Buffer buffer = editor.getBuffer(); 83 if (buffer instanceof ListTagsBuffer) 84 ((ListTagsBuffer)buffer).jumpToTag(editor, true); 85 } 86 87 public static void mouseJumpToTag() 88 { 89 final Editor editor = Editor.currentEditor(); 90 final Buffer buffer = editor.getBuffer(); 91 if (buffer instanceof ListTagsBuffer) { 92 AWTEvent e = editor.getDispatcher().getLastEvent(); 93 if (e instanceof MouseEvent ) { 94 editor.mouseMoveDotToPoint((MouseEvent )e); 95 ((ListTagsBuffer)buffer).jumpToTag(editor, false); 96 } 97 } 98 } 99 100 public static void tagDown() 101 { 102 final Editor editor = Editor.currentEditor(); 103 final Buffer buffer = editor.getBuffer(); 104 if (buffer instanceof ListTagsBuffer) { 105 for (Line line = editor.getDotLine().next(); line != null; line = line.next()) { 106 if (line instanceof TagLine) { 107 editor.moveDotTo(line, 0); 108 break; 109 } 110 } 111 } 112 } 113 114 public static void tagUp() 115 { 116 final Editor editor = Editor.currentEditor(); 117 final Buffer buffer = editor.getBuffer(); 118 if (buffer instanceof ListTagsBuffer) { 119 for (Line line = editor.getDotLine().previous(); line != null; line = line.previous()) { 120 if (line instanceof TagLine) { 121 editor.moveDotTo(line, 0); 122 break; 123 } 124 } 125 } 126 } 127 } 128 | Popular Tags |