EditTextView.st
branchdelegated_gc_text-view-selection-refactoring
changeset 5221 d036f1df0408
parent 5182 64bfca913dab
parent 5220 5251ecf0c9bb
child 5294 d53a2bdc1569
--- a/EditTextView.st	Mon Nov 24 13:48:48 2014 +0000
+++ b/EditTextView.st	Wed Dec 10 23:48:16 2014 +0000
@@ -1179,6 +1179,12 @@
     ^ editMode value isInsertMode
 !
 
+isNotReadOnly
+    "return true, if the text is not readonly."
+
+    ^ self isReadOnly not
+!
+
 isReadOnly
     "return true, if the text is readonly."
 
@@ -3500,7 +3506,7 @@
     col == 0 ifTrue:[
         line > 1 ifTrue:[
             line := line - 1. 
-            col := (self listAt:line) size. 
+            col := (self listAt:line) size + 1. 
         ] ifFalse:[
             col := 1.
         ]
@@ -3799,7 +3805,7 @@
 replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
     "replace a substring at a character position"
 
-    "/ sigh - insert first, to avoid troible due to shifing-in virtual line ends
+    "/ sigh - insert first, to avoid trouble due to shifing-in virtual line ends
     self insertString:newString atCharacterPosition:charPos1.
     self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
 !
@@ -4740,7 +4746,7 @@
 buttonPress:button x:x y:y
     "hide the cursor when button is activated"
 
-    hasKeyboardFocus := true.
+    hasKeyboardFocus := true.   "/ cg: why is this needed?
     dragIsActive := false.
 
     completionSupport notNil ifTrue:[ 
@@ -5792,7 +5798,7 @@
             "/ this is done BEFORE the buttonPress event is delivered.
             "/ therefore, allow for the activate of the completionMenu and it's button event to be processed.
             "/ before forcing it to be closed...
-            Processor addTimedBlock:[completionSupport "release" editViewLostFocus] afterMilliseconds:200.
+            Processor addTimedBlock:[completionSupport editViewLostFocus] afterMilliseconds:200.
         ].
     ].
 
@@ -6567,7 +6573,7 @@
             sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what).
         ]
     ].
-    acceptEnabled == false ifTrue:[
+    self canAccept ifFalse:[
         m disable:#accept
     ].
     ^ m.
@@ -6942,11 +6948,16 @@
     startLine := l1 := cursorLine.
     startCol := c1 := cursorCol.
 
-    "do not expand tabs into spaces here -
-     they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
-     Some Subviews want to paste with unexpanded tabs!!"
-
-    self insertLines:s withCR:withCR.
+    "do not autoindent here. 
+     It does make things very ugly, in the inspector 
+     (try inspecting a multiline string)..."
+    self withAutoIndent:false do:[
+        "do not expand tabs into spaces here -
+         they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
+         Some Subviews want to paste with unexpanded tabs!!"
+
+        self insertLines:s withCR:withCR.
+    ].
     l2 := cursorLine.
     c2 := (cursorCol - 1).
     self selectFromLine:l1 col:c1 toLine:l2 col:c2.
@@ -7448,6 +7459,7 @@
     typeOfSelection == #paste ifTrue:[
         ^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
     ].
+    "/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. 
     ^ super currentSelectionBgColor
 
     "
@@ -7533,6 +7545,32 @@
 
 !EditTextView methodsFor:'queries'!
 
+canAccept
+    "true if text can be accepts.
+     Used to disable the menu if there is nothing selector or the text is readonly"
+
+    ^ acceptEnabled ~~ false
+!
+
+canCut
+    "true if there is a selection possibly to be cut.
+     Used to disable the menu if there is nothing selector or the text is readonly"
+
+    self isReadOnly ifTrue:[ ^ false ].
+    ^ self hasSelection
+!
+
+canDoAgain
+    "true if there is a possible repeat last edit operation.
+     Used to disable the menu if there is nothing"
+
+    |lastStringToReplace|
+
+    self isReadOnly ifTrue:[ ^ false ].
+    lastStringToReplace := lastReplacementInfo lastStringToReplace.
+    ^ lastStringToReplace notNil
+!
+
 currentLine
     "the current line (for relative gotos)"
 
@@ -7972,6 +8010,11 @@
     "/ the very first one. Actually, this method and comment was 
     "/ written by Martin Dvorak. Yeah, being bit nostalgic...
 
+    "Pokud existuje selekce, upravi ji
+     podle aktualni pozice kurzoru a pozice
+     po provedeni blocku.
+     Urceno k implementaci Shift-Home a Shift-End
+     Nejak nevim, jak to presneji popsat :-)"
 
     | startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown flip extModeStandard |
 
@@ -9007,11 +9050,11 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.626 2014-11-20 19:30:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.628 2014-12-05 13:39:25 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.626 2014-11-20 19:30:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.628 2014-12-05 13:39:25 cg Exp $'
 !
 
 version_HG