Fix copy & paste in `TerminalView`
Fix various copy-paste bugs and weirdnesses, namly:
* preserve new lines when copying multi-line contents from
terminal view.
* preserve cursor position when selecting text both via
mouse and via double-click.
--- a/TerminalView.st Mon Jan 21 10:05:38 2019 +0000
+++ b/TerminalView.st Thu Feb 07 12:16:15 2019 +0000
@@ -2862,8 +2862,14 @@
!
copySelection
+ | savCursorLine savCursorCol |
+
+ savCursorLine := cursorLine.
+ savCursorCol := cursorCol.
super copySelection.
- self cursorToEndOfText
+ self cursorLine:savCursorLine col:savCursorCol.
+
+ "Modified: / 07-02-2019 / 12:08:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
paste:someText
@@ -2919,15 +2925,41 @@
sel := super selection.
sel isNil ifTrue:[^ sel].
- "/ if it is a line-wise collection, return multiple lines;
- "/ otherwise, concatenate to make it one long string.
- "/ this allows for multi-line commands (many args) to be copy-pasted easily
- selectionStartCol == 1 ifTrue:[
- selectionEndCol == 0 ifTrue:[
- ^ sel "/ a full-line (3xclick selection)
- ].
- ].
- ^ StringCollection with:(sel asStringWith:'').
+ "/ JV: NO, don't to this. This effectively hinders the ability to
+ "/ copy-paste multi-line contents of the terminal being pasted to
+ "/ another application.
+ "/
+ "/ I do consider this use-case much more important than the one
+ "/ below with long commands. Besides, no other terminal widhet behaves
+ "/ this way.
+ "/
+ "/ So, NO.
+
+"/ "/ if it is a line-wise collection, return multiple lines;
+"/ "/ otherwise, concatenate to make it one long string.
+"/ "/ this allows for multi-line commands (many args) to be copy-pasted easily
+"/ selectionStartCol == 1 ifTrue:[
+"/ selectionEndCol == 0 ifTrue:[
+"/ ^ sel "/ a full-line (3xclick selection)
+"/ ].
+"/ ].
+"/ ^ StringCollection with:(sel asStringWith:'').
+ ^ sel
+
+ "Modified (comment): / 07-02-2019 / 12:13:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TerminalView methodsFor:'selections'!
+
+selectWordAtLine:line col:col
+ | savCursorLine savCursorCol |
+
+ savCursorLine := cursorLine.
+ savCursorCol := cursorCol.
+ super selectWordAtLine:line col:col.
+ self cursorLine:savCursorLine col:savCursorCol.
+
+ "Created: / 26-01-2019 / 22:55:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TerminalView methodsFor:'sending'!