mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Editor: triple click select whole line, new line included. Fixes #3469
This commit is contained in:
parent
b0587d1091
commit
e22463032f
@ -15,7 +15,8 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
|
|||||||
|
|
||||||
private static final Action[] defaultActions = {
|
private static final Action[] defaultActions = {
|
||||||
new DeleteNextWordAction(),
|
new DeleteNextWordAction(),
|
||||||
new DeleteLineToCursorAction()
|
new DeleteLineToCursorAction(),
|
||||||
|
new SelectWholeLineAction()
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,4 +101,29 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the line around the caret.
|
||||||
|
*/
|
||||||
|
public static class SelectWholeLineAction extends RecordableTextAction {
|
||||||
|
|
||||||
|
public SelectWholeLineAction() {
|
||||||
|
super(selectLineAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
|
||||||
|
Document document = textArea.getDocument();
|
||||||
|
Element map = document.getDefaultRootElement();
|
||||||
|
int currentLineNum = map.getElementIndex(textArea.getCaretPosition());
|
||||||
|
Element currentLineElement = map.getElement(currentLineNum);
|
||||||
|
textArea.select(currentLineElement.getStartOffset(), currentLineElement.getEndOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getMacroID() {
|
||||||
|
return DefaultEditorKit.selectLineAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user