@@ -1072,19 +1072,8 @@ public final int getSelectionStart() {
10721072 */
10731073 public int getSelectionStart (int line )
10741074 {
1075- if (line == selectionStartLine )
1075+ if (line == selectionStartLine )
10761076 return selectionStart ;
1077- else if (rectSelect )
1078- {
1079- Element map = document .getDefaultRootElement ();
1080- int start = selectionStart - map .getElement (selectionStartLine )
1081- .getStartOffset ();
1082-
1083- Element lineElement = map .getElement (line );
1084- int lineStart = lineElement .getStartOffset ();
1085- int lineEnd = lineElement .getEndOffset () - 1 ;
1086- return Math .min (lineEnd ,lineStart + start );
1087- }
10881077 else
10891078 return getLineStartOffset (line );
10901079 }
@@ -1122,19 +1111,8 @@ public final int getSelectionStop()
11221111 */
11231112 public int getSelectionStop (int line )
11241113 {
1125- if (line == selectionEndLine )
1114+ if (line == selectionEndLine )
11261115 return selectionEnd ;
1127- else if (rectSelect )
1128- {
1129- Element map = document .getDefaultRootElement ();
1130- int end = selectionEnd - map .getElement (selectionEndLine )
1131- .getStartOffset ();
1132-
1133- Element lineElement = map .getElement (line );
1134- int lineStart = lineElement .getStartOffset ();
1135- int lineEnd = lineElement .getEndOffset () - 1 ;
1136- return Math .min (lineEnd ,lineStart + end );
1137- }
11381116 else
11391117 return getLineStopOffset (line ) - 1 ;
11401118 }
@@ -1297,10 +1275,6 @@ public void select(int start, int end)
12971275 caretTimer .restart ();
12981276 }
12991277
1300- // Disable rectangle select if selection start = selection end
1301- if (selectionStart == selectionEnd )
1302- rectSelect = false ;
1303-
13041278 // Clear the `magic' caret position used by up/down
13051279 magicCaret = -1 ;
13061280
@@ -1380,54 +1354,10 @@ protected void setNewSelectionWord( int line, int offset )
13801354 */
13811355 public final String getSelectedText ()
13821356 {
1383- if (selectionStart == selectionEnd )
1357+ if (selectionStart == selectionEnd ) {
13841358 return null ;
1385-
1386- if (rectSelect )
1387- {
1388- // Return each row of the selection on a new line
1389-
1390- Element map = document .getDefaultRootElement ();
1391-
1392- int start = selectionStart - map .getElement (selectionStartLine )
1393- .getStartOffset ();
1394- int end = selectionEnd - map .getElement (selectionEndLine )
1395- .getStartOffset ();
1396-
1397- // Certain rectangles satisfy this condition...
1398- if (end < start )
1399- {
1400- int tmp = end ;
1401- end = start ;
1402- start = tmp ;
1403- }
1404-
1405- StringBuilder sb = new StringBuilder ();
1406- Segment seg = new Segment ();
1407-
1408- for (int i = selectionStartLine ; i <= selectionEndLine ; i ++)
1409- {
1410- Element lineElement = map .getElement (i );
1411- int lineStart = lineElement .getStartOffset ();
1412- int lineEnd = lineElement .getEndOffset () - 1 ;
1413- int lineLen = lineEnd - lineStart ;
1414-
1415- lineStart = Math .min (lineStart + start ,lineEnd );
1416- lineLen = Math .min (end - start ,lineEnd - lineStart );
1417-
1418- getText (lineStart ,lineLen ,seg );
1419- sb .append (seg .array ,seg .offset ,seg .count );
1420-
1421- if (i != selectionEndLine )
1422- sb .append ('\n' );
1423- }
1424-
1425- return sb .toString ();
1426- }
1427- else
1428- {
1429- return getText (selectionStart ,
1430- selectionEnd - selectionStart );
1359+ } else {
1360+ return getText (selectionStart , selectionEnd - selectionStart );
14311361 }
14321362 }
14331363
@@ -1456,55 +1386,11 @@ public void setSelectedText(String selectedText, boolean recordCompoundEdit) {
14561386 }
14571387
14581388 try {
1459- if (rectSelect ) {
1460- Element map = document .getDefaultRootElement ();
1461-
1462- int start = selectionStart -
1463- map .getElement (selectionStartLine ).getStartOffset ();
1464- int end = selectionEnd -
1465- map .getElement (selectionEndLine ).getStartOffset ();
1466-
1467- // Certain rectangles satisfy this condition...
1468- if (end < start ) {
1469- int tmp = end ;
1470- end = start ;
1471- start = tmp ;
1472- }
1473-
1474- int lastNewline = 0 ;
1475- int currNewline = 0 ;
1476-
1477- for (int i = selectionStartLine ; i <= selectionEndLine ; i ++) {
1478- Element lineElement = map .getElement (i );
1479- int lineStart = lineElement .getStartOffset ();
1480- int lineEnd = lineElement .getEndOffset () - 1 ;
1481- int rectStart = Math .min (lineEnd ,lineStart + start );
1482-
1483- document .remove (rectStart ,Math .min (lineEnd - rectStart , end - start ));
1484-
1485- if (selectedText != null ) {
1486- currNewline = selectedText .indexOf ('\n' , lastNewline );
1487- if (currNewline == -1 ) {
1488- currNewline = selectedText .length ();
1489- }
1490- document .insertString (rectStart , selectedText .substring (lastNewline , currNewline ), null );
1491- lastNewline = Math .min (selectedText .length (), currNewline + 1 );
1492- }
1493- }
1494-
1495- if (selectedText != null &&
1496- currNewline != selectedText .length ()) {
1497- int offset = map .getElement (selectionEndLine ).getEndOffset () - 1 ;
1498- document .insertString (offset , "\n " , null );
1499- document .insertString (offset + 1 ,selectedText .substring (currNewline + 1 ), null );
1500- }
1501- } else {
1502- document .remove (selectionStart , selectionEnd - selectionStart );
1503- if (selectedText != null ) {
1504- document .insertString (selectionStart , selectedText ,null );
1505- }
1389+ document .remove (selectionStart , selectionEnd - selectionStart );
1390+ if (selectedText != null ) {
1391+ document .insertString (selectionStart , selectedText ,null );
15061392 }
1507- } catch (BadLocationException bl ) {
1393+ } catch (BadLocationException bl ) {
15081394 bl .printStackTrace ();
15091395 throw new InternalError ("Cannot replace selection" );
15101396
@@ -1632,24 +1518,6 @@ public final void setOverwriteEnabled(boolean overwrite)
16321518 painter .invalidateSelectedLines ();
16331519 }
16341520
1635- /**
1636- * Returns true if the selection is rectangular, false otherwise.
1637- */
1638- public final boolean isSelectionRectangular ()
1639- {
1640- return rectSelect ;
1641- }
1642-
1643- /**
1644- * Sets if the selection should be rectangular.
1645- * @param rectSelect True if the selection should be rectangular,
1646- * false otherwise.
1647- */
1648- public final void setSelectionRectangular (boolean rectSelect )
1649- {
1650- this .rectSelect = rectSelect ;
1651- painter .invalidateSelectedLines ();
1652- }
16531521
16541522 /**
16551523 * Returns the position of the highlighted bracket (the bracket
@@ -2071,7 +1939,6 @@ public void processKeyEvent(KeyEvent event) {
20711939
20721940 protected int magicCaret ;
20731941 protected boolean overwrite ;
2074- protected boolean rectSelect ;
20751942
20761943
20771944 protected void fireCaretEvent ()
@@ -2391,8 +2258,6 @@ public void mouseDragged(MouseEvent evt) {
23912258 if (popup != null && popup .isVisible ()) return ;
23922259
23932260 if (!selectWord && !selectLine ) {
2394- //setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0);
2395- setSelectionRectangular (evt .isControlDown ());
23962261 try {
23972262 select (getMarkPosition (), xyToOffset (evt .getX (), evt .getY ()));
23982263 } catch (ArrayIndexOutOfBoundsException e ) {
@@ -2531,7 +2396,6 @@ public void mouseReleased(MouseEvent event) {
25312396
25322397 private void doSingleClick (MouseEvent evt , int line , int offset , int dot ) {
25332398 if ((evt .getModifiers () & InputEvent .SHIFT_MASK ) != 0 ) {
2534- rectSelect = (evt .getModifiers () & InputEvent .CTRL_MASK ) != 0 ;
25352399 select (getMarkPosition (),dot );
25362400 } else {
25372401 setCaretPosition (dot );
0 commit comments