EditTextView.st
changeset 324 9eec6d69e155
parent 323 58102e6bc087
child 331 c58f0c52d2d7
equal deleted inserted replaced
323:58102e6bc087 324:9eec6d69e155
    11 "
    11 "
    12 
    12 
    13 TextView subclass:#EditTextView
    13 TextView subclass:#EditTextView
    14 	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
    14 	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
    15 		prevCursorState readOnly modified fixedSize exceptionBlock
    15 		prevCursorState readOnly modified fixedSize exceptionBlock
    16 		cursorFgColor cursorBgColor cursorType undoAction
    16 		cursorFgColor cursorBgColor cursorType undoAction typeOfSelection
    17 		typeOfSelection lastString lastReplacement lastAction replacing
    17 		lastString lastReplacement lastAction replacing
    18 		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
    18 		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
    19 		tabMeansNextField'
    19 		tabMeansNextField'
    20 	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
    20 	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
    21 		DefaultCursorType'
    21 		DefaultCursorType'
    22 	poolDictionaries:''
    22 	poolDictionaries:''
  2092 
  2092 
  2093      see TextView>>:x:y
  2093      see TextView>>:x:y
  2094     "
  2094     "
  2095     (('[fF][0-9]' match:key)
  2095     (('[fF][0-9]' match:key)
  2096     or:['[fF][0-9][0-9]' match:key]) ifTrue:[
  2096     or:['[fF][0-9][0-9]' match:key]) ifTrue:[
  2097         device shiftDown ifFalse:[
  2097         self sensor shiftDown ifFalse:[
  2098             fKeyMacros := Smalltalk at:#FunctionKeySequences.
  2098             fKeyMacros := Smalltalk at:#FunctionKeySequences.
  2099             fKeyMacros notNil ifTrue:[
  2099             fKeyMacros notNil ifTrue:[
  2100                 (fKeyMacros includesKey:key) ifTrue:[
  2100                 (fKeyMacros includesKey:key) ifTrue:[
  2101                     self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
  2101                     self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
  2102                     ^ self
  2102                     ^ self
  2192             ^ self
  2192             ^ self
  2193         ].
  2193         ].
  2194     ].
  2194     ].
  2195 
  2195 
  2196     (key == #Return)    ifTrue:[
  2196     (key == #Return)    ifTrue:[
  2197         device shiftDown ifTrue:[
  2197         self sensor shiftDown ifTrue:[
  2198             self unselect. self cursorReturn. ^self
  2198             self unselect. self cursorReturn. ^self
  2199         ].
  2199         ].
  2200         readOnly ifTrue:[
  2200         readOnly ifTrue:[
  2201             self unselect; makeCursorVisible.
  2201             self unselect; makeCursorVisible.
  2202             self cursorReturn
  2202             self cursorReturn
  2214         ].
  2214         ].
  2215         ^self
  2215         ^self
  2216     ].
  2216     ].
  2217 
  2217 
  2218     (key == #Tab) ifTrue:[
  2218     (key == #Tab) ifTrue:[
  2219         device shiftDown ifTrue:[
  2219         self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
       
  2220 
       
  2221         self sensor shiftDown ifTrue:[
  2220             "
  2222             "
  2221              the old version used shift-tab as backtab,
  2223              the old version used shift-tab as backtab,
  2222              however, backtab was seldom used.
  2224              however, backtab was seldom used.
  2223              An alternative is to make it a non-inserting tab ...
  2225              An alternative is to make it a non-inserting tab ...
  2224             "
  2226             "
  2225             "/ self unselect. self cursorBacktab. ^self
  2227             "/ self unselect. self cursorBacktab.
  2226             self unselect. self cursorTab. ^self
  2228             self unselect. self cursorTab. 
       
  2229             ^self
  2227         ].
  2230         ].
       
  2231 
  2228         "
  2232         "
  2229          uncomment line below, if you like RAND/INed/MAXed editor behavior
  2233          uncomment line below, if you like RAND/INed/MAXed editor behavior
  2230          (where tab-key is only cursor positioning)
  2234          (where tab-key is only cursor positioning)
  2231          this was the original behavior of the TAB key, but many people
  2235          this was the original behavior of the TAB key, but many people
  2232          complained ....
  2236          complained ....
  2233         "
  2237         "
  2234         "/ self unselect. self cursorTab. ^self
  2238         "/ self unselect. self cursorTab. ^self
  2235         self unselect. self insertTabAtCursor. ^self
  2239         self unselect. self insertTabAtCursor. 
       
  2240         ^self
  2236     ].
  2241     ].
  2237 
  2242 
  2238     (key == #BackSpace) ifTrue:[
  2243     (key == #BackSpace) ifTrue:[
  2239 
  2244 
  2240         "/ old version just unselected here 
  2245         "/ old version just unselected here 
  2296         self makeCursorVisible.
  2301         self makeCursorVisible.
  2297         self unselect. self insertLine:nil before:cursorLine. ^self
  2302         self unselect. self insertLine:nil before:cursorLine. ^self
  2298     ].
  2303     ].
  2299     super keyPress:key x:x y:y
  2304     super keyPress:key x:x y:y
  2300 
  2305 
  2301     "Modified: 16.12.1995 / 13:11:45 / cg"
  2306     "Modified: 7.2.1996 / 19:26:28 / cg"
  2302 !
  2307 !
  2303 
  2308 
  2304 mapped
  2309 mapped
  2305     "view was made visible"
  2310     "view was made visible"
  2306 
  2311 
  2773     contentsWasSaved := false
  2778     contentsWasSaved := false
  2774 ! !
  2779 ! !
  2775 
  2780 
  2776 !EditTextView methodsFor:'queries'!
  2781 !EditTextView methodsFor:'queries'!
  2777 
  2782 
  2778 canTab
  2783 tabMeansNextField
  2779     "return true, if a Tab character should shift focus."
  2784     "return true, if a Tab character should shift focus."
  2780 
  2785 
  2781     "if not readOnly, I want my tab keys ..."
  2786     "if not readOnly, I want my tab keys ..."
  2782 
  2787 
  2783     ^ readOnly or:[tabMeansNextField]
  2788     ^ readOnly or:[tabMeansNextField]
       
  2789 
       
  2790     "Created: 7.2.1996 / 19:15:31 / cg"
  2784 !
  2791 !
  2785 
  2792 
  2786 widthOfContents
  2793 widthOfContents
  2787     "return the width of the contents in pixels
  2794     "return the width of the contents in pixels
  2788      Redefined to add the size of a space (for the cursor).
  2795      Redefined to add the size of a space (for the cursor).
  3190 ! !
  3197 ! !
  3191 
  3198 
  3192 !EditTextView class methodsFor:'documentation'!
  3199 !EditTextView class methodsFor:'documentation'!
  3193 
  3200 
  3194 version
  3201 version
  3195     ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.43 1996-02-07 17:42:12 cg Exp $'
  3202     ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.44 1996-02-07 18:32:04 cg Exp $'
  3196 ! !
  3203 ! !