@@ -13,10 +13,12 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
13
13
14
14
public static final String rtaDeleteNextWordAction = "RTA.DeleteNextWordAction" ;
15
15
public static final String rtaDeleteLineToCursorAction = "RTA.DeleteLineToCursorAction" ;
16
+ public static final String rtaIncreaseIndentAction = "RTA.IncreaseIndentAction" ;
16
17
17
18
private static final Action [] defaultActions = {
18
19
new DeleteNextWordAction (),
19
20
new DeleteLineToCursorAction (),
21
+ new IncreaseIndentAction (),
20
22
new SelectWholeLineAction (),
21
23
new ToggleCommentAction ()
22
24
};
@@ -103,6 +105,39 @@ public String getMacroID() {
103
105
104
106
}
105
107
108
+ /**
109
+ * Increases the indent of the selected or current line(s).
110
+ */
111
+ public static class IncreaseIndentAction extends RSyntaxTextAreaEditorKit .InsertTabAction {
112
+
113
+ public IncreaseIndentAction () {
114
+ super (rtaIncreaseIndentAction );
115
+ }
116
+
117
+ @ Override
118
+ public void actionPerformedImpl (ActionEvent e , RTextArea textArea ) {
119
+ int caretPosition = textArea .getCaretPosition ();
120
+ boolean noSelec = textArea .getSelectedText () == null ;
121
+
122
+ // if no selection, focus on first char.
123
+ if (noSelec ) {
124
+ try {
125
+ int line = textArea .getCaretLineNumber ();
126
+ int startOffset = textArea .getLineStartOffset (line );
127
+ textArea .setCaretPosition (startOffset );
128
+ } catch (BadLocationException ex ) {
129
+ }
130
+ }
131
+
132
+ // Insert Tab or Spaces..
133
+ super .actionPerformedImpl (e , textArea );
134
+
135
+ if (noSelec ) {
136
+ textArea .setCaretPosition (caretPosition + (textArea .getTabsEmulated () ? textArea .getTabSize () : 1 ));
137
+ }
138
+ }
139
+ }
140
+
106
141
/**
107
142
* Selects the line around the caret.
108
143
*/
0 commit comments