#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 14 Mar 2017 20:29:15 +0100
changeset 6135 5d74fd984cde
parent 6134 97a51db349db
child 6136 54e34fbf8f6d
#FEATURE by cg class: TextView added: #copySelectionBox comment/format in: #examples changed: #editMenu
TextView.st
--- a/TextView.st	Tue Mar 14 20:29:07 2017 +0100
+++ b/TextView.st	Tue Mar 14 20:29:15 2017 +0100
@@ -139,7 +139,9 @@
     open a (readonly) textView on some information text:
                                                         [exBegin]
         TextView
-            openWith:'read this'
+            openWith:'read this
+and that,
+and also this'
             title:'demonstration'
                                                         [exEnd]
 
@@ -2132,6 +2134,35 @@
     "Modified: 17.5.1996 / 08:57:54 / cg"
 !
 
+copySelectionBox
+    "copy contents into the smalltalk copybuffer.
+     This copies it as a rectangular text area (INed/MAXed-like)"
+
+    |text startCol endCol len|
+
+    text := self selection.
+    text notNil ifTrue:[
+        "/ forget any emphasis ...
+        text := text collect:[:l | l isNil ifTrue:[''] ifFalse:[l string]].
+
+        startCol := selectionStartCol.
+        endCol := selectionEndCol.
+        len := endCol - startCol + 1.
+        text := text keysAndValuesCollect:[:idx :line |
+                    
+                    idx == 1 ifTrue:[
+                        (line paddedTo:len) copyTo:len    
+                    ] ifFalse:[
+                        (line paddedTo:startCol+len-1) copyFrom:startCol
+                    ].
+                ].    
+        self unselect.
+        self setClipboardText:text.
+    ]
+
+    "Created: / 14-03-2017 / 16:06:02 / cg"
+!
+
 defaultForGotoLine
     "return a default value to show in the gotoLine box"
 
@@ -2173,10 +2204,19 @@
     <resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)>
     <resource: #programMenu>
 
-    |items m|
-
-    items := #(
+    |item1 items m|
+
+    self sensor metaDown ifTrue:[
+        item1 := #(
+                        ('Copy Box'      copySelectionBox  CopyBox)
+                 )        
+    ] ifFalse:[
+        item1 := #(
                         ('Copy'          copySelection  Copy)
+                 )        
+    ].    
+
+    items := item1 , #(
                         ('-'             nil            )
                         ('Search...'     search         Find)
                         ('Goto Line...'  gotoLine       GotoLine)
@@ -2188,13 +2228,17 @@
                 ).
 
     m := PopUpMenu itemList:items resources:resources.
-
+    m := m asMenu.
+    
     self hasSelectionForCopy ifFalse:[
+        "/ (i := m itemAtValue:#copySelection) notNil ifTrue:[i disable].
+        "/ (i := m itemAtValue:#copySelectionBox) notNil ifTrue:[i disable].
         m disable:#copySelection.
+        m disable:#copySelectionBox.
     ].
     ^ m
 
-    "Modified: / 12.11.2001 / 13:43:56 / cg"
+    "Modified: / 14-03-2017 / 16:25:45 / cg"
 !
 
 find