Skip to content

Commit 2f06d71

Browse files
committed
'Ugly' hack to slow down the selection of text in the IDE via mouse dragging of big chunks of text
Due the outdated of the JEditTextArea, there is not much else to do than this. But it works: Try to select and stop the selection in a precise line without this hack, is not possible due the uncontrollable speed of the unmodified version
1 parent 36a2d0b commit 2f06d71

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/src/processing/app/syntax/JEditTextArea.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,7 @@ public void changedUpdate(DocumentEvent evt)
21192119

21202120
class DragHandler implements MouseMotionListener
21212121
{
2122+
int prevStart = -1, prevStop = -1;
21222123
public void mouseDragged(MouseEvent evt)
21232124
{
21242125
if (popup != null && popup.isVisible()) return;
@@ -2127,6 +2128,18 @@ public void mouseDragged(MouseEvent evt)
21272128
setSelectionRectangular((evt.getModifiers()
21282129
& InputEvent.CTRL_MASK) != 0);
21292130
select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY()));
2131+
2132+
int start = getSelectionStartLine(), stop =getSelectionStopLine();
2133+
//int selectedLines = Math.max(stop,start)-Math.min(stop,start);
2134+
int selectedLines = stop-start;
2135+
2136+
if(start!=stop && (prevStart!=start || prevStop!=stop) && selectedLines>getVisibleLines())
2137+
{
2138+
try { Thread.sleep(10*(Math.max(20-(selectedLines-getVisibleLines()),4))); } catch (Exception e) {}
2139+
2140+
prevStart = start;
2141+
prevStop =stop;
2142+
}
21302143
} else {
21312144
int line = yToLine(evt.getY());
21322145
if ( selectWord ) {

0 commit comments

Comments
 (0)