diff --git a/app/src/processing/app/syntax/SketchTextAreaEditorKit.java b/app/src/processing/app/syntax/SketchTextAreaEditorKit.java index b31bfcb2e..b1c03e960 100644 --- a/app/src/processing/app/syntax/SketchTextAreaEditorKit.java +++ b/app/src/processing/app/syntax/SketchTextAreaEditorKit.java @@ -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; + } + + } + }