mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
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:
parent
05be1480d4
commit
07903b8585
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user