diff --git a/app/src/processing/app/syntax/DefaultInputHandler.java b/app/src/processing/app/syntax/DefaultInputHandler.java index 3001f9eebe..c8db2bf7da 100755 --- a/app/src/processing/app/syntax/DefaultInputHandler.java +++ b/app/src/processing/app/syntax/DefaultInputHandler.java @@ -46,7 +46,6 @@ public void addDefaultKeyBindings() addKeyBinding("TAB",INSERT_TAB); addKeyBinding("INSERT",OVERWRITE); - addKeyBinding("C+\\",TOGGLE_RECT); addKeyBinding("HOME",HOME); addKeyBinding("END",END); diff --git a/app/src/processing/app/syntax/InputHandler.java b/app/src/processing/app/syntax/InputHandler.java index 5cde91f2a9..debf3023bb 100644 --- a/app/src/processing/app/syntax/InputHandler.java +++ b/app/src/processing/app/syntax/InputHandler.java @@ -84,7 +84,6 @@ public abstract class InputHandler extends KeyAdapter public static final ActionListener SELECT_PREV_PAGE = new prev_page(true); public static final ActionListener SELECT_PREV_WORD = new prev_word(true); public static final ActionListener REPEAT = new repeat(); - public static final ActionListener TOGGLE_RECT = new toggle_rect(); public static final ActionListener CLIPBOARD_CUT = new clipboard_cut(); // [fry] public static final ActionListener CLIPBOARD_COPY = new clipboard_copy(); public static final ActionListener CLIPBOARD_PASTE = new clipboard_paste(); @@ -133,7 +132,6 @@ public abstract class InputHandler extends KeyAdapter actions.put("select-prev-page",SELECT_PREV_PAGE); actions.put("select-prev-word",SELECT_PREV_WORD); actions.put("repeat",REPEAT); - actions.put("toggle-rect",TOGGLE_RECT); actions.put("insert-char",INSERT_CHAR); actions.put("clipboard-cut",CLIPBOARD_CUT); actions.put("clipboard-copy",CLIPBOARD_COPY); @@ -1060,14 +1058,6 @@ public void actionPerformed(ActionEvent evt) { } - public static class toggle_rect implements ActionListener { - public void actionPerformed(ActionEvent evt) { - JEditTextArea textArea = getTextArea(evt); - textArea.setSelectionRectangular(!textArea.isSelectionRectangular()); - } - } - - public static class clipboard_cut implements ActionListener { public void actionPerformed(ActionEvent evt) { getTextArea(evt).cut(); diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 865974d011..0466a19553 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -1072,19 +1072,8 @@ public final int getSelectionStart() { */ public int getSelectionStart(int line) { - if(line == selectionStartLine) + if (line == selectionStartLine) return selectionStart; - else if(rectSelect) - { - Element map = document.getDefaultRootElement(); - int start = selectionStart - map.getElement(selectionStartLine) - .getStartOffset(); - - Element lineElement = map.getElement(line); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; - return Math.min(lineEnd,lineStart + start); - } else return getLineStartOffset(line); } @@ -1122,19 +1111,8 @@ public final int getSelectionStop() */ public int getSelectionStop(int line) { - if(line == selectionEndLine) + if (line == selectionEndLine) return selectionEnd; - else if(rectSelect) - { - Element map = document.getDefaultRootElement(); - int end = selectionEnd - map.getElement(selectionEndLine) - .getStartOffset(); - - Element lineElement = map.getElement(line); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; - return Math.min(lineEnd,lineStart + end); - } else return getLineStopOffset(line) - 1; } @@ -1297,10 +1275,6 @@ public void select(int start, int end) caretTimer.restart(); } - // Disable rectangle select if selection start = selection end - if(selectionStart == selectionEnd) - rectSelect = false; - // Clear the `magic' caret position used by up/down magicCaret = -1; @@ -1380,54 +1354,10 @@ protected void setNewSelectionWord( int line, int offset ) */ public final String getSelectedText() { - if(selectionStart == selectionEnd) + if (selectionStart == selectionEnd) { return null; - - if(rectSelect) - { - // Return each row of the selection on a new line - - Element map = document.getDefaultRootElement(); - - int start = selectionStart - map.getElement(selectionStartLine) - .getStartOffset(); - int end = selectionEnd - map.getElement(selectionEndLine) - .getStartOffset(); - - // Certain rectangles satisfy this condition... - if(end < start) - { - int tmp = end; - end = start; - start = tmp; - } - - StringBuilder sb = new StringBuilder(); - Segment seg = new Segment(); - - for(int i = selectionStartLine; i <= selectionEndLine; i++) - { - Element lineElement = map.getElement(i); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; - int lineLen = lineEnd - lineStart; - - lineStart = Math.min(lineStart + start,lineEnd); - lineLen = Math.min(end - start,lineEnd - lineStart); - - getText(lineStart,lineLen,seg); - sb.append(seg.array,seg.offset,seg.count); - - if(i != selectionEndLine) - sb.append('\n'); - } - - return sb.toString(); - } - else - { - return getText(selectionStart, - selectionEnd - selectionStart); + } else { + return getText(selectionStart, selectionEnd - selectionStart); } } @@ -1456,55 +1386,11 @@ public void setSelectedText(String selectedText, boolean recordCompoundEdit) { } try { - if (rectSelect) { - Element map = document.getDefaultRootElement(); - - int start = selectionStart - - map.getElement(selectionStartLine).getStartOffset(); - int end = selectionEnd - - map.getElement(selectionEndLine).getStartOffset(); - - // Certain rectangles satisfy this condition... - if (end < start) { - int tmp = end; - end = start; - start = tmp; - } - - int lastNewline = 0; - int currNewline = 0; - - for (int i = selectionStartLine; i <= selectionEndLine; i++) { - Element lineElement = map.getElement(i); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; - int rectStart = Math.min(lineEnd,lineStart + start); - - document.remove(rectStart,Math.min(lineEnd - rectStart, end - start)); - - if (selectedText != null) { - currNewline = selectedText.indexOf('\n', lastNewline); - if (currNewline == -1) { - currNewline = selectedText.length(); - } - document.insertString(rectStart, selectedText.substring(lastNewline, currNewline), null); - lastNewline = Math.min(selectedText.length(), currNewline + 1); - } - } - - if (selectedText != null && - currNewline != selectedText.length()) { - int offset = map.getElement(selectionEndLine).getEndOffset() - 1; - document.insertString(offset, "\n", null); - document.insertString(offset + 1,selectedText.substring(currNewline + 1), null); - } - } else { - document.remove(selectionStart, selectionEnd - selectionStart); - if (selectedText != null) { - document.insertString(selectionStart, selectedText,null); - } + document.remove(selectionStart, selectionEnd - selectionStart); + if (selectedText != null) { + document.insertString(selectionStart, selectedText,null); } - } catch(BadLocationException bl) { + } catch (BadLocationException bl) { bl.printStackTrace(); throw new InternalError("Cannot replace selection"); @@ -1632,24 +1518,6 @@ public final void setOverwriteEnabled(boolean overwrite) painter.invalidateSelectedLines(); } - /** - * Returns true if the selection is rectangular, false otherwise. - */ - public final boolean isSelectionRectangular() - { - return rectSelect; - } - - /** - * Sets if the selection should be rectangular. - * @param rectSelect True if the selection should be rectangular, - * false otherwise. - */ - public final void setSelectionRectangular(boolean rectSelect) - { - this.rectSelect = rectSelect; - painter.invalidateSelectedLines(); - } /** * Returns the position of the highlighted bracket (the bracket @@ -2071,7 +1939,6 @@ public void processKeyEvent(KeyEvent event) { protected int magicCaret; protected boolean overwrite; - protected boolean rectSelect; protected void fireCaretEvent() @@ -2391,8 +2258,6 @@ public void mouseDragged(MouseEvent evt) { if (popup != null && popup.isVisible()) return; if (!selectWord && !selectLine) { - //setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0); - setSelectionRectangular(evt.isControlDown()); try { select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY())); } catch (ArrayIndexOutOfBoundsException e) { @@ -2531,7 +2396,6 @@ public void mouseReleased(MouseEvent event) { private void doSingleClick(MouseEvent evt, int line, int offset, int dot) { if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { - rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0; select(getMarkPosition(),dot); } else { setCaretPosition(dot); diff --git a/app/src/processing/app/syntax/TextAreaPainter.java b/app/src/processing/app/syntax/TextAreaPainter.java index 34da0c35e6..59c99a5a88 100644 --- a/app/src/processing/app/syntax/TextAreaPainter.java +++ b/app/src/processing/app/syntax/TextAreaPainter.java @@ -833,13 +833,7 @@ protected void paintLineHighlight(Graphics gfx, int line, int y) { int lineStart = textArea.getLineStartOffset(line); int x1, x2; - if (textArea.isSelectionRectangular()) { - int lineLen = textArea.getLineLength(line); - x1 = textArea._offsetToX(line,Math.min(lineLen, selectionStart - textArea.getLineStartOffset(selectionStartLine))); - x2 = textArea._offsetToX(line,Math.min(lineLen, selectionEnd - textArea.getLineStartOffset(selectionEndLine))); - if (x1 == x2) - x2++; - } else if(selectionStartLine == selectionEndLine) { + if (selectionStartLine == selectionEndLine) { x1 = textArea._offsetToX(line, selectionStart - lineStart); x2 = textArea._offsetToX(line, selectionEnd - lineStart); } else if(line == selectionStartLine) {