1 | /*
|
---|
2 | * 10/27/2004
|
---|
3 | *
|
---|
4 | * RSyntaxTextAreaDefaultInputMap.java - The default input map for
|
---|
5 | * RSyntaxTextAreas.
|
---|
6 | *
|
---|
7 | * This library is distributed under a modified BSD license. See the included
|
---|
8 | * RSyntaxTextArea.License.txt file for details.
|
---|
9 | */
|
---|
10 | package org.fife.ui.rsyntaxtextarea;
|
---|
11 |
|
---|
12 | import java.awt.event.InputEvent;
|
---|
13 | import java.awt.event.KeyEvent;
|
---|
14 | import javax.swing.KeyStroke;
|
---|
15 |
|
---|
16 | import org.fife.ui.rtextarea.RTADefaultInputMap;
|
---|
17 |
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * The default input map for an <code>RSyntaxTextArea</code>.
|
---|
21 | * Currently, the new key bindings include:
|
---|
22 | * <ul>
|
---|
23 | * <li>Shift+Tab indents the current line or currently selected lines
|
---|
24 | * to the left.
|
---|
25 | * </ul>
|
---|
26 | *
|
---|
27 | * @author Robert Futrell
|
---|
28 | * @version 1.0
|
---|
29 | */
|
---|
30 | public class RSyntaxTextAreaDefaultInputMap extends RTADefaultInputMap {
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Constructs the default input map for an <code>RSyntaxTextArea</code>.
|
---|
34 | */
|
---|
35 | public RSyntaxTextAreaDefaultInputMap() {
|
---|
36 |
|
---|
37 | int defaultMod = getDefaultModifier();
|
---|
38 | //int ctrl = InputEvent.CTRL_MASK;
|
---|
39 | int shift = InputEvent.SHIFT_MASK;
|
---|
40 | //int alt = InputEvent.ALT_MASK;
|
---|
41 |
|
---|
42 | put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, shift), RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction);
|
---|
43 | put(KeyStroke.getKeyStroke('}'), RSyntaxTextAreaEditorKit.rstaCloseCurlyBraceAction);
|
---|
44 | put(KeyStroke.getKeyStroke('/'), RSyntaxTextAreaEditorKit.rstaCloseMarkupTagAction);
|
---|
45 | put(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, defaultMod), RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
|
---|
46 | put(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, defaultMod), RSyntaxTextAreaEditorKit.rstaGoToMatchingBracketAction);
|
---|
47 | put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, defaultMod), RSyntaxTextAreaEditorKit.rstaCollapseFoldAction);
|
---|
48 | put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, defaultMod), RSyntaxTextAreaEditorKit.rstaExpandFoldAction);
|
---|
49 | put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, defaultMod), RSyntaxTextAreaEditorKit.rstaCollapseAllFoldsAction);
|
---|
50 | put(KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, defaultMod), RSyntaxTextAreaEditorKit.rstaExpandAllFoldsAction);
|
---|
51 |
|
---|
52 | // FIXME: The keystroke associated with this action should be dynamic and
|
---|
53 | // configurable and synchronized with the "trigger" defined in RSyntaxTextArea's
|
---|
54 | // CodeTemplateManager.
|
---|
55 | // NOTE: no modifiers => mapped to keyTyped. If we had "0" as a second
|
---|
56 | // second parameter, we'd get the template action (keyPressed) AND the
|
---|
57 | // default space action (keyTyped).
|
---|
58 | //put(KeyStroke.getKeyStroke(' '), RSyntaxTextAreaEditorKit.rstaPossiblyInsertTemplateAction);
|
---|
59 | put(CodeTemplateManager.TEMPLATE_KEYSTROKE, RSyntaxTextAreaEditorKit.rstaPossiblyInsertTemplateAction);
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | } |
---|