Skip to content

Commit

Permalink
Editor: triple click select whole line, new line included. Fixes #3469
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Fissore committed Jul 6, 2015
1 parent b0587d1 commit e224630
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion app/src/processing/app/syntax/SketchTextAreaEditorKit.java
Expand Up @@ -15,7 +15,8 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {

private static final Action[] defaultActions = {
new DeleteNextWordAction(),
new DeleteLineToCursorAction()
new DeleteLineToCursorAction(),
new SelectWholeLineAction()
};

@Override
Expand Down Expand Up @@ -100,4 +101,29 @@ public String getMacroID() {

}

/**
* 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;
}

}

}

0 comments on commit e224630

Please sign in to comment.