Use new IncreaseIndentAction for Edit > Increase Indent.

This simplifies the code a bit and fixes a small bug that would cause the cursor to fail to move with the text being indented.
This commit is contained in:
David A. Mellis 2015-12-21 16:42:40 -08:00
parent 05be1480d4
commit 07903b8585
1 changed files with 2 additions and 21 deletions

View File

@ -44,6 +44,7 @@ import processing.app.legacy.PApplet;
import processing.app.syntax.ArduinoTokenMakerFactory;
import processing.app.syntax.PdeKeywords;
import processing.app.syntax.SketchTextArea;
import processing.app.syntax.SketchTextAreaEditorKit;
import processing.app.tools.DiscourseFormat;
import processing.app.tools.MenuScroller;
import processing.app.tools.Tool;
@ -1866,28 +1867,8 @@ public class Editor extends JFrame implements RunnerListener {
private void handleIndentOutdent(boolean indent) {
if (indent) {
int caretPosition = textarea.getCaretPosition();
boolean noSelec = !textarea.isSelectionActive();
// if no selection, focus on first char.
if (noSelec) {
try {
int line = textarea.getCaretLineNumber();
int startOffset = textarea.getLineStartOffset(line);
textarea.setCaretPosition(startOffset);
} catch (BadLocationException e) {
}
}
// Insert Tab or Spaces..
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.insertTabAction);
Action action = textarea.getActionMap().get(SketchTextAreaEditorKit.rtaIncreaseIndentAction);
action.actionPerformed(null);
if (noSelec) {
textarea.setCaretPosition(caretPosition);
}
} else {
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction);
action.actionPerformed(null);