Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions app/src/processing/app/syntax/JEditTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,20 @@ public final void selectAll()
select(0,getDocumentLength());
}

/**
* Selects all text in the given line.
* @param line The line number to select all text in it.
*/
public final void selectLine(final int line)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @urbanskimichal! I think I'm in favor of the change if it isn't confusing to new users (I don't think it would be, it's common behavior for a lot of editors). However, could you say more about why you made this public?

{
selectLine = true;
final int lineStart = getLineStartOffset(line);
final int lineEnd = getLineSelectionStopOffset(line);
select(lineStart, lineEnd);
selectionAncorStart = selectionStart;
selectionAncorEnd = selectionEnd;
}

/**
* Moves the mark to the caret position.
*/
Expand Down Expand Up @@ -1663,6 +1677,7 @@ public final void removeCaretListener(CaretListener listener)
/**
* Deletes the selected text from the text area and places it
* into the clipboard.
* If no selection is made, the whole line with caret will be selectd.
*/
public void cut() {
if (editable) {
Expand All @@ -1674,16 +1689,21 @@ public void cut() {

/**
* Places the selected text into the clipboard.
* If no selection is made, the whole line with caret will be selectd.
*/
public void copy() {
if (selectionStart != selectionEnd) {
Clipboard clipboard = getToolkit().getSystemClipboard();

String selection = getSelectedText();
if (selection != null) {
int repeatCount = inputHandler.getRepeatCount();
clipboard.setContents(new StringSelection(selection.repeat(Math.max(0, repeatCount))), null);
if (selectionStart == selectionEnd) {
selectLine(getCaretLine());
}
Clipboard clipboard = getToolkit().getSystemClipboard();
String selection = getSelectedText();
if (selection != null) {
int repeatCount = inputHandler.getRepeatCount();
StringBuilder sb = new StringBuilder();
for(int i = 0; i < repeatCount; i++) {
sb.append(selection);
}
clipboard.setContents(new StringSelection(sb.toString()), null);
}
}

Expand Down Expand Up @@ -2539,10 +2559,7 @@ private void doDoubleClick(MouseEvent evt, int line, int offset,


private void doTripleClick(MouseEvent evt, int line, int offset, int dot) {
selectLine = true;
select(getLineStartOffset(line),getLineSelectionStopOffset(line));
selectionAncorStart = selectionStart;
selectionAncorEnd = selectionEnd;
selectLine(line);
}
}

Expand Down