Editor: triple click select whole line, new line included. Fixes #3469

This commit is contained in:
Federico Fissore 2015-07-06 09:52:40 +02:00
parent b0587d1091
commit e22463032f
1 changed files with 27 additions and 1 deletions

View File

@ -15,7 +15,8 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
private static final Action[] defaultActions = {
new DeleteNextWordAction(),
new DeleteLineToCursorAction()
new DeleteLineToCursorAction(),
new SelectWholeLineAction()
};
@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;
}
}
}