class definition
authorClaus Gittinger <cg@exept.de>
Wed, 15 Feb 2012 17:50:10 +0100
changeset 4373 22fb03e6d08a
parent 4372 45db247121fd
child 4374 e0cdb94c4530
class definition comment/format in: #sortSelection:ignoreCase: changed: #editMenu #sort:ignoreCase:fromLine:toLine:
EditTextView.st
--- a/EditTextView.st	Wed Feb 15 16:33:45 2012 +0100
+++ b/EditTextView.st	Wed Feb 15 17:50:10 2012 +0100
@@ -25,7 +25,7 @@
 		lastReplacementInfo'
 	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
 		DefaultCursorType DefaultCursorNoFocusForegroundColor
-		DefaultCursorTypeNoFocus'
+		DefaultCursorTypeNoFocus LastColumnNumberForSort'
 	poolDictionaries:''
 	category:'Views-Text'
 !
@@ -5649,13 +5649,15 @@
     sortItems := #(
                     ('Lines'                            (sortSelection:ignoreCase: #lines false)        )
                     ('Lines by First Word'              (sortSelection:ignoreCase: #linesByFirstWord false)     )
-                    ('Lines by nth Word'                (sortSelection:ignoreCase: #linesByNthWord false)       )
+                    ('Lines by n''th Word'              (sortSelection:ignoreCase: #linesByNthWord false)       )
+                    ('Lines by n''th Number'            (sortSelection:ignoreCase: #linesByNthNumber false)     )
+                    ('Lines by n''th Hex Number'        (sortSelection:ignoreCase: #linesByNthHexNumber false)     )
                     ('Words'                            (sortSelection:ignoreCase: #words false)        )
                     ('-'                                                      )
-                    ('Lines (ignore case)'              (sortSelection:ignoreCase: #lines true)         )
-                    ('Lines by First Word (ignore case)'(sortSelection:ignoreCase: #linesByFirstWord true)      )
-                    ('Lines by nth Word (ignore case)'  (sortSelection:ignoreCase: #linesByNthWord true)        )
-                    ('Words (ignore case)'              (sortSelection:ignoreCase: #words true)         )
+                    ('Lines (ignore case)'               (sortSelection:ignoreCase: #lines true)         )
+                    ('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true)      )
+                    ('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true)        )
+                    ('Words (ignore case)'               (sortSelection:ignoreCase: #words true)         )
               ).
 
     toolItems := #(
@@ -5725,7 +5727,7 @@
         m := main
     ].
 
-    SOAP::GoogleClient isNil ifTrue:[
+    (Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[
         "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
         m disable:#googleSpellingSuggestion
     ].
@@ -5782,7 +5784,7 @@
     ].
     ^ m.
 
-    "Modified: / 14-07-2011 / 12:13:14 / cg"
+    "Modified: / 15-02-2012 / 17:48:39 / cg"
 !
 
 getTextSelectionFromHistory
@@ -6393,35 +6395,48 @@
     lineWise := true.
 
     how == #lines ifTrue:[
-	extractor := [:l | l withoutLeadingSeparators].
-    ] ifFalse:[ how == #linesByFirstWord ifTrue:[
-	extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
-    ] ifFalse:[ how == #linesByNthWord ifTrue:[
-	nStr := Dialog request:'Word (1..)'.
-	nStr isEmptyOrNil ifTrue:[^ self].
-	n := Integer readFrom:nStr onError:[^ self].
-
-	extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')].
-    ] ifFalse:[ how == #words ifTrue:[
-	lineWise := false.
-	extractor := [:w | w].
-    ] ifFalse:[
-	self error:'unknown sort criteria: ', how printString.
-    ]]]].
+        extractor := [:l | l withoutLeadingSeparators].
+    ] ifFalse:[ 
+        how == #linesByFirstWord ifTrue:[
+            extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
+        ] ifFalse:[ 
+            ((how == #linesByNthWord) or:[ how == #linesByNthNumber  or:[ how == #linesByNthHexNumber]]) ifTrue:[
+                nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2).
+                nStr isEmptyOrNil ifTrue:[^ self].
+                n := Integer readFrom:nStr onError:[^ self].
+                LastColumnNumberForSort := n.
+                extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')].
+                how == #linesByNthNumber ifTrue:[
+                    extractor := [:l | Integer readFrom:(extractor value:l) onError:0]
+                ] ifFalse:[
+                    how == #linesByNthHexNumber ifTrue:[
+                        extractor := [:l | Integer readFrom:(extractor value:l) radix:16 onError:0]
+                    ]
+                ].
+            ] ifFalse:[ 
+                how == #words ifTrue:[
+                    lineWise := false.
+                    extractor := [:w | w].
+                ] ifFalse:[
+                    self error:'unknown sort criteria: ', how printString.
+                ]
+            ]
+        ]
+    ].
 
     ignoreCase ifTrue:[
-	fetcher := [:l | (extractor value:l) asLowercase].
+        fetcher := [:l | (extractor value:l) asLowercase].
     ] ifFalse:[
-	fetcher := extractor.
+        fetcher := extractor.
     ].
 
     lineWise ifTrue:[
-	start == end ifTrue:[^ self ].
-	lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
-	lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)].
-	(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line].
-	self textChanged.
-	^ self.
+        start == end ifTrue:[^ self ].
+        lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
+        lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)].
+        (start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line].
+        self textChanged.
+        ^ self.
     ].
 
     s := self selectionAsString.
@@ -6430,6 +6445,8 @@
     s := words asStringCollection asStringWith:Character space.
     self replace:s.
     self textChanged.
+
+    "Modified: / 15-02-2012 / 17:49:52 / cg"
 !
 
 sortSelection:how ignoreCase:ignoreCase
@@ -6446,8 +6463,12 @@
     ].
 
     self
-        undoableDo:[ self sort:how ignoreCase:ignoreCase fromLine:start toLine:end ]
+        undoableDo:[ 
+            self sort:how ignoreCase:ignoreCase fromLine:start toLine:end 
+        ]
         info:'Sort'
+
+    "Modified (format): / 15-02-2012 / 16:52:53 / cg"
 !
 
 specialCharacters
@@ -8003,9 +8024,9 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.521 2012-02-14 10:21:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.522 2012-02-15 16:50:10 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.521 2012-02-14 10:21:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.522 2012-02-15 16:50:10 cg Exp $'
 ! !