EditTextView.st
changeset 4940 73e7031a4a85
parent 4889 3ee5b37416a1
child 4966 fdd9e824fd05
--- a/EditTextView.st	Wed Mar 05 16:15:46 2014 +0100
+++ b/EditTextView.st	Wed Mar 05 16:16:07 2014 +0100
@@ -1429,8 +1429,8 @@
     |wasOn|
 
     wasOn := self hideCursor.
-    cursorFgColor := color1 onDevice:device.
-    cursorBgColor := color2 onDevice:device.
+    cursorFgColor := color1 onDevice:self graphicsDevice.
+    cursorBgColor := color2 onDevice:self graphicsDevice.
     wasOn ifTrue:[self showCursor]
 !
 
@@ -4564,7 +4564,7 @@
     "On X11, be nice and paste PRIMARY when middle click. 
      Note, that middle button on X11 is translated to button
      128 in Smalltalk/X - see XWorkstation class>>initializeConstants"
-    (button == #paste and:[device platformName == #X11]) ifTrue:[
+    (button == #paste and:[self graphicsDevice platformName == #X11]) ifTrue:[
         self undoableDo:[
             self paste: (self getClipboardText:#selection).
         ].
@@ -4838,7 +4838,7 @@
     ].
 
     key isSymbol ifTrue:[
-        (device modifierKeys includes:key) ifFalse:[
+        (self graphicsDevice modifierKeys includes:key) ifFalse:[
             lastReplacementInfo stillCollectingInput:false.
         ]
     ].
@@ -5272,11 +5272,11 @@
     selEndLineBefore := selectionEndLine.
     selEndColBefore := self selectionEndCol.
 
-    (characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
+    (gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
         key isCharacter ifTrue:[
-            key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding.
+            key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding.
         ] ifFalse:[
-            key := CharacterEncoder encodeString:key from:#'iso10646-1' into:characterEncoding.
+            key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding.
         ].
     ].
 
@@ -5326,7 +5326,7 @@
                              savLine := cursorLine.
                              savCol := cursorCol.
                              self cursorLine:line col:col.
-                             device flush.
+                             self flush.
 
                              "/ want to wait 200ms, but not if another keyPress
                              "/ arrives in the meantime ...
@@ -5653,9 +5653,9 @@
 
     super fetchDeviceResources.
 
-    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
-    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
-    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
+    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:self graphicsDevice].
+    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:self graphicsDevice].
+    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:self graphicsDevice].
 
     "Created: 14.1.1997 / 00:15:24 / cg"
     "Modified: 18.2.1997 / 15:02:46 / cg"
@@ -5969,7 +5969,9 @@
                     ('Search...'        search         Find     )
                     ('Goto Line...'     gotoLine       GotoLine )
                     ('-'                                        )
-                    ('Tools'            tools                   ) ).
+                    ('Tools'            tools                   )
+                    ('Insert Unicode...' insertUnicode )
+            ).
     CharacterSetView notNil ifTrue:[
         items := items ,
                     #(
@@ -6136,7 +6138,7 @@
                        babelFishTranslate googleSpellingSuggestion sort
                        convertSelectionToLowercaseOrUppercaseOrUppercaseFirst 
                        joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral
-                       specialCharacters)
+                       insertUnicode specialCharacters)
     ].
     self hasSelectionForCopy ifFalse:[
         m disable:#copySelection.
@@ -6183,7 +6185,7 @@
 getTextSelectionFromHistory
     |sel list box history|
 
-    history := device getCopyBufferHistory copy.
+    history := self graphicsDevice getCopyBufferHistory copy.
     list := history collect:[:entry |
                 |text shown|
 
@@ -6386,6 +6388,26 @@
     "Created: / 28-07-2007 / 13:01:16 / cg"
 !
 
+insertUnicode
+    "open a Dialog requesting an integer value and insert it as unicode character"
+
+    |unicodePoint unicodeChar unicodeString|
+
+    unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'.
+    unicodeString size < 2 ifTrue:[
+        ^ self.
+    ].
+    (unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[
+        unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self].
+    ] ifFalse:[
+        unicodePoint := Integer readFrom:unicodeString onError:[^ self].
+    ].
+        
+    unicodeChar := Character value:unicodePoint.
+    self keyPress:unicodeChar x:0 y:0.
+    self keyRelease:unicodeChar x:0 y:0.
+!
+
 internalSpellingSuggestion
     "insert the internal-spelling suggestion for the selected text.
      Requires that the RefactoryBrowser/line/spelCheck stuff is loaded."
@@ -6482,7 +6504,7 @@
 
         code := ex parameter.
         codingErrorReported ifFalse:[
-            msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'.
+            msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'.
             code notNil ifTrue:[
                 msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
             ].
@@ -6492,8 +6514,8 @@
         ex proceedWith:ex defaultValue
     ] do:[
         s isString ifTrue:[
-            s encoding ~~ characterEncoding ifTrue:[
-                s := s encodeFrom:(s encoding) into:characterEncoding.
+            s encoding ~~ gc characterEncoding ifTrue:[
+                s := s encodeFrom:(s encoding) into:gc characterEncoding.
             ].
 
             s := s asStringCollection.
@@ -6504,7 +6526,7 @@
             ]
         ] ifFalse:[
             s isStringCollection ifTrue:[
-                s := s encodeFrom:(s encoding) into:characterEncoding.
+                s := s encodeFrom:(s encoding) into:gc characterEncoding.
             ] ifFalse:[
                 (self
                     confirm:(resources
@@ -7174,8 +7196,8 @@
     super realize.
 
     self makeCursorVisible.
-    cursorFgColor := cursorFgColor onDevice:device.
-    cursorBgColor := cursorBgColor onDevice:device.
+    cursorFgColor := cursorFgColor onDevice:self graphicsDevice.
+    cursorBgColor := cursorBgColor onDevice:self graphicsDevice.
 
     "Modified: 20.12.1996 / 14:16:05 / cg"
     "Created: 24.7.1997 / 18:24:12 / cg"
@@ -8514,10 +8536,10 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.600 2014-02-13 18:37:39 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.601 2014-03-05 15:16:07 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.600 2014-02-13 18:37:39 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.601 2014-03-05 15:16:07 stefan Exp $'
 ! !