author | Claus Gittinger <cg@exept.de> |
Tue, 14 Sep 2004 11:55:41 +0200 | |
changeset 3020 | 68a2dfad4e5e |
parent 2999 | 40d3a383e8db |
child 3023 | 9a6809da7351 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
2357 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
14 |
|
0 | 15 |
TextView subclass:#EditTextView |
2724 | 16 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
17 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
18 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
2952 | 19 |
cursorTypeNoFocus typeOfSelection lastString lastReplacement |
20 |
lastAction replacing showMatchingParenthesis hasKeyboardFocus |
|
21 |
acceptAction lockUpdates tabMeansNextField autoIndent insertMode |
|
22 |
trimBlankLines wordWrap replacementWordSelectStyle acceptChannel |
|
23 |
acceptEnabled st80Mode disableIfInvisible |
|
24 |
cursorMovementWhenUpdating learnMode learnedMacro |
|
25 |
cursorLineHolder cursorColHolder dropTarget tabRequiresControl |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
26 |
undoSupport' |
2724 | 27 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
28 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
29 |
DefaultCursorTypeNoFocus' |
|
30 |
poolDictionaries:'' |
|
31 |
category:'Views-Text' |
|
0 | 32 |
! |
33 |
||
2952 | 34 |
Object subclass:#EditAction |
35 |
instanceVariableNames:'' |
|
36 |
classVariableNames:'' |
|
37 |
poolDictionaries:'' |
|
38 |
privateIn:EditTextView |
|
39 |
! |
|
40 |
||
41 |
EditTextView::EditAction subclass:#DeleteRange |
|
42 |
instanceVariableNames:'line1 col1 line2 col2' |
|
43 |
classVariableNames:'' |
|
44 |
poolDictionaries:'' |
|
45 |
privateIn:EditTextView |
|
46 |
! |
|
47 |
||
48 |
EditTextView::EditAction subclass:#InsertCharacter |
|
49 |
instanceVariableNames:'line col character' |
|
50 |
classVariableNames:'' |
|
51 |
poolDictionaries:'' |
|
52 |
privateIn:EditTextView |
|
53 |
! |
|
54 |
||
55 |
EditTextView::EditAction subclass:#PasteString |
|
56 |
instanceVariableNames:'line col string selected' |
|
57 |
classVariableNames:'' |
|
58 |
poolDictionaries:'' |
|
59 |
privateIn:EditTextView |
|
60 |
! |
|
61 |
||
62 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
63 |
instanceVariableNames:'line col character' |
|
64 |
classVariableNames:'' |
|
65 |
poolDictionaries:'' |
|
66 |
privateIn:EditTextView |
|
67 |
! |
|
68 |
||
865 | 69 |
!EditTextView class methodsFor:'documentation'! |
0 | 70 |
|
33 | 71 |
copyright |
72 |
" |
|
73 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
2357 | 74 |
All Rights Reserved |
33 | 75 |
|
76 |
This software is furnished under a license and may be used |
|
77 |
only in accordance with the terms of that license and with the |
|
78 |
inclusion of the above copyright notice. This software may not |
|
79 |
be provided or otherwise made available to, or used by, any |
|
80 |
other person. No title to or ownership of the software is |
|
81 |
hereby transferred. |
|
82 |
" |
|
83 |
! |
|
84 |
||
0 | 85 |
documentation |
86 |
" |
|
87 |
a view for editable text - adds editing functionality to TextView |
|
125 | 88 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
89 |
acceptAction to be performed for accept |
125 | 90 |
|
91 |
If used with a model, this is informed by sending it a changeMsg with |
|
92 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
93 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 94 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
95 |
Please read the historic notice in the ListView class. |
0 | 96 |
|
586 | 97 |
[Instance variables:] |
0 | 98 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
99 |
cursorLine <Number> line where cursor sits (1..) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
100 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
101 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
102 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
103 |
cursorCol <Number> col where cursor sits (1..) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
104 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
105 |
cursorShown <Boolean> true, if cursor is currently shown |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
106 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
107 |
readOnly <Boolean> true, if text may not be edited |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
108 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
109 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
110 |
cleared on accept. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
111 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
112 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
113 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
114 |
fixedSize <Boolean> true, if no lines may be added/removed |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
115 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
116 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
117 |
if it returns true, the modification will be done anyway. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
118 |
if it returns anything else, the modification is not done. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
119 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
120 |
cursorFgColor <Color> color used for cursor drawing |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
121 |
cursorBgColor <Color> color used for cursor drawing |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
122 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
123 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
124 |
are #block (solid-block cursor), #ibeam |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
125 |
(vertical bar at insertion point) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
126 |
and #caret (caret below insertion-point) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
127 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
128 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
129 |
nil means: hide the cursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
130 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
131 |
undoAction <Block> block which undoes last cut, paste or replace |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
132 |
(not yet fully implemented) |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
133 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
134 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
135 |
this affects the next keyPress: if #paste it does not |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
136 |
replace; otherwise it replaces the selection. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
137 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
138 |
lastCut <String> last cut or replaced string |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
139 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
140 |
lastReplacement <String> last replacement |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
141 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
142 |
replacing <Boolean> true if entered characters replace last selection |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
143 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
144 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
145 |
when entering one; this is the default. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
146 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
147 |
hasKeyboardFocus <Boolean> true if this view has the focus |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
148 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
149 |
acceptAction <Block> accept action - evaluated passing the contents as |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
150 |
argument |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
151 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
152 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
153 |
focus to the next field. For editTextViews, this is false |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
154 |
by default (i.e. tabs can be entered into the text). |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
155 |
For some subclasses (inputFields), this may be true. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
156 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
157 |
trimBlankLines <Boolean> if true, trailing blanks are |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
158 |
removed when editing. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
159 |
Default is true. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
160 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
161 |
wordWrap <Boolean> Currently not used. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
162 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
163 |
lockUpdates <Boolean> internal, private |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
164 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
165 |
prevCursorState <Boolean> temporary, private |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
166 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
167 |
cursorMovementWhenUpdating |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
168 |
<Symbol> defines where the cursor is to be positioned if the |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
169 |
model changes its value by some outside activity |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
170 |
(i.e. not by user input into the field). |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
171 |
Can be one of: |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
172 |
#keep / nil -> stay where it was |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
173 |
#endOfText -> cursor to the end |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
174 |
#endOfLine -> stay in the line, but move to end |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
175 |
#beginOfText -> cursor to the beginning |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
176 |
#beginOfLine -> stay in the line, but move to begin |
2131 | 177 |
The default is #beginOfText |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
178 |
|
33 | 179 |
|
2589 | 180 |
|
181 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
182 |
||
183 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
184 |
userPreference values: |
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
185 |
userPreferences.st80EditMode |
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
186 |
<Boolean> if true, cursor positioning is |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
187 |
done as in vi or ST80; i.e. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
188 |
wysiwyg mode is somewhat relaxed, |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
189 |
in that the cursor cannot be |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
190 |
positioned behind a lines end. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
191 |
This is not yet completely implemented. |
33 | 192 |
used globals: |
193 |
||
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
194 |
DeleteHistory <Text> last 1000 lines of deleted text |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
195 |
(but only if this variable exists already) |
586 | 196 |
|
197 |
[styleSheet parameters:] |
|
121 | 198 |
|
2589 | 199 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
200 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
201 |
textCursorNoFocusForegroundColor |
2589 | 202 |
<Color> cursor fg color if no focus; default: cursor fg color |
203 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 204 |
|
205 |
[author:] |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
206 |
Claus Gittinger |
586 | 207 |
|
208 |
[see also:] |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
209 |
CodeView Workspace TextView ListView |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
210 |
EditField |
0 | 211 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
212 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
213 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
214 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
215 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
216 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
217 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
218 |
basic setup: |
2357 | 219 |
[exBegin] |
220 |
|top textView| |
|
221 |
||
222 |
top := StandardSystemView new. |
|
223 |
top extent:300@200. |
|
224 |
||
225 |
textView := EditTextView new. |
|
226 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
227 |
top addSubView:textView. |
|
228 |
||
229 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
230 |
||
231 |
top open. |
|
232 |
[exEnd] |
|
594 | 233 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
234 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
235 |
with vertical scrollbar: |
2357 | 236 |
[exBegin] |
237 |
|top scrollView textView| |
|
238 |
||
239 |
top := StandardSystemView new. |
|
240 |
top extent:300@200. |
|
241 |
||
242 |
scrollView := ScrollableView for:EditTextView. |
|
243 |
textView := scrollView scrolledView. |
|
244 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
245 |
top addSubView:scrollView. |
|
246 |
||
247 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
248 |
||
249 |
top open. |
|
250 |
[exEnd] |
|
594 | 251 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
252 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
253 |
with horizontal & vertical scrollbars: |
2357 | 254 |
[exBegin] |
255 |
|top scrollView textView| |
|
256 |
||
257 |
top := StandardSystemView new. |
|
258 |
top extent:300@200. |
|
259 |
||
260 |
scrollView := HVScrollableView for:EditTextView. |
|
261 |
textView := scrollView scrolledView. |
|
262 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
263 |
top addSubView:scrollView. |
|
264 |
||
265 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
266 |
||
267 |
top open. |
|
268 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
269 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
270 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
271 |
set the action for accept: |
2357 | 272 |
[exBegin] |
273 |
|top textView| |
|
274 |
||
275 |
top := StandardSystemView new. |
|
276 |
top extent:300@200. |
|
277 |
||
278 |
textView := EditTextView new. |
|
279 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
280 |
top addSubView:textView. |
|
281 |
||
282 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
283 |
textView acceptAction:[:contents | |
|
284 |
Transcript showCR:'will not overwrite the file with:'. |
|
285 |
Transcript showCR:contents asString |
|
286 |
]. |
|
287 |
top open. |
|
288 |
[exEnd] |
|
594 | 289 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
292 |
non-string (text) items: |
2357 | 293 |
[exBegin] |
294 |
|top textView list| |
|
295 |
||
296 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
297 |
1 to:list size by:2 do:[:nr | |
|
298 |
list at:nr put:(Text string:(list at:nr) |
|
299 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
300 |
]. |
|
301 |
||
302 |
top := StandardSystemView new. |
|
303 |
top extent:300@200. |
|
304 |
||
305 |
textView := EditTextView new. |
|
306 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
307 |
top addSubView:textView. |
|
308 |
||
309 |
textView contents:list. |
|
310 |
top open. |
|
311 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
312 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
313 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
314 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
315 |
MVC operation: |
594 | 316 |
(the examples model here is a plug simulating a real model; |
317 |
real world applications would not use a plug ..) |
|
2357 | 318 |
[exBegin] |
319 |
|top textView model| |
|
320 |
||
321 |
model := Plug new. |
|
322 |
model respondTo:#accepted: |
|
323 |
with:[:newContents | |
|
324 |
Transcript showCR:'will not overwrite the file with:'. |
|
325 |
Transcript showCR:newContents asString |
|
326 |
]. |
|
327 |
model respondTo:#getList |
|
328 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
329 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
330 |
|
2357 | 331 |
top := StandardSystemView new. |
332 |
top extent:300@200. |
|
333 |
||
334 |
textView := EditTextView new. |
|
335 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
336 |
top addSubView:textView. |
|
337 |
||
338 |
textView listMessage:#getList; |
|
339 |
model:model; |
|
340 |
changeMessage:#accepted:; |
|
341 |
aspect:#list. |
|
342 |
top open. |
|
343 |
[exEnd] |
|
594 | 344 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
346 |
two textViews on the same model: |
2357 | 347 |
[exBegin] |
348 |
|top1 textView1 top2 textView2 model currentContents| |
|
349 |
||
350 |
model := Plug new. |
|
351 |
model respondTo:#accepted: |
|
352 |
with:[:newContents | |
|
353 |
Transcript showCR:'accepted:'. |
|
354 |
Transcript showCR:newContents asString. |
|
355 |
currentContents := newContents. |
|
356 |
model changed:#contents |
|
357 |
]. |
|
358 |
model respondTo:#getList |
|
359 |
with:[Transcript showCR:'query'. |
|
360 |
currentContents]. |
|
361 |
||
362 |
||
363 |
top1 := StandardSystemView new. |
|
364 |
top1 extent:300@200. |
|
365 |
||
366 |
textView1 := EditTextView new. |
|
367 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
368 |
top1 addSubView:textView1. |
|
369 |
||
370 |
textView1 listMessage:#getList; |
|
371 |
model:model; |
|
372 |
aspect:#contents; |
|
373 |
changeMessage:#accepted:. |
|
374 |
top1 open. |
|
375 |
||
376 |
top2 := StandardSystemView new. |
|
377 |
top2 extent:300@200. |
|
378 |
||
379 |
textView2 := EditTextView new. |
|
380 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
381 |
top2 addSubView:textView2. |
|
382 |
||
383 |
textView2 listMessage:#getList; |
|
384 |
model:model; |
|
385 |
aspect:#contents; |
|
386 |
changeMessage:#accepted:. |
|
387 |
top2 open. |
|
388 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
389 |
" |
0 | 390 |
! ! |
391 |
||
865 | 392 |
!EditTextView class methodsFor:'defaults'! |
59 | 393 |
|
1419 | 394 |
st80Mode |
395 |
"return true, if the st80 editing mode is turned on. |
|
396 |
This setting affects the behavior of the cursor, when positioned |
|
2707 | 397 |
beyond the end of a line or the end of the text. |
1419 | 398 |
The default is initialized from the viewStyle." |
399 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
400 |
^ UserPreferences current st80EditMode |
1419 | 401 |
|
402 |
" |
|
403 |
EditTextView st80Mode:true |
|
404 |
EditTextView st80Mode:false |
|
405 |
" |
|
406 |
||
407 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
408 |
! |
|
409 |
||
410 |
st80Mode:aBoolean |
|
411 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 412 |
beyond the end of a line or the last line" |
1419 | 413 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
414 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 415 |
|
416 |
" |
|
417 |
EditTextView st80Mode:true |
|
418 |
EditTextView st80Mode:false |
|
419 |
" |
|
420 |
||
421 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
422 |
! |
|
423 |
||
59 | 424 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
425 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
426 |
|
1390 | 427 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
2357 | 428 |
#'textCursor.noFocusForegroundColor' |
429 |
#'textCursor.type' #'textCursor.typeNoFocus' |
|
430 |
#'editText.st80Mode')> |
|
1355 | 431 |
|
432 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
433 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
434 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
435 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
436 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
437 |
|
1419 | 438 |
" |
439 |
self updateStyleCache |
|
440 |
" |
|
441 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
442 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 443 |
! ! |
444 |
||
2744 | 445 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
446 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
447 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
448 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
449 |
|
2019 | 450 |
"Created: / 5.6.1998 / 15:30:32 / cg " |
1585
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
451 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
452 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
453 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
454 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
455 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
456 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
457 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
458 |
|
1390 | 459 |
cutSelection |
460 |
self cut |
|
461 |
||
462 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
463 |
! |
|
464 |
||
1590 | 465 |
deselect |
466 |
"remove the selection" |
|
467 |
||
468 |
^ self unselect |
|
469 |
||
470 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
471 |
! |
|
472 |
||
2101 | 473 |
enabled:aBoolean |
474 |
||
475 |
self readOnly:aBoolean not |
|
476 |
||
477 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
478 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
479 |
! |
|
480 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
481 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
482 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
483 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
484 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
485 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
486 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
487 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
488 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
489 |
"insert a string at aCharacterPosition." |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
490 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
491 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
492 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
493 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
494 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
495 |
col < 1 ifTrue:[ |
2357 | 496 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
497 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
498 |
self insertString:aString atLine:line col:col. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
499 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
500 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
501 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
502 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
503 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
504 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
505 |
v := EditTextView origin:0.0@0.0 corner:1.0@1.0 in:top. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
506 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
507 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
508 |
v insert:'<- hello there' at:5. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
509 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
510 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
511 |
"Modified: / 5.4.1998 / 17:20:08 / cg" |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
512 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
513 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
514 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
515 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
516 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
517 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
518 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
519 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 520 |
col := (aCharacterPosition - (self characterPositionOfLine:line col:1) + 1) max:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
521 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
522 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 523 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
524 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
525 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
526 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
527 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
528 |
v insertAndSelect:'<- hello there' at:5. |
125 | 529 |
" |
1390 | 530 |
! |
531 |
||
532 |
pasteSelection |
|
533 |
self paste |
|
534 |
||
535 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 536 |
! |
537 |
||
538 |
replaceSelectionWith:aString |
|
539 |
^ self replaceSelectionBy:aString |
|
540 |
||
541 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
542 |
! |
|
543 |
||
544 |
selectAt:pos |
|
545 |
"move the cursor before cursorPosition." |
|
546 |
||
547 |
self cursorToCharacterPosition:pos |
|
548 |
||
549 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
550 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
551 |
! |
|
552 |
||
553 |
selectFrom:startPos to:endPos |
|
554 |
"change the selection given two aCharacterPositions." |
|
555 |
||
556 |
|line1 col1 line2 col2| |
|
557 |
||
558 |
startPos > endPos ifTrue:[ |
|
2357 | 559 |
^ self unselect |
1590 | 560 |
]. |
561 |
||
562 |
line1 := self lineOfCharacterPosition:startPos. |
|
563 |
col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1. |
|
564 |
col1 < 1 ifTrue:[ |
|
2357 | 565 |
col1 := 1 |
1590 | 566 |
]. |
567 |
line2 := self lineOfCharacterPosition:endPos. |
|
568 |
col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1. |
|
569 |
col2 < 1 ifTrue:[ |
|
2357 | 570 |
col2 := 1 |
1590 | 571 |
]. |
572 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
573 |
||
574 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
2101 | 575 |
! |
576 |
||
577 |
textHasChanged |
|
578 |
^ self modified |
|
579 |
||
580 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
581 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
582 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
583 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
584 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
585 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
586 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
587 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
588 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
589 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
590 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
591 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
592 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
593 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
594 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
595 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
596 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
597 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
598 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
599 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
600 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
601 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
602 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
603 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
604 |
|
2792 | 605 |
acceptChannel |
606 |
"return the valueHolder holding true if text was accepted. |
|
607 |
By placing a true into this channel, an accept can also be forced." |
|
608 |
||
609 |
^ acceptChannel |
|
610 |
||
611 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
612 |
! |
|
613 |
||
614 |
acceptChannel:aValueHolder |
|
615 |
"set the valueHolder holding true if text was accepted. |
|
616 |
By placing a true into this channel, an accept can also be forced." |
|
617 |
||
618 |
|prev| |
|
619 |
||
620 |
prev := acceptChannel. |
|
621 |
acceptChannel := aValueHolder. |
|
622 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
623 |
||
624 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
625 |
! |
|
626 |
||
1108 | 627 |
acceptEnabled:aBoolean |
628 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
629 |
||
630 |
acceptEnabled := aBoolean |
|
631 |
||
632 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
633 |
! |
|
634 |
||
2792 | 635 |
accepted |
636 |
"return true if text was accepted" |
|
637 |
||
638 |
^ acceptChannel value |
|
639 |
||
640 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
641 |
! |
|
642 |
||
643 |
accepted:aBoolean |
|
644 |
"set/clear the accepted flag. |
|
645 |
This may force my current contents to be placed into my model." |
|
646 |
||
647 |
acceptChannel value:aBoolean. |
|
648 |
||
649 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
650 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
651 |
! |
|
652 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
653 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
654 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
655 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
656 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
657 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
658 |
|
2774 | 659 |
cursorMovementWhenUpdating |
660 |
"return what is be done with the cursor, |
|
661 |
when I get a new text (via the model or the #contents/#list) |
|
662 |
Allowed arguments are: |
|
663 |
#keep / nil -> stay where it was |
|
664 |
#endOfText -> position cursor to the end |
|
665 |
#beginOfText -> position cursor to the beginning |
|
666 |
#endOfLine -> position cursor to the current lines end |
|
667 |
#beginOfLine -> position cursor to the current lines start |
|
668 |
The default is #beginOfText. |
|
669 |
This may be useful for fields which get new values assigned from |
|
670 |
the program (i.e. not from the user)" |
|
671 |
||
672 |
^ cursorMovementWhenUpdating |
|
673 |
||
674 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
675 |
! |
|
676 |
||
2133 | 677 |
cursorMovementWhenUpdating:aSymbolOrNil |
678 |
"define what should be done with the cursor, |
|
679 |
when I get a new text (via the model or the #contents/#list) |
|
680 |
Allowed arguments are: |
|
681 |
#keep / nil -> stay where it was |
|
682 |
#endOfText -> position cursor to the end |
|
683 |
#beginOfText -> position cursor to the beginning |
|
684 |
#endOfLine -> position cursor to the current lines end |
|
685 |
#beginOfLine -> position cursor to the current lines start |
|
686 |
The default is #beginOfText. |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
687 |
This may be useful for fields which get new values assigned from |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
688 |
the program (i.e. not from the user)" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
689 |
|
2133 | 690 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
691 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
692 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
693 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
694 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
695 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
696 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
697 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
698 |
|
2438 | 699 |
dontReplaceSelectionOnInput |
700 |
typeOfSelection := #paste |
|
701 |
! |
|
702 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
703 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
704 |
"define the action to be triggered when user tries to modify |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
705 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
706 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
707 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
708 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
709 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
710 |
insertMode:aBoolean |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
711 |
insertMode value:aBoolean |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
712 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
713 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
714 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
715 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
716 |
insertModeHolder |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
717 |
^ insertMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
718 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
719 |
|
2792 | 720 |
isReadOnly |
721 |
"return true, if the text is readonly." |
|
722 |
||
723 |
^ readOnly value |
|
724 |
||
725 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
726 |
! |
|
727 |
||
2796 | 728 |
modeLabelHolder |
729 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
730 |
||
731 |
^ BlockValue |
|
732 |
with:[:i :l | |
|
733 |
l value |
|
734 |
ifTrue:[ |
|
735 |
'L' asText allBold colorizeAllWith:Color red] |
|
736 |
ifFalse:[ |
|
737 |
i value |
|
738 |
ifTrue:[ |
|
739 |
'I'] |
|
740 |
ifFalse:[ |
|
741 |
nil]]] |
|
742 |
argument:(self insertModeHolder) |
|
743 |
argument:(self learnModeHolder). |
|
744 |
! |
|
745 |
||
2792 | 746 |
modified |
747 |
"return true if text was modified" |
|
748 |
||
749 |
^ modifiedChannel value |
|
750 |
! |
|
751 |
||
752 |
modified:aBoolean |
|
753 |
"set/clear the modified flag" |
|
754 |
||
755 |
modifiedChannel value:aBoolean |
|
756 |
||
757 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
758 |
! |
|
759 |
||
760 |
modifiedChannel |
|
761 |
"return the valueHolder holding true if text was modified" |
|
762 |
||
763 |
^ modifiedChannel |
|
764 |
! |
|
765 |
||
766 |
modifiedChannel:aValueHolder |
|
767 |
"set the valueHolder holding true if text was modified" |
|
768 |
||
769 |
|prev| |
|
770 |
||
771 |
prev := modifiedChannel. |
|
772 |
modifiedChannel := aValueHolder. |
|
773 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
774 |
||
775 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
776 |
! |
|
777 |
||
778 |
readOnly |
|
779 |
"make the text readonly. |
|
780 |
Somewhat obsolete - use #readOnly:" |
|
781 |
||
782 |
<resource:#obsolete> |
|
783 |
||
784 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
785 |
readOnly := true |
|
786 |
||
787 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
788 |
! |
|
789 |
||
790 |
readOnly:aBoolean |
|
791 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
792 |
The argument may also be a valueHolder." |
|
793 |
||
794 |
readOnly := aBoolean |
|
795 |
||
796 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
797 |
! |
|
798 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
799 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
800 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
801 |
If true, Tab is ignored and shifts the keyboard focus. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
802 |
If false, tabs can be entered into the text. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
803 |
The default is true for editTextView, false for single-line |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
804 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
805 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
806 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
807 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
808 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
809 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
810 |
"returns true, if a focus tabbing requires a control-key to be pressed. |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
811 |
The default is true for editTextView, false for other widgets, |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
812 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
813 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
814 |
^ tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
815 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
816 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
817 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
818 |
"controls if a focus tabbing requires a control-key to be pressed. |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
819 |
The default is true for editTextView, false for other widgets, |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
820 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
821 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
822 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
823 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
824 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
825 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
826 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
827 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
828 |
"change a line without change notification" |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
829 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
830 |
(self at:lineNr) = aLine ifFalse:[ |
2357 | 831 |
super at:lineNr put:aLine. |
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
832 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
833 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
834 |
|
522 | 835 |
at:lineNr put:aLine |
836 |
(self at:lineNr) = aLine ifFalse:[ |
|
2357 | 837 |
super at:lineNr put:aLine. |
838 |
self textChanged |
|
522 | 839 |
]. |
840 |
! |
|
841 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
842 |
characterBeforeCursor |
2707 | 843 |
"return the character under the cursor - space if beyond line. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
844 |
For non-block cursors, this is the character immediately to the right |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
845 |
of the insertion-bar or caret." |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
846 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
847 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
848 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
849 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
850 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
851 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
852 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
853 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
854 |
characterUnderCursor |
2707 | 855 |
"return the character under the cursor - space if beyond line. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
856 |
For non-block cursors, this is the character immediately to the right |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
857 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
859 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
860 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
861 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
862 |
contents |
2213 | 863 |
"return the contents as a String or Text (i.e. with emphasis)" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
864 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
865 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
866 |
self removeTrailingBlankLines. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
867 |
^ list asStringWithCRs |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
868 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
869 |
|
2213 | 870 |
contentsAsString |
871 |
"return the contents as a String (i.e. without emphasis)" |
|
872 |
||
873 |
list isNil ifTrue:[^ '']. |
|
874 |
self removeTrailingBlankLines. |
|
875 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
876 |
ifFalse:[each string] |
|
877 |
]) asStringWithCRs |
|
878 |
! |
|
879 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
880 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
881 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
882 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
883 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
884 |
^ cursorCol |
125 | 885 |
! |
886 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
887 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
888 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
889 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
890 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
891 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
892 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
893 |
cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
894 |
"return the cursors line (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
895 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
896 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
897 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
898 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
899 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
900 |
cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
901 |
"return a valueHolder for the cursors line (1..). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
902 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
903 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
904 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
905 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
906 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
907 |
fixedSize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
908 |
"make the texts size fixed (no lines may be added). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
909 |
OBSOLETE: use readOnly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
910 |
|
2363 | 911 |
<resource:#obsolete> |
912 |
||
1018 | 913 |
self obsoleteMethodWarning:'use #readOnly:'. |
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
914 |
readOnly == true ifFalse:[ |
2357 | 915 |
readOnly := true. |
916 |
middleButtonMenu notNil ifTrue:[ |
|
917 |
middleButtonMenu disableAll:#(cut paste replace indent) |
|
918 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
919 |
] |
1018 | 920 |
|
921 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
|
127 | 922 |
! |
923 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
924 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
925 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
926 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
927 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
928 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
929 |
undoSupport resetHistories. |
2955 | 930 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
931 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
932 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
933 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
934 |
super list:something. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
935 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
936 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
937 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
938 |
^ self cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
939 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
940 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
941 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
942 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
943 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
944 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
945 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
946 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
947 |
^ self cursorHome |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
948 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
949 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
950 |
^ self cursorLine:prevCursorLine col:1. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
951 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
952 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
953 |
"/ default: stay where it was |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
954 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
956 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
957 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
958 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
959 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
960 |
undoSupport resetHistories. |
2955 | 961 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
962 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
963 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
964 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
965 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
966 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
967 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
968 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
969 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
970 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
971 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
972 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
973 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
974 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
975 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
976 |
wasOn := self hideCursor. |
1993 | 977 |
cursorFgColor := color1 onDevice:device. |
978 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
979 |
wasOn ifTrue:[self showCursor] |
1333 | 980 |
! |
981 |
||
1899 | 982 |
cursorType |
983 |
"return the style of the text cursor. |
|
984 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
2357 | 985 |
#bigCaret and #bigSolidCaret" |
1899 | 986 |
|
987 |
^ cursorType |
|
988 |
||
989 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
990 |
! |
|
991 |
||
1333 | 992 |
cursorType:aCursorTypeSymbol |
993 |
"set the style of the text cursor. |
|
994 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
2357 | 995 |
#bigCaret and #bigSolidCaret" |
1333 | 996 |
|
1334 | 997 |
cursorType := aCursorTypeSymbol. |
1333 | 998 |
|
999 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1000 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1001 |
! |
1002 |
||
1899 | 1003 |
cursorTypeNoFocus |
1004 |
"return the style of the text cursor when the view has no focus. |
|
1005 |
If left unspecified, this is the same as the regular cursorType." |
|
1006 |
||
1007 |
^ cursorTypeNoFocus |
|
1008 |
||
1009 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1010 |
! |
|
1011 |
||
1334 | 1012 |
cursorTypeNoFocus:aCursorTypeSymbol |
1013 |
"set the style of the text cursor when the view has no focus. |
|
1014 |
If left unspecified, this is the same as the regular cursorType." |
|
1015 |
||
1016 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1017 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1018 |
|
2119 | 1019 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1020 |
|
125 | 1021 |
accept |
1022 |
"accept the current contents by executing the accept-action and/or |
|
1023 |
changeMessage." |
|
1024 |
||
1108 | 1025 |
acceptEnabled == false ifTrue:[ |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1026 |
device beep. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1027 |
^ self |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1028 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1029 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1030 |
^ self |
1108 | 1031 |
]. |
1032 |
||
125 | 1033 |
lockUpdates := true. |
1013 | 1034 |
|
1035 |
"/ |
|
1036 |
"/ ST-80 way of doing it |
|
1037 |
"/ |
|
1038 |
model notNil ifTrue:[ |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1039 |
self sendChangeMessageWith:self argForChangeMessage. |
1013 | 1040 |
]. |
1041 |
||
2999 | 1042 |
model notNil ifTrue:[ |
1043 |
acceptChannel value:true withoutNotifying:self. |
|
1044 |
]. |
|
1045 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1046 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1047 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1048 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1049 |
"/ the block is called with a stringCollection |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1050 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1051 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1052 |
acceptAction notNil ifTrue:[ |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1053 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1054 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1055 |
|
125 | 1056 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1057 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1058 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1059 |
! |
1060 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1061 |
argForChangeMessage |
597 | 1062 |
"return the argument to be passed with the change notification. |
1063 |
Defined as separate method for easier subclassability." |
|
1064 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1065 |
^ self contents |
597 | 1066 |
|
1067 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1068 |
! |
1069 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1070 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1071 |
"get my contents from the model. |
597 | 1072 |
Redefined to ignore updates resulting from my own changes |
1073 |
(i.e. if lockUpdates is true)." |
|
121 | 1074 |
|
1075 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1076 |
ignore updates from my own change |
121 | 1077 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1078 |
lockUpdates ifTrue:[ |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1079 |
lockUpdates := false. |
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1080 |
^ self |
121 | 1081 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1082 |
super getListFromModel. |
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1083 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1084 |
"/ validate the cursorLine |
2310 | 1085 |
(cursorLine notNil |
1086 |
and:[ cursorLine > list size ]) ifTrue:[ |
|
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1087 |
self cursorLine:list size + 1 col:1 |
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1088 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1089 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1090 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1091 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1092 |
changedObject == acceptChannel ifTrue:[ |
2357 | 1093 |
acceptChannel value == true ifTrue:[ |
1094 |
self accept. |
|
1095 |
]. |
|
1096 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1097 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1098 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1099 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1100 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1101 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1102 |
! ! |
1103 |
||
1104 |
!EditTextView methodsFor:'cursor handling'! |
|
1105 |
||
2406 | 1106 |
characterPositionOfCursor |
1107 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1108 |
! |
|
1109 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1110 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1111 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1112 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1113 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1114 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1116 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1117 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1118 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1119 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1120 |
|
2822 | 1121 |
(cursorCol == newCol) ifTrue:[^ self]. |
1122 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1123 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1124 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1125 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1126 |
|
1127 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1128 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1130 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1131 |
"move cursor down; scroll if at end of visible text; |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1132 |
beep if at end of physical text." |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1133 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1134 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1135 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1136 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1137 |
|
2707 | 1138 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1139 |
cursorLine > list size ifTrue:[ |
2357 | 1140 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1141 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
2357 | 1142 |
self makeCursorVisibleAndShowCursor:wasOn. |
1143 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1144 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1145 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1146 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1147 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1148 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1149 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1150 |
"move cursor down by n lines; scroll if at end of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1151 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1152 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1153 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1154 |
cursorVisibleLine notNil ifTrue:[ |
2357 | 1155 |
wasOn := self hideCursor. |
1156 |
nv := cursorVisibleLine + n - 1. |
|
1157 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1158 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1159 |
]. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1160 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
2357 | 1161 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1162 |
] ifFalse:[ |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1163 |
(nL := cursorLine) isNil ifTrue:[ |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1164 |
nL := firstLineShown |
2357 | 1165 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1166 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
2357 | 1167 |
self makeCursorVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1168 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1169 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1170 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1171 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1172 |
|
121 | 1173 |
cursorHome |
597 | 1174 |
"scroll to top AND move cursor to first line of text." |
121 | 1175 |
|
674 | 1176 |
self cursorLine:1 col:1 |
1177 |
||
1178 |
"/ |wasOn| |
|
1179 |
"/ |
|
1180 |
"/ wasOn := self hideCursor. |
|
1181 |
"/ self scrollToTop. |
|
1182 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1183 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1184 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1185 |
||
1186 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1187 |
! |
1188 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1189 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1190 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1191 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1192 |
(cursorCol ~~ 1) ifTrue:[ |
2357 | 1193 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1194 |
] ifFalse:[ |
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1195 |
"/ no, do not wrap back to previous line |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1196 |
"/ cursorLine ~~ 1 ifTrue:[ |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1197 |
"/ self st80Mode == true ifTrue:[ |
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1198 |
"/ self cursorUp. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1199 |
"/ self cursorToEndOfLine. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1200 |
"/ ] |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1201 |
"/ ] |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1202 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1203 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1204 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1205 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1206 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1207 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1208 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1209 |
|
676 | 1210 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1211 |
|
2822 | 1212 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1213 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1214 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1215 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1216 |
|
672 | 1217 |
(col < 1) ifTrue:[ |
2357 | 1218 |
newCol := 1 |
672 | 1219 |
] ifFalse:[ |
2357 | 1220 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1221 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1222 |
self st80EditMode ifTrue:[ |
2357 | 1223 |
(cursorLine == list size |
1224 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1225 |
newCol := (self listAt:(list size)) size + 1. |
|
1226 |
] |
|
1419 | 1227 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1228 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1229 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1230 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1231 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1232 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1233 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1234 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1235 |
"return true, if the user may move the cursor around |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1236 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1237 |
By default, true is returned, but this may be redefined |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1238 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1239 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1240 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1241 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1242 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1243 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1244 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1245 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1246 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1247 |
"move cursor to start of next line; scroll if at end of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1248 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1249 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1250 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1251 |
self checkForExistingLine:(cursorLine + 1). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1252 |
cursorVisibleLine notNil ifTrue:[ |
2357 | 1253 |
nFullLinesShown notNil ifTrue:[ |
1254 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1255 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1256 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1257 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1258 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1259 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1260 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1261 |
|
674 | 1262 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1263 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1264 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1265 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1266 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1267 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1268 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1269 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1270 |
self st80EditMode == true ifTrue:[ |
2357 | 1271 |
l := (self listAt:cursorLine). |
1272 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1273 |
"/ no, do not wrap to next line |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1274 |
"/ cursorLine < list size ifTrue:[ |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1275 |
"/ self cursorReturn. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1276 |
"/ ]. |
2357 | 1277 |
^ self |
1278 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1279 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1280 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1281 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1282 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1283 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1284 |
|
1833 | 1285 |
cursorShown:aBoolean |
1286 |
"change cursor visibility |
|
1287 |
return true if cursor was visible before." |
|
1288 |
||
1289 |
|oldState| |
|
1290 |
||
1291 |
oldState := cursorShown. |
|
1292 |
||
1293 |
aBoolean ifTrue:[ |
|
2357 | 1294 |
self drawCursor. |
1833 | 1295 |
] ifFalse:[ |
2357 | 1296 |
(cursorShown and:[shown]) ifTrue: [ |
1297 |
self undrawCursor. |
|
1298 |
]. |
|
1833 | 1299 |
]. |
1300 |
cursorShown := aBoolean. |
|
1301 |
||
1302 |
^ oldState |
|
1303 |
||
1304 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1305 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1306 |
! |
|
1307 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1308 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1309 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1310 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1311 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1312 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1313 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1314 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1315 |
"move cursor to the start of the current line" |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1316 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1317 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1318 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1319 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1320 |
textStart := l isNil ifTrue:[1] ifFalse:[l indexOfNonSeparator]. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1321 |
cursorCol > textStart ifTrue:[ |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1322 |
self cursorCol:textStart |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1323 |
] ifFalse:[ |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1324 |
self cursorCol:1 |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1325 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1326 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1327 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1328 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1329 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1330 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1331 |
"move cursor to the last line of text (col 1)" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1332 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1333 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1334 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1335 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1336 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1337 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1338 |
(newTop < 1) ifTrue:[ |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1339 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1340 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1341 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1342 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1343 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1345 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1346 |
|
674 | 1347 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1348 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1349 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1350 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1351 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1352 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1353 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1354 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1355 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1356 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1357 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1358 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1359 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1360 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1361 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1362 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1363 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1364 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1365 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1366 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1367 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1368 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1369 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1370 |
cursorLine >= lineNr ifTrue:[ |
2357 | 1371 |
line := self listAt:cursorLine. |
1372 |
(line isNil or:[line isEmpty]) ifTrue:[ |
|
1373 |
^ self |
|
1374 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1375 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1376 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1377 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1378 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1379 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1380 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1381 |
(newTop < 1) ifTrue:[ |
2357 | 1382 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1383 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1384 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1385 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1386 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1387 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1388 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1389 |
|
674 | 1390 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1391 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1392 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1393 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1394 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1395 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1396 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1397 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1398 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1399 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1400 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1401 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1402 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1403 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1404 |
cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1405 |
"move cursor to the end of the text (behinf last character in last line)" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1406 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1407 |
|wasOn newTop| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1408 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1409 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1410 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1411 |
newTop := list size - nFullLinesShown. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1412 |
(newTop < 1) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1413 |
newTop := 1 |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1414 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1415 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1416 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1417 |
self setValidatedCursorLine:list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1418 |
self setCursorCol:(self validateCursorCol:(self listAt:cursorLine) size inLine:cursorLine). |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1419 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1420 |
self makeCursorVisibleAndShowCursor:wasOn. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1421 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1422 |
|
131 | 1423 |
cursorToFirstVisibleLine |
1424 |
"place cursor into the first visible line; do not scroll." |
|
1425 |
||
1426 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1427 |
! |
|
1428 |
||
1429 |
cursorToLastVisibleLine |
|
1430 |
"place cursor into the first visible line; do not scroll." |
|
1431 |
||
1432 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1433 |
! |
|
1434 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1435 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1436 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1437 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1438 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1439 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1440 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1441 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
self wordAtLine:cursorLine col:cursorCol do:[ |
2357 | 1443 |
:beginLine :beginCol :endLine :endCol :style | |
1444 |
||
1445 |
line := endLine. |
|
1446 |
col := endCol + 1. |
|
1447 |
searching := true. |
|
1448 |
[searching |
|
1449 |
and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
1450 |
self wordAtLine:line col:col do:[ |
|
1451 |
:beginLine :beginCol :endLine :endCol :style | |
|
1452 |
||
1453 |
(line > list size) ifTrue:[ |
|
1454 |
"break out" |
|
1455 |
searching := false |
|
1456 |
] ifFalse:[ |
|
1457 |
line := endLine. |
|
1458 |
col := endCol + 1. |
|
1459 |
] |
|
1460 |
] |
|
1461 |
]. |
|
1462 |
self cursorLine:line col:col |
|
121 | 1463 |
] |
1464 |
! |
|
1465 |
||
499 | 1466 |
cursorToPreviousWord |
1467 |
"move the cursor to the beginning of this or the previous word" |
|
1468 |
||
1469 |
|col line searching l| |
|
1470 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1471 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1472 |
|
1473 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
2357 | 1474 |
:beginLine :beginCol :endLine :endCol :style | |
1475 |
||
1476 |
line := beginLine. |
|
1477 |
col := beginCol. |
|
1478 |
style == #wordLeft ifTrue:[ |
|
1479 |
col := col + 1 |
|
1480 |
]. |
|
1481 |
||
1482 |
(cursorLine == line |
|
1483 |
and:[cursorCol == col]) ifTrue:[ |
|
1484 |
searching := true. |
|
1485 |
||
1486 |
col > 1 ifTrue:[ |
|
1487 |
col := col - 1. |
|
1488 |
]. |
|
1489 |
||
1490 |
[searching] whileTrue:[ |
|
1491 |
(col == 1) ifTrue:[ |
|
1492 |
line == 1 ifTrue:[ |
|
1493 |
searching := false |
|
1494 |
] ifFalse:[ |
|
1495 |
line := line - 1. |
|
1496 |
l := list at:line. |
|
1497 |
col := l size + 1. |
|
1498 |
] |
|
1499 |
] ifFalse:[ |
|
1500 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
1501 |
self wordAtLine:line col:col do:[ |
|
1502 |
:beginLine :beginCol :endLine :endCol :style | |
|
1503 |
||
1504 |
line := beginLine. |
|
1505 |
col := beginCol. |
|
1506 |
style == #wordLeft ifTrue:[ |
|
1507 |
col := col + 1 |
|
1508 |
]. |
|
1509 |
searching := false. |
|
1510 |
] |
|
1511 |
] ifTrue:[ |
|
1512 |
col := col - 1 |
|
1513 |
] |
|
1514 |
] |
|
1515 |
] |
|
1516 |
]. |
|
1517 |
self cursorLine:line col:col |
|
499 | 1518 |
] |
1519 |
||
1520 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
1521 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
1522 |
! |
|
1523 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1524 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1525 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1526 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1527 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1528 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1529 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1530 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1531 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1533 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1534 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1535 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1536 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1537 |
"move cursor up n lines; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1539 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1540 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1541 |
cursorLine isNil ifTrue:[ |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1542 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1543 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1544 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1545 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1547 |
(nl ~~ cursorLine) ifTrue: [ |
2357 | 1548 |
wasOn := self hideCursor. |
1549 |
cursorVisibleLine notNil ifTrue:[ |
|
1550 |
nv := cursorVisibleLine - n. |
|
1551 |
nv < 1 ifTrue:[ |
|
1552 |
self scrollUp:(nv negated + 1) |
|
1553 |
]. |
|
1554 |
]. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1555 |
self setValidatedCursorLine:nl col:cursorCol. |
2357 | 1556 |
wasOn ifTrue:[self showCursor]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1557 |
] |
672 | 1558 |
|
674 | 1559 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1560 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1561 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1562 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1563 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1564 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1565 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1567 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1568 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1569 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1570 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1571 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1572 |
|
676 | 1573 |
newCol := colNr. |
1574 |
(newCol < 1) ifTrue:[ |
|
2357 | 1575 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1576 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1577 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1578 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1579 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1580 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
1581 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1582 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1583 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1584 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1585 |
"put cursor to position next to x/y coordinate in view" |
121 | 1586 |
|
1587 |
|line col| |
|
1588 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1589 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1590 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1591 |
self cursorVisibleLine:line col:col. |
121 | 1592 |
! |
1593 |
||
1594 |
drawCursor |
|
1595 |
"draw the cursor if shown and cursor is visible. |
|
1596 |
(but not, if there is a selection - to avoid confusion)" |
|
1597 |
||
1598 |
shown ifTrue:[ |
|
2357 | 1599 |
cursorVisibleLine notNil ifTrue:[ |
1600 |
self hasSelection ifFalse:[ |
|
1601 |
self drawCursorCharacter |
|
1602 |
] |
|
1603 |
] |
|
121 | 1604 |
] |
1605 |
! |
|
1606 |
||
1607 |
drawCursor:cursorType with:fgColor and:bgColor |
|
1608 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 1609 |
of cursor should be drawn. |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1610 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1611 |
#bigCaret and #bigSolidCaret" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1612 |
|
2570 | 1613 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 1614 |
|
1615 |
self hasSelection ifTrue:[ |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1616 |
" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1617 |
hide cursor, if there is a selection |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1618 |
" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1619 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 1620 |
]. |
1621 |
||
1334 | 1622 |
cursorType == #none ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1623 |
^ self |
1334 | 1624 |
]. |
1625 |
||
121 | 1626 |
cursorType == #block ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1627 |
super drawVisibleLine:cursorVisibleLine |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1628 |
col:cursorCol |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1629 |
with:fgColor |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1630 |
and:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1631 |
^ self |
121 | 1632 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1633 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 1634 |
y := self yOfVisibleLine:cursorVisibleLine. |
1635 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
1636 |
oldPaint := self paint. "/ do not clobber GC |
121 | 1637 |
cursorType == #frame ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1638 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1639 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1640 |
char := self characterUnderCursor asString. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1641 |
self paint:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1642 |
self displayRectangleX:x y:y |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1643 |
width:(font widthOf:char) height:fontHeight. |
133 | 1644 |
] ifFalse:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1645 |
self paint:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1646 |
cursorType == #ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1647 |
x1 := x - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1648 |
y2 := y + fontHeight - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1649 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1650 |
self displayLineFromX:x y:y toX:x y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1651 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1652 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1653 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1654 |
cursorType == #Ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1655 |
x1 := x - 1. |
2088 | 1656 |
y := y + 1. |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1657 |
y2 := y + fontHeight - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1658 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1659 |
self displayLineFromX:x y:y toX:x y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1660 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1661 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1662 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1663 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1664 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1665 |
y := y + fontHeight - 3. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1666 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1667 |
w := (fontWidth * 2 // 3) max:4. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1668 |
y2 := y + w + (w//2). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1669 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1670 |
w := (fontWidth // 2) max:4. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1671 |
y2 := y + w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1672 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1673 |
x1 := x - w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1674 |
x2 := x + w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1675 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1676 |
oldClip := self clippingRectangleOrNil. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1677 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1678 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1679 |
cursorType == #caret ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1680 |
self lineWidth:2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1681 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1682 |
self displayLineFromX:x y:y toX:x2 y:y2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1683 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1684 |
"anything else: solidCaret" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1685 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1686 |
self fillPolygon:(Array with:(x1 @ y2) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1687 |
with:(x @ y) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1688 |
with:(x2 @ y2)) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1689 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1690 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1691 |
self clippingRectangle:oldClip |
121 | 1692 |
]. |
133 | 1693 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
1694 |
|
2088 | 1695 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 1696 |
! |
1697 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1698 |
drawCursorCharacter |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1699 |
"draw the cursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1700 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1701 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1702 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1703 |
(hasKeyboardFocus |
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1704 |
and:[self enabled |
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1705 |
and:[readOnly not]]) ifTrue:[ |
2357 | 1706 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1707 |
] ifFalse:[ |
2357 | 1708 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1709 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1710 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1711 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1712 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1713 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1714 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1715 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1716 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1717 |
self hasSelection ifTrue:[ |
2357 | 1718 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 1719 |
]. |
1720 |
cursorType == #none ifTrue:[ |
|
2357 | 1721 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1722 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1723 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 1724 |
|
1725 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1726 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1727 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1728 |
drawNoFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1729 |
"draw the cursor for the case when the view has no keyboard focus" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1730 |
|
1334 | 1731 |
|cType| |
1732 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1733 |
self hasSelection ifTrue:[ |
2357 | 1734 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 1735 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1736 |
|
1334 | 1737 |
cType := cursorTypeNoFocus ? cursorType. |
1738 |
cType == #none ifTrue:[ |
|
2357 | 1739 |
^ self undrawCursor |
1334 | 1740 |
]. |
1741 |
||
1742 |
cType == #block ifTrue:[ |
|
2357 | 1743 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1744 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1745 |
|
1334 | 1746 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
1747 |
||
1748 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1749 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1751 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1752 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1753 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1754 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1755 |
self makeLineVisible:aLineNumber. |
2951 | 1756 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1757 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1758 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1759 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1760 |
hideCursor |
1833 | 1761 |
"make cursor invisible if currently invisible" |
1762 |
||
1763 |
^ self cursorShown:false |
|
1764 |
||
1765 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 1766 |
! |
1767 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1768 |
makeCursorVisible |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
"scroll text to make cursorline visible |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1770 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1771 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1772 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1773 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1774 |
cursorLine notNil ifTrue:[ |
2357 | 1775 |
line := cursorLine. |
1776 |
col := cursorCol. |
|
1777 |
" |
|
1778 |
if there is a selection, its better to |
|
1779 |
have its start being visible, instead of the end |
|
1780 |
" |
|
1781 |
(selectionStartLine notNil |
|
1782 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
1783 |
expandingTop ~~ false ifTrue:[ |
|
1784 |
line := selectionStartLine. |
|
1785 |
col := selectionStartCol. |
|
1786 |
] ifFalse:[ |
|
1787 |
line := selectionEndLine. |
|
1788 |
col := selectionEndCol |
|
1789 |
] |
|
1790 |
]. |
|
1791 |
self makeLineVisible:line. |
|
1792 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1793 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1794 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1795 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1796 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1797 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1798 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1799 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1800 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1801 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1802 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1803 |
flag ifTrue:[self showCursor] |
121 | 1804 |
! |
1805 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1806 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1807 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1808 |
|
2815 | 1809 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1810 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1811 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1812 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1813 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1814 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1815 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1816 |
cursorLine := lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1817 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1818 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1819 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1820 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1821 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1822 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1823 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1824 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1825 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1826 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1827 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1828 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1829 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1830 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1831 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1832 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1833 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1834 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1835 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1836 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1837 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1838 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1839 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1840 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1841 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1842 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1843 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1844 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1845 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1846 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1847 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1848 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
|
1833 | 1850 |
^ self cursorShown:true |
1851 |
||
1852 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1853 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1854 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1855 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1856 |
"undraw the cursor (i.e. redraw the character(s) under the cursor)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1858 |
|prevCol line oldClip x y e1 e2 e3| |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1859 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1860 |
cursorVisibleLine notNil ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1861 |
prevCol := cursorCol - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1862 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1863 |
"/ if there is any italic stuff in the cursor line, |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1864 |
"/ redraw it completely (because characters overlap). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1865 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1866 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1867 |
line hasChangeOfEmphasis ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1868 |
line size >= (cursorCol-1) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1869 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1870 |
line size >= (cursorCol) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1871 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1872 |
line size >= (cursorCol+1) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1873 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1874 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1875 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1876 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1877 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1878 |
^ super redrawVisibleLine:cursorVisibleLine |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1879 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1880 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1881 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1882 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1883 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1884 |
((cursorType == #caret) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1885 |
or:[cursorType == #solidCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1886 |
or:[cursorType == #bigSolidCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1887 |
or:[cursorType == #bigCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1888 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1889 |
"caret-cursor touches 4 characters" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1890 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
2088 | 1891 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1892 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1893 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1894 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1895 |
"care for left margin" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1896 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1897 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1898 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1899 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1900 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1901 |
cursorType == #ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1902 |
"ibeam-cursor touches 2 characters" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1903 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1904 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1905 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1906 |
"care for left margin" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1907 |
super redrawVisibleLine:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1908 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1909 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1910 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1911 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1912 |
"block cursor is simple - just one character under cursor" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1913 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1914 |
"/ however, if italic characters are involved, we must care |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1915 |
"/ for the chars before/after the cursor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1916 |
"/ We redraw the part of the previous character which got |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1917 |
"/ detroyed by the block cursor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1918 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1919 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1920 |
line := self visibleAt:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1921 |
(line notNil and:[line isText]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1922 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1923 |
oldClip := self clippingRectangleOrNil. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1924 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1925 |
y := self yOfVisibleLine:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1926 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1927 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1928 |
self clippingRectangle:oldClip. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1929 |
^ self. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1930 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1931 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1932 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1933 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1934 |
|
2088 | 1935 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 1936 |
! |
1937 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1938 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1939 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1940 |
notice: visibleLine will be set to nil if the cursor is not visible" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1941 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1942 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1943 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1944 |
|
672 | 1945 |
validateCursorCol:col inLine:line |
674 | 1946 |
"check of col is a valid cursor position; return a new col-nr if not. |
1947 |
Here, no limits are enforced (and col is returned), |
|
1948 |
but it may be redefined in EditFields or views which dont like the |
|
1949 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
|
672 | 1950 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1951 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1952 |
|
1419 | 1953 |
"/ in ST80 mode, |
2707 | 1954 |
"/ the cursor may not be positioned beyond the |
1955 |
"/ end of a line or beyond the last line of the text |
|
1419 | 1956 |
"/ |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1957 |
self st80EditMode == true ifTrue:[ |
2357 | 1958 |
l := (self listAt:line). |
1959 |
max := l size + 1. |
|
1960 |
col > max ifTrue:[ |
|
1961 |
^ max |
|
1962 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1963 |
]. |
672 | 1964 |
^ col |
1965 |
||
1419 | 1966 |
"Created: / 22.5.1996 / 14:25:30 / cg" |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1967 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 1968 |
! |
1969 |
||
1970 |
validateCursorLine:line |
|
1971 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
1972 |
Here, no limits are enforced (and line is returned), but it may be |
|
1973 |
redefined in views which dont like the cursor to be positioned |
|
1974 |
behind the end of the text (vi/st-80 behavior), or want to |
|
1975 |
skip reserved regions" |
|
1976 |
||
1419 | 1977 |
"/ |
1978 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 1979 |
"/ beyond the last line |
1419 | 1980 |
"/ |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1981 |
self st80EditMode == true ifTrue:[ |
2357 | 1982 |
^ (line min:(list size)) max:1 |
1419 | 1983 |
]. |
674 | 1984 |
^ line |
1985 |
||
1419 | 1986 |
"Created: / 22.5.1996 / 18:22:23 / cg" |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1987 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 1988 |
! |
1989 |
||
121 | 1990 |
withCursorOffDo:aBlock |
1991 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
1992 |
||
1993 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
2357 | 1994 |
^ aBlock value |
121 | 1995 |
]. |
1996 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
1997 |
aBlock ensure:[ |
2357 | 1998 |
self showCursor |
121 | 1999 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2000 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2001 |
|
2589 | 2002 |
!EditTextView methodsFor:'drag & drop'! |
2003 |
||
2004 |
allowDrop:aBoolean |
|
2005 |
"enable/disable drop support |
|
2006 |
" |
|
2007 |
aBoolean ifFalse:[ |
|
2008 |
dropTarget := nil. |
|
2009 |
] ifTrue:[ |
|
2010 |
dropTarget ifNil:[ |
|
2011 |
dropTarget := DropTarget receiver:self |
|
2012 |
argument:nil |
|
2013 |
dropSelector:#'drop:' |
|
2014 |
canDropSelector:#'canDrop:' |
|
2015 |
] |
|
2016 |
]. |
|
2017 |
! |
|
2018 |
||
2019 |
canDrop:aContext |
|
2020 |
"I accept textObjects and fileObjects only |
|
2021 |
" |
|
2022 |
|objects| |
|
2023 |
||
2024 |
aContext sourceWidget == self ifTrue:[ |
|
2025 |
^ false |
|
2026 |
]. |
|
2027 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2028 |
||
2029 |
objects := aContext dropObjects. |
|
2030 |
objects isEmpty ifTrue:[ ^ false ]. |
|
2031 |
||
2032 |
objects do:[:el| |
|
2033 |
(el isTextObject or:[el isFileObject]) ifFalse:[^ false]. |
|
2034 |
]. |
|
2035 |
^ true |
|
2036 |
! |
|
2037 |
||
2038 |
drop:aContext |
|
2039 |
"drop objects |
|
2040 |
" |
|
2041 |
|text| |
|
2042 |
||
2043 |
(self canDrop:aContext) ifFalse:[^ false]. |
|
2044 |
||
2045 |
text := StringCollection new. |
|
2046 |
||
2047 |
aContext dropObjects do:[:el| |obj| |
|
2048 |
obj := el theObject. |
|
2049 |
el isTextObject ifTrue:[ text addAll:obj ] |
|
2050 |
ifFalse:[ text add:(obj asString) ] |
|
2051 |
]. |
|
2052 |
self pasteOrReplace:text. |
|
2053 |
^ true |
|
2054 |
! |
|
2055 |
||
2056 |
dropTarget |
|
2057 |
"returns the dropTarget or nil |
|
2058 |
" |
|
2059 |
^ dropTarget |
|
2060 |
! |
|
2061 |
||
2062 |
dropTarget:aDropTragetOrNil |
|
2063 |
"set the dropTarget or nil |
|
2064 |
" |
|
2065 |
dropTarget := aDropTragetOrNil. |
|
2066 |
! ! |
|
2067 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2068 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2069 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2070 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2071 |
"copy the selection into the pastBuffer and delete it" |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2072 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2073 |
selectionStartLine notNil ifTrue:[ |
2357 | 2074 |
self setTextSelection:(self selection). |
2075 |
self deleteSelection. |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2076 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2077 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2078 |
"Created: 27.1.1996 / 16:23:28 / cg" |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2079 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2080 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2081 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2082 |
"delete single character under cursor; does not merge lines" |
121 | 2083 |
|
2084 |
|wasOn| |
|
2085 |
||
2086 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2088 |
wasOn ifTrue:[self showCursor] |
2089 |
! |
|
2090 |
||
827 | 2091 |
deleteCharAtLine:lineNr col:colNr |
2092 |
"delete a single character at colNr in line lineNr" |
|
2093 |
||
2094 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
|
2095 |
! |
|
2096 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2097 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2098 |
"delete single character to the left of cursor and move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2099 |
|
2491 | 2100 |
|soCol wasOn lineNrAboveCursor ln prevTab| |
121 | 2101 |
|
2102 |
wasOn := self hideCursor. |
|
2491 | 2103 |
autoIndent ifTrue:[ |
2104 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
|
2105 |
ln := (list at:cursorLine) ? ''. |
|
2106 |
ln size < prevTab ifTrue:[ |
|
2107 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2108 |
]. |
|
2109 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2110 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2111 |
cursorCol > prevTab ifTrue:[ |
|
2112 |
self cursorLine:cursorLine col:prevTab. |
|
2113 |
wasOn ifTrue:[ self showCursor ]. |
|
2114 |
^ self |
|
2115 |
]. |
|
2116 |
] ifFalse:[ |
|
2117 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2118 |
self cursorLine:cursorLine col:prevTab. |
|
2119 |
wasOn ifTrue:[ self showCursor ]. |
|
2120 |
^ self. |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2121 |
] |
2491 | 2122 |
]. |
827 | 2123 |
]. |
2124 |
||
2491 | 2125 |
"/ (autoIndent |
2126 |
"/ and:[cursorCol ~~ 1 |
|
2127 |
"/ and:[cursorLine <= (list size)]]) |
|
2128 |
"/ ifTrue:[ |
|
2129 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2130 |
"/ |
|
2131 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2132 |
"/ ln := list at:cursorLine. |
|
2133 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2134 |
"/ soCol := 1 |
|
2135 |
"/ ] |
|
2136 |
"/ ] |
|
2137 |
"/ ] ifFalse:[ |
|
2138 |
soCol := 1. |
|
2139 |
"/ ]. |
|
2140 |
||
1419 | 2141 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2142 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2143 |
somewhere in the middle of a line |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2144 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2145 |
self cursorLeft. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2146 |
self deleteCharAtLine:cursorLine col:cursorCol. |
1419 | 2147 |
] ifFalse:[ |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2148 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2149 |
at begin of line - merge with previous line; |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2150 |
except for the very first line. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2151 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2152 |
(cursorLine == 1) ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2153 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2154 |
lineNrAboveCursor < cursorLine ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2155 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
2707 | 2156 |
"/ we are beyond the end of the text. |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2157 |
"/ move the cursor to the previous line. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2158 |
self cursorLine:lineNrAboveCursor col:1. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2159 |
] ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2160 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2161 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2162 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2163 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2164 |
]. |
827 | 2165 |
wasOn ifTrue:[ self showCursor ] |
2166 |
||
1419 | 2167 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2168 |
! |
2169 |
||
2170 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2171 |
"delete characters from colNr up to the end in line lineNr" |
|
2172 |
||
2173 |
|line| |
|
2174 |
||
2175 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
2357 | 2176 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2177 |
] |
2178 |
||
2179 |
! |
|
2180 |
||
2181 |
deleteCharsAtLine:lineNr toCol:colNr |
|
2182 |
"delete characters from start up to colNr in line lineNr" |
|
2183 |
||
2184 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2185 |
||
2186 |
||
121 | 2187 |
! |
2188 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2189 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2190 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2191 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2192 |
self deleteLine:cursorLine |
121 | 2193 |
! |
2194 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2195 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2196 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2197 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2198 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2199 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2200 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2201 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2202 |
col1 == 0 ifTrue:[ |
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2203 |
line1 := line1 - 1. |
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2204 |
col1 := (self listAt:line1) size + 1. |
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2205 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2206 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2207 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2208 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2209 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2210 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2211 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2212 |
|
2954 | 2213 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2214 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2215 |
joining lines if nescessary" |
|
2216 |
||
2217 |
|line newLine lineSize nMore| |
|
2218 |
||
2219 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2220 |
list isNil ifTrue:[^ self]. |
|
2221 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2222 |
||
2223 |
(startLine == endLine) ifTrue:[ |
|
2224 |
"/ delete chars within a line |
|
2225 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2226 |
^ self |
|
2227 |
]. |
|
2228 |
||
2229 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
2230 |
"/ delete full lines only |
|
2231 |
endLine > startLine ifTrue:[ |
|
2232 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2233 |
]. |
|
2234 |
^ self |
|
2235 |
]. |
|
2236 |
||
2237 |
"/ delete right rest of 1st line |
|
2238 |
self deleteCharsAtLine:startLine fromCol:startCol. |
|
2239 |
||
2240 |
"/ delete the inner lines ... |
|
2241 |
endLine > (startLine + 1) ifTrue:[ |
|
2242 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
|
2243 |
]. |
|
2244 |
||
2245 |
(endCol ~~ 0) ifTrue:[ |
|
2246 |
"/ delete the left rest of the last line |
|
2247 |
||
2248 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2249 |
||
2250 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2251 |
||
2252 |
line := list at:startLine. |
|
2253 |
lineSize := line size. |
|
2254 |
(startCol > lineSize) ifTrue:[ |
|
2255 |
newLine := line. |
|
2256 |
line isNil ifTrue:[ |
|
2257 |
newLine := String new:(startCol - 1) |
|
2258 |
] ifFalse:[ |
|
2259 |
nMore := startCol - 1 - lineSize. |
|
2260 |
nMore > 0 ifTrue:[ |
|
2261 |
newLine := line , (line species new:nMore) |
|
2262 |
] |
|
2263 |
]. |
|
2264 |
newLine ~~ line ifTrue:[ |
|
2265 |
list at:startLine put:newLine. |
|
2266 |
]. |
|
2267 |
"/ TODO: remember old maxwidth of linerange, |
|
2268 |
"/ only clear widthOfWidestLine, if this max |
|
2269 |
"/ length was (one of) the longest. |
|
2270 |
"/ avoids slow delete with huge texts. |
|
2271 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2272 |
self textChanged. |
|
2273 |
] |
|
2274 |
]. |
|
2275 |
||
2276 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
2277 |
self mergeLine:startLine removeBlanks:false |
|
2278 |
||
2279 |
"Modified: / 10.11.1998 / 23:52:59 / cg" |
|
2280 |
! |
|
2281 |
||
827 | 2282 |
deleteLine:lineNr |
2283 |
"delete line" |
|
2284 |
||
2285 |
self deleteFromLine:lineNr toLine:lineNr |
|
2286 |
||
2287 |
||
2288 |
! |
|
2289 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2294 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2295 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2296 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2297 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2299 |
(endLine > list size) ifTrue:[ |
2357 | 2300 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2301 |
] ifFalse:[ |
2357 | 2302 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2304 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2305 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2306 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2307 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2308 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2309 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2310 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2311 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2312 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2313 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2314 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2315 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2316 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2318 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2321 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2322 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
selectionStartLine notNil ifTrue:[ |
2357 | 2324 |
wasOn := self hideCursor. |
2325 |
||
2326 |
startLine := selectionStartLine. |
|
2327 |
startCol := selectionStartCol. |
|
2328 |
endLine := selectionEndLine. |
|
2329 |
endCol := selectionEndCol. |
|
2330 |
self unselectWithoutRedraw. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2331 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2332 |
self setCursorLine:startLine col:startCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2333 |
|
2357 | 2334 |
self makeCursorVisibleAndShowCursor:wasOn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2335 |
] |
121 | 2336 |
! |
2337 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2338 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2339 |
"delete the word to the left of cursor and move cursor to left" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2340 |
|
2952 | 2341 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2342 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2343 |
wasOn := self hideCursor. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2344 |
endCol := cursorCol-1. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2345 |
endLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2346 |
self cursorToPreviousWord. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2347 |
beginCol := cursorCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2348 |
beginLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2349 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2350 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2351 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2352 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2353 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2354 |
|
121 | 2355 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2356 |
"insert a single character at cursor-position - advance cursor." |
121 | 2357 |
|
2358 |
|wasOn| |
|
2359 |
||
2360 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2361 |
aCharacter == Character tab ifTrue:[ |
2357 | 2362 |
"/ needs special care to advance cursor correctly |
2363 |
self insertTabAtCursor |
|
121 | 2364 |
] ifFalse:[ |
2357 | 2365 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
2366 |
aCharacter == (Character cr) ifTrue:[ |
|
2367 |
self cursorReturn |
|
2368 |
] ifFalse:[ |
|
2369 |
self cursorRight. |
|
2370 |
]. |
|
121 | 2371 |
]. |
2372 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2373 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2374 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 2375 |
! |
2376 |
||
641 | 2377 |
insertLine:aString before:lineNr |
2378 |
"insert the line aString before line lineNr" |
|
2379 |
||
2380 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
2381 |
||
2382 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
2383 |
! |
|
2384 |
||
155 | 2385 |
insertLines:aStringCollection before:lineNr |
2386 |
"insert a bunch before line lineNr" |
|
2387 |
||
2388 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
2389 |
||
2390 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
2391 |
! |
|
2392 |
||
654 | 2393 |
insertLines:lines withCR:withCr |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2394 |
"insert a bunch of lines at cursor position. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2395 |
Cursor is moved behind insertion. |
641 | 2396 |
If withCr is true, append cr after last line" |
2397 |
||
2398 |
|start end nLines wasOn| |
|
2399 |
||
2400 |
lines notNil ifTrue:[ |
|
2357 | 2401 |
nLines := lines size. |
2402 |
(nLines == 1) ifTrue:[ |
|
2403 |
self insertStringAtCursor:(lines at:1). |
|
2404 |
withCr ifTrue:[ |
|
2405 |
self insertCharAtCursor:(Character cr) |
|
2406 |
] |
|
2407 |
] ifFalse:[ |
|
2408 |
(cursorCol ~~ 1) ifTrue:[ |
|
2409 |
self insertStringAtCursor:(lines at:1). |
|
2410 |
self insertCharAtCursor:(Character cr). |
|
2411 |
start := 2 |
|
2412 |
] ifFalse:[ |
|
2413 |
start := 1 |
|
2414 |
]. |
|
2415 |
withCr ifTrue:[ |
|
2416 |
end := nLines |
|
2417 |
] ifFalse:[ |
|
2418 |
end := nLines - 1 |
|
2419 |
]. |
|
2420 |
(start < nLines) ifTrue:[ |
|
2421 |
(end >= start) ifTrue:[ |
|
2422 |
wasOn := self hideCursor. |
|
2423 |
self insertLines:lines from:start to:end before:cursorLine. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2424 |
self setCursorLine:(cursorLine + (end - start + 1)). |
2357 | 2425 |
wasOn ifTrue:[self showCursor]. |
2426 |
] |
|
2427 |
]. |
|
2428 |
withCr ifFalse:[ |
|
2429 |
"last line without cr" |
|
2430 |
self insertStringAtCursor:(lines at:nLines) |
|
2431 |
] |
|
2432 |
] |
|
641 | 2433 |
] |
654 | 2434 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2435 |
"Created: / 18.5.1996 / 15:32:06 / cg" |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2436 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 2437 |
! |
2438 |
||
2439 |
insertLines:lines withCr:withCr |
|
2440 |
"insert a bunch of lines at cursor position. Cursor |
|
2441 |
is moved behind insertion. |
|
2442 |
If withCr is true, append cr after last line" |
|
2443 |
||
2363 | 2444 |
<resource:#obsolete> |
2445 |
||
1292 | 2446 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
2447 |
self insertLines:lines withCR:withCr. |
|
2448 |
||
2449 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 2450 |
! |
2451 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2452 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2453 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2455 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2456 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2457 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2458 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2459 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2460 |
self selectFromLine:startLine col:startCol |
2357 | 2461 |
toLine:cursorLine col:(cursorCol - 1) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2462 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2463 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2464 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2465 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2466 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2467 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2468 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2469 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2470 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2471 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2472 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2473 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2474 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2475 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2476 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2477 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2478 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2479 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2480 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2481 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2482 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2483 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2484 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2485 |
(aString includes:(Character cr)) ifFalse:[ |
2357 | 2486 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 2487 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2488 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2489 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2490 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2491 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2492 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2493 |
[start <= end] whileTrue:[ |
2357 | 2494 |
stop := aString indexOf:(Character cr) startingAt:start. |
2495 |
stop == 0 ifTrue:[ |
|
2496 |
stop := end + 1 |
|
2497 |
]. |
|
2498 |
subString := aString copyFrom:start to:(stop - 1). |
|
2499 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
2500 |
(stop <= end) ifTrue:[ |
|
2501 |
c := c + subString size. |
|
2502 |
self insert:(Character cr) atLine:l col:c. |
|
2503 |
l := l + 1. |
|
2504 |
c := 1 |
|
2505 |
]. |
|
2506 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2507 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2508 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2509 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 2510 |
! |
2511 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2512 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2513 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2514 |
handle cr's correctly. A nil argument is interpreted as an empty line." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2515 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2516 |
aString isNil ifTrue:[ |
2357 | 2517 |
"new:" |
2518 |
self insertCharAtCursor:(Character cr). |
|
2519 |
^ self |
|
105 | 2520 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2521 |
(aString includes:(Character cr)) ifFalse:[ |
2357 | 2522 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 2523 |
]. |
2524 |
||
654 | 2525 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2526 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2527 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 2528 |
! |
2529 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2530 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2531 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2534 |
shown ifTrue:[self redrawLine:lineNr from:colNr] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2535 |
|
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2536 |
"Modified: / 5.4.1998 / 16:51:14 / cg" |
105 | 2537 |
! |
2538 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2539 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2540 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2541 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2542 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2543 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2544 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2545 |
aString size > 0 ifTrue:[ |
2357 | 2546 |
wasOn := self hideCursor. |
2547 |
(aString includes:Character tab) ifTrue:[ |
|
2548 |
self checkForExistingLine:cursorLine. |
|
2549 |
oldLen := (list at:cursorLine) size. |
|
2550 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
2551 |
newLen := (list at:cursorLine) size. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2552 |
deltaLen := newLen - oldLen. |
2357 | 2553 |
] ifFalse:[ |
2574 | 2554 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2555 |
deltaLen := aString size. |
2357 | 2556 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2557 |
self setCursorCol:(cursorCol + deltaLen). |
2357 | 2558 |
wasOn ifTrue:[self showCursor] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2559 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2560 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2561 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2562 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2563 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2564 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2565 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2567 |
|wasOn nextTab| |
105 | 2568 |
|
121 | 2569 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2570 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2571 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2572 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 2573 |
! |
2574 |
||
2952 | 2575 |
mergeLine:lineNr |
2576 |
"merge line lineNr with line lineNr+1" |
|
2577 |
||
2578 |
self mergeLine:lineNr removeBlanks:true |
|
2579 |
||
2580 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
2581 |
! |
|
2582 |
||
2506 | 2583 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2584 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2585 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2586 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2587 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2588 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2589 |
|
2506 | 2590 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
2591 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2592 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2593 |
newSelectionEnd := newSelectionEnd-1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2594 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2595 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2596 |
selectionStartLine == selectionEndLine ifTrue:[ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2597 |
newSelectionEnd := newSelectionEnd-1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2598 |
] |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2599 |
] ifFalse:[ |
2506 | 2600 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2601 |
newSelectionEnd := newSelectionEnd+1. |
2506 | 2602 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2603 |
selectionStartLine == selectionEndLine ifTrue:[ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2604 |
newSelectionEnd := newSelectionEnd+1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2605 |
] |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2606 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2607 |
self |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2608 |
selectFromLine:selectionStartLine col:selectionStartCol |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2609 |
toLine:selectionEndLine col:newSelectionEnd. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2610 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2611 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2612 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2613 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2614 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2615 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2616 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2617 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2618 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2619 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2620 |
[finished] whileFalse:[ |
2357 | 2621 |
(lastLine <= 1) ifTrue:[ |
2622 |
finished := true |
|
2623 |
] ifFalse:[ |
|
2624 |
line := list at:lastLine. |
|
2625 |
line notNil ifTrue:[ |
|
2626 |
line isBlank ifTrue:[ |
|
2627 |
list at:lastLine put:nil. |
|
2628 |
line := nil |
|
2629 |
] |
|
2630 |
]. |
|
2631 |
line notNil ifTrue:[ |
|
2632 |
finished := true |
|
2633 |
] ifFalse:[ |
|
2634 |
lastLine := lastLine - 1 |
|
2635 |
] |
|
2636 |
] |
|
118 | 2637 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2638 |
(lastLine ~~ list size) ifTrue:[ |
2357 | 2639 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2640 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2641 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2643 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2644 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2645 |
"replace a single character at cursor-position - advance cursor" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2646 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2647 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2648 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2649 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2650 |
aCharacter == (Character cr) ifTrue:[ |
2357 | 2651 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2652 |
] ifFalse:[ |
2357 | 2653 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
2654 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2655 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2656 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2657 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2658 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2659 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2660 |
|
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2661 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2662 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2663 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2664 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2665 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2666 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2667 |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2668 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2669 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2670 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2671 |
If withCr is true, move to the beginning of the next line |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2672 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2673 |
|
1809 | 2674 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2675 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2676 |
lines notNil ifTrue:[ |
2357 | 2677 |
wasOn := self hideCursor. |
2678 |
nLines := lines size. |
|
2679 |
line := cursorLine. |
|
2680 |
col := cursorCol. |
|
2681 |
lines keysAndValuesDo:[:i :l | |
|
2682 |
self replaceString:l atLine:line col:col. |
|
2683 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
2684 |
line := line + 1. |
|
2685 |
col := 1. |
|
2686 |
] ifFalse:[ |
|
2687 |
col := col + (l size). |
|
2688 |
] |
|
2689 |
]. |
|
2690 |
self cursorLine:line col:col. |
|
2691 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2692 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2693 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2694 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2695 |
"Created: / 18.5.1996 / 15:32:06 / cg" |
1567
0eff7ca88e89
much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents:
1566
diff
changeset
|
2696 |
"Modified: / 12.6.1998 / 22:05:51 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2697 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2698 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2699 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2700 |
"delete the selection (if any) and insert something, a character or string; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2701 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2702 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2703 |
self replaceSelectionBy:something keepCursor:false |
105 | 2704 |
! |
2705 |
||
2706 |
replaceSelectionBy:something keepCursor:keep |
|
2707 |
"delete the selection (if any) and insert something, a character or string; |
|
2708 |
leave cursor after insertion or leave it, depending on keep" |
|
2709 |
||
2710 |
|sel l c| |
|
2711 |
||
2712 |
l := cursorLine. |
|
2713 |
c := cursorCol. |
|
2714 |
||
2715 |
sel := self selection. |
|
2716 |
sel notNil ifTrue:[ |
|
2357 | 2717 |
lastString := sel. |
2718 |
self deleteSelection. |
|
2719 |
replacing := true. |
|
2720 |
lastReplacement := '' |
|
105 | 2721 |
]. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2722 |
|
105 | 2723 |
(something isMemberOf:Character) ifTrue:[ |
2357 | 2724 |
lastReplacement notNil ifTrue:[ |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2725 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2726 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2727 |
"/ lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2728 |
"/ lastReplacement := lastReplacement copyWith:something. |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2729 |
"/ lastReplacement := lastReplacement copyWith:Character space |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2730 |
"/ ] ifFalse:[ |
2357 | 2731 |
lastReplacement := lastReplacement copyWith:something. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2732 |
"/ ] |
2357 | 2733 |
]. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
2734 |
insertMode value ifTrue:[ |
2357 | 2735 |
self insertCharAtCursor:something |
2736 |
] ifFalse:[ |
|
2737 |
self replaceCharAtCursor:something |
|
2738 |
] |
|
105 | 2739 |
] ifFalse:[ |
2357 | 2740 |
lastReplacement := something. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
2741 |
insertMode value ifTrue:[ |
2357 | 2742 |
self insertStringAtCursor:something |
2743 |
] ifFalse:[ |
|
2912
b302a46fc21e
oops - replace-by-keyboard-entry got corrupted by
Claus Gittinger <cg@exept.de>
parents:
2910
diff
changeset
|
2744 |
self replaceStringAtCursor:something |
2357 | 2745 |
] |
105 | 2746 |
]. |
2747 |
keep ifTrue:[ |
|
2357 | 2748 |
self cursorLine:l col:c |
105 | 2749 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2750 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2751 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2752 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2753 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2754 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2755 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2756 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2757 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2758 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2759 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2760 |
(aString includes:Character tab) ifTrue:[ |
2357 | 2761 |
"/ need special care for TAB (to move cursor correctly) |
2762 |
i1 := 1. |
|
2763 |
[i1 ~~ 0] whileTrue:[ |
|
2764 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
2765 |
i2 ~~ 0 ifTrue:[ |
|
2766 |
i1 ~~ i2 ifTrue:[ |
|
2767 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
2768 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
2769 |
]. |
|
2770 |
self replaceTABAtCursor. |
|
2771 |
i2 := i2 + 1. |
|
2772 |
] ifFalse:[ |
|
2773 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
2774 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
2775 |
]. |
|
2776 |
i1 := i2. |
|
2777 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2778 |
] ifFalse:[ |
2357 | 2779 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
2780 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2781 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2782 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2783 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2784 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2785 |
"Modified: / 20.6.1998 / 19:41:02 / cg" |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2786 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2787 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2788 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2789 |
"replace a single character at cursor-position by a TAB character" |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2790 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2791 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2792 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2793 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2794 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2795 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2796 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2797 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2798 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2799 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2800 |
|
2752 | 2801 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2802 |
|
2952 | 2803 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
827 | 2804 |
"delete characters from startCol to endCol in line lineNr |
2805 |
" |
|
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
2806 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2807 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2808 |
line := self listAt:lineNr. |
827 | 2809 |
|
2810 |
(self checkModificationsAllowed and:[line notNil]) ifTrue:[ |
|
2207 | 2811 |
lineSize := line size. |
2812 |
||
2813 |
startCol == 0 ifFalse:[ start := startCol ] |
|
2814 |
ifTrue:[ start := 1 ]. |
|
2815 |
||
2816 |
endCol > lineSize ifFalse:[ stop := endCol ] |
|
2817 |
ifTrue:[ stop := lineSize ]. |
|
2818 |
||
2819 |
stop >= start ifTrue:[ |
|
2820 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
2821 |
ifFalse:[ newLine := '' ]. |
|
2822 |
||
2823 |
stop == lineSize ifFalse:[ |
|
2824 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
2825 |
newLine := line string species fromString:newLine. |
|
2826 |
]. |
|
2827 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
2828 |
]. |
|
2829 |
||
2830 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
2831 |
newLine := nil |
|
2832 |
]. |
|
2833 |
||
2834 |
prevWidth := self widthOfLine:lineNr. |
|
2835 |
||
2836 |
list at:lineNr put:newLine. |
|
2837 |
||
2838 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
2839 |
"/ remember old width of this line, |
|
2840 |
"/ only clear widthOfWidestLine, if this lines |
|
2841 |
"/ length was (one of) the longest. |
|
2842 |
"/ avoids slow delete with huge texts. |
|
2843 |
widthOfWidestLine := nil. "i.e. unknown" |
|
2844 |
||
2845 |
"/ scroll left if reqiured |
|
2846 |
viewOrigin x > 0 ifTrue:[ |
|
2847 |
newWidth := self widthOfLine:lineNr. |
|
2848 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
2849 |
self scrollHorizontalTo:(newWidth |
|
2850 |
- width |
|
2851 |
+ margin + margin |
|
2852 |
+ (font widthOf:' ')) |
|
2853 |
] |
|
2854 |
]. |
|
2855 |
self textChanged. |
|
2856 |
] ifFalse:[ |
|
2617 | 2857 |
self textChanged "/ textChangedButNoSizeChange |
2207 | 2858 |
]. |
2859 |
self redrawLine:lineNr from:start. |
|
2860 |
||
2861 |
] |
|
827 | 2862 |
] |
2863 |
||
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2864 |
"Modified: / 11.11.1998 / 00:01:09 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2865 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2866 |
|
2952 | 2867 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2868 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2869 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2870 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2871 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2872 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2873 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2874 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2875 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2876 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2877 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2878 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2879 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2880 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2881 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2882 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2883 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2884 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2885 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2886 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2887 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2888 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2889 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2890 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2891 |
(firstLineShown >= nLines) ifTrue:[ |
2357 | 2892 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2893 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2894 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2895 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2896 |
"Modified: / 10.11.1998 / 23:55:05 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2897 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2898 |
|
2952 | 2899 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2900 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2901 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2902 |
|
2952 | 2903 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2904 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2905 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2906 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2907 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2908 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2909 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2910 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2911 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2912 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2913 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2914 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2915 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2916 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2917 |
|
2952 | 2918 |
basicInsert:aCharacter atLine:lineNr col:colNr |
827 | 2919 |
"insert a single character at lineNr/colNr; |
2920 |
set emphasis to character at current position" |
|
2921 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
2922 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2923 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2924 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2925 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2926 |
aCharacter == (Character cr) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2927 |
self splitLine:lineNr before:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2928 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2929 |
]. |
827 | 2930 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2931 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2932 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2933 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2934 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
2935 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2936 |
self st80EditMode ~~ true ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2937 |
(trimBlankLines |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2938 |
and:[colNr > lineSize |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2939 |
and:[aCharacter == Character space]]) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2940 |
^ self |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2941 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2942 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
2943 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2944 |
(lineSize == 0) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2945 |
newLine := aCharacter asString species new:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2946 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2947 |
] ifFalse: [ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2948 |
(colNr > lineSize) ifTrue: [ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2949 |
colNr == (lineSize +1) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2950 |
attribute := line emphasisAt:lineSize |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2951 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2952 |
newLine := line species new:colNr. |
2210 | 2953 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2954 |
drawCharacterOnly := true |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2955 |
] ifFalse: [ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2956 |
attribute := line emphasisAt:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2957 |
newLine := line species new:(lineSize + 1). |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2958 |
|
2210 | 2959 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
2960 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2961 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2962 |
]. |
827 | 2963 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
2964 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
2940 | 2965 |
newLine := aCharacter asString species fromString:newLine. |
2966 |
line isText ifTrue:[ |
|
2967 |
newLine := newLine asText |
|
2968 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
2969 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2970 |
newLine at:colNr put:aCharacter. |
827 | 2971 |
|
2972 |
attribute notNil ifTrue:[ |
|
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2973 |
newLine emphasisAt:colNr put:attribute |
827 | 2974 |
]. |
2975 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2976 |
aCharacter == (Character tab) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2977 |
newLine := self withTabsExpanded:newLine. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2978 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2979 |
]. |
827 | 2980 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2981 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2982 |
widthOfWidestLine notNil ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2983 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2984 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2985 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2986 |
shown ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2987 |
"/ care for italic text - in this case, we must also |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2988 |
"/ redraw the character before the insertion in order |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2989 |
"/ to fix the slanted piece of the character. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2990 |
"/ (but we must clip, to avoid destoying the character before) |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2991 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2992 |
colNr > 1 ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2993 |
cursorVisibleLine notNil ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2994 |
oldClip := self clippingRectangleOrNil. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2995 |
x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - viewOrigin x. |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2996 |
y := self yOfVisibleLine:cursorVisibleLine. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2997 |
drawCharacterOnly ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2998 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2999 |
self redrawLine:lineNr from:colNr-1 to:colNr |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3000 |
] ifFalse:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3001 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3002 |
self redrawLine:lineNr from:colNr-1 |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3003 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3004 |
self clippingRectangle:oldClip. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3005 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3006 |
^ self. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3007 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3008 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3009 |
drawCharacterOnly ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3010 |
self redrawLine:lineNr col:colNr |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3011 |
] ifFalse:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3012 |
self redrawLine:lineNr from:colNr |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
3013 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3014 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3015 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
3016 |
"Modified: / 20.6.1998 / 18:19:22 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3017 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3018 |
|
2952 | 3019 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 3020 |
"merge line lineNr with line lineNr+1" |
3021 |
||
827 | 3022 |
|leftPart rightPart bothParts nextLineNr i| |
3023 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3024 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
2707 | 3025 |
"/ empty list or beyond end of text |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3026 |
^ self |
827 | 3027 |
]. |
3028 |
leftPart := self listAt:lineNr. |
|
3029 |
||
3030 |
leftPart isNil ifTrue:[ |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3031 |
leftPart := ''. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3032 |
autoIndent ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3033 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3034 |
leftPart := String new:i |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3035 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3036 |
] |
827 | 3037 |
]. |
3038 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
3039 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
3040 |
||
3041 |
nextLineNr > (list size) ifFalse:[ |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3042 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3043 |
rightPart := '' |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3044 |
] ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3045 |
removeBlanks ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3046 |
rightPart := rightPart withoutLeadingSeparators. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3047 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3048 |
]. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3049 |
|
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3050 |
bothParts := leftPart , rightPart. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3051 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3052 |
list at:lineNr put:bothParts. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3053 |
self redrawLine:lineNr. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3054 |
self deleteLine:nextLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3055 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3056 |
|
1319 | 3057 |
"Created: 9.9.1997 / 09:27:38 / cg" |
3058 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3059 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3060 |
|
2952 | 3061 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3062 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3063 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3064 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3065 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3066 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3067 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3068 |
aCharacter == (Character cr) ifTrue:[ |
2357 | 3069 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3070 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3071 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3072 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3073 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3074 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3075 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3076 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3077 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3078 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3079 |
and:[aCharacter == Character space]]) ifTrue:[ |
2357 | 3080 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3081 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3082 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3083 |
(lineSize == 0) ifTrue:[ |
2357 | 3084 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3085 |
] ifFalse: [ |
2357 | 3086 |
(colNr > lineSize) ifTrue: [ |
3087 |
newLine := line species new:colNr. |
|
3088 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3089 |
] ifFalse: [ |
|
3090 |
newLine := line copy. |
|
3091 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3092 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3093 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3094 |
aCharacter == (Character tab) ifTrue:[ |
2357 | 3095 |
newLine := self withTabsExpanded:newLine. |
3096 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3097 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3098 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3099 |
widthOfWidestLine notNil ifTrue:[ |
2357 | 3100 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3101 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3102 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3103 |
shown ifTrue:[ |
2357 | 3104 |
drawCharacterOnly ifTrue:[ |
3105 |
self redrawLine:lineNr col:colNr |
|
3106 |
] ifFalse:[ |
|
3107 |
self redrawLine:lineNr from:colNr |
|
3108 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3109 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3110 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3111 |
"Created: / 6.3.1996 / 12:29:20 / cg" |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3112 |
"Modified: / 10.6.1998 / 18:50:18 / cg" |
105 | 3113 |
! |
3114 |
||
2952 | 3115 |
basicSplitLine:lineNr before:colNr |
3116 |
"split the line linNr before colNr; the right part (from colNr) |
|
3117 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3118 |
||
3119 |
|line lineSize leftRest rightRest visLine w h mustWait |
|
3120 |
srcY "{ Class: SmallInteger }" | |
|
3121 |
||
3122 |
list isNil ifFalse:[ |
|
3123 |
lineNr > (list size) ifFalse:[ |
|
3124 |
(colNr == 1) ifTrue:[ |
|
3125 |
self nonUndoableDo:[ |
|
3126 |
self insertLine:nil before:lineNr. |
|
3127 |
]. |
|
3128 |
^ self |
|
3129 |
]. |
|
3130 |
line := list at:lineNr. |
|
3131 |
line isNil ifFalse:[ |
|
3132 |
lineSize := line size. |
|
3133 |
(colNr <= lineSize) ifTrue:[ |
|
3134 |
rightRest := line copyFrom:colNr to:lineSize. |
|
3135 |
(colNr > 1) ifTrue:[ |
|
3136 |
leftRest := line copyTo:(colNr - 1) |
|
3137 |
] |
|
3138 |
] ifFalse:[ |
|
3139 |
leftRest := line |
|
3140 |
] |
|
3141 |
]. |
|
3142 |
leftRest notNil ifTrue:[ |
|
3143 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
|
3144 |
]. |
|
3145 |
list at:lineNr put:leftRest. |
|
3146 |
self nonUndoableDo:[ |
|
3147 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
|
3148 |
]. |
|
3149 |
visLine := self listLineToVisibleLine:(lineNr). |
|
3150 |
visLine notNil ifTrue:[ |
|
3151 |
w := self widthForScrollBetween:lineNr |
|
3152 |
and:(firstLineShown + nLinesShown). |
|
3153 |
srcY := topMargin + (visLine * fontHeight). |
|
3154 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
3155 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
3156 |
self catchExpose. |
|
3157 |
self |
|
3158 |
copyFrom:self |
|
3159 |
x:textStartLeft y:srcY |
|
3160 |
toX:textStartLeft y:(srcY + fontHeight) |
|
3161 |
width:w |
|
3162 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
3163 |
async:true. |
|
3164 |
]. |
|
3165 |
self redrawLine:lineNr. |
|
3166 |
self redrawLine:(lineNr + 1). |
|
3167 |
mustWait ifTrue:[self waitForExpose] |
|
3168 |
]. |
|
3169 |
widthOfWidestLine := nil. "/ unknown |
|
3170 |
self textChanged. |
|
3171 |
] |
|
3172 |
] |
|
3173 |
||
3174 |
"Modified: 29.1.1997 / 13:03:22 / cg" |
|
3175 |
! |
|
3176 |
||
3177 |
basicWithoutRedrawInsertLine:aString before:lineNr |
|
3178 |
"insert the argument, aString before line lineNr; the string |
|
3179 |
becomes line nileNr; everything else is moved down; the view |
|
3180 |
is not redrawn" |
|
3181 |
||
3182 |
|line| |
|
3183 |
||
3184 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3185 |
||
3186 |
line := aString. |
|
3187 |
line notNil ifTrue:[ |
|
3188 |
line isString ifTrue:[ |
|
3189 |
line isBlank ifTrue:[ |
|
3190 |
line := nil |
|
3191 |
] ifFalse:[ |
|
3192 |
(line includes:(Character tab)) ifTrue:[ |
|
3193 |
line := self withTabsExpanded:line |
|
3194 |
] |
|
3195 |
] |
|
3196 |
] |
|
3197 |
]. |
|
3198 |
list isNil ifTrue: [ |
|
3199 |
list := StringCollection new:lineNr |
|
3200 |
] ifFalse: [ |
|
3201 |
list grow:((list size + 1) max:lineNr) |
|
3202 |
]. |
|
3203 |
||
3204 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
3205 |
overlapping copy - if it didn't, we had to use:" |
|
3206 |
" |
|
3207 |
index := list size. |
|
3208 |
[index > lineNr] whileTrue: [ |
|
3209 |
pIndex := index - 1. |
|
3210 |
list at:index put:(list at:pIndex). |
|
3211 |
index := pIndex |
|
3212 |
]. |
|
3213 |
" |
|
3214 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
|
3215 |
list at:lineNr put:line. |
|
3216 |
self contentsChanged |
|
3217 |
||
3218 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
|
3219 |
! |
|
3220 |
||
2954 | 3221 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
3222 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3223 |
||
3224 |
|newLine newLines nLines| |
|
3225 |
||
3226 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3227 |
||
3228 |
nLines := end - start + 1. |
|
3229 |
newLines := Array new:(lines size). |
|
3230 |
start to:end do:[:index | |
|
3231 |
newLine := lines at:index. |
|
3232 |
newLine notNil ifTrue:[ |
|
3233 |
newLine isString ifTrue:[ |
|
3234 |
newLine isBlank ifTrue:[ |
|
3235 |
newLine := nil |
|
3236 |
] ifFalse:[ |
|
3237 |
(newLine includes:(Character tab)) ifTrue:[ |
|
3238 |
newLine := self withTabsExpanded:newLine |
|
3239 |
] |
|
3240 |
] |
|
3241 |
] |
|
3242 |
]. |
|
3243 |
newLines at:index put:newLine |
|
3244 |
]. |
|
3245 |
list isNil ifTrue: [ |
|
3246 |
list := StringCollection new:(lineNr + nLines + 1) |
|
3247 |
] ifFalse: [ |
|
3248 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
|
3249 |
]. |
|
3250 |
||
3251 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
3252 |
overlapping copy - if it didn't, we had to use:" |
|
3253 |
" |
|
3254 |
index := list size. |
|
3255 |
[index > lineNr] whileTrue: [ |
|
3256 |
pIndex := index - 1. |
|
3257 |
list at:index put:(list at:pIndex). |
|
3258 |
index := pIndex |
|
3259 |
]. |
|
3260 |
" |
|
3261 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
3262 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
3263 |
self contentsChanged |
|
3264 |
||
3265 |
"Modified: / 10.6.1998 / 19:01:16 / cg" |
|
3266 |
! |
|
3267 |
||
3268 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3269 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3270 |
||
3271 |
|isText strLen line lineSize newLine stringType sz| |
|
3272 |
||
3273 |
(aString notNil) ifFalse:[ ^ self]. |
|
3274 |
||
3275 |
strLen := aString size. |
|
3276 |
self checkForExistingLine:lineNr. |
|
3277 |
||
3278 |
stringType := aString string species. |
|
3279 |
isText := aString isText. |
|
3280 |
line := list at:lineNr. |
|
3281 |
||
3282 |
line notNil ifTrue:[ |
|
3283 |
lineSize := line size. |
|
3284 |
line isString ifFalse:[ |
|
3285 |
stringType := line species |
|
3286 |
] ifTrue:[ |
|
3287 |
line bitsPerCharacter > aString bitsPerCharacter ifTrue:[ |
|
3288 |
stringType := line string species |
|
3289 |
]. |
|
3290 |
line isText ifTrue:[ isText := true ] |
|
3291 |
]. |
|
3292 |
] ifFalse:[ |
|
3293 |
lineSize := 0 |
|
3294 |
]. |
|
3295 |
||
3296 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
3297 |
newLine := aString |
|
3298 |
] ifFalse:[ |
|
3299 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
|
3300 |
sz := colNr + strLen - 1 |
|
3301 |
] ifFalse:[ |
|
3302 |
sz := lineSize + strLen |
|
3303 |
]. |
|
3304 |
||
3305 |
isText ifFalse:[ |
|
3306 |
newLine := stringType new:sz |
|
3307 |
] ifTrue:[ |
|
3308 |
newLine := Text string:(stringType new:sz) |
|
3309 |
]. |
|
3310 |
||
3311 |
(lineSize ~~ 0) ifTrue: [ |
|
3312 |
(colNr > lineSize) ifTrue: [ |
|
3313 |
newLine replaceFrom:1 to:lineSize |
|
3314 |
with:line startingAt:1 |
|
3315 |
] ifFalse: [ |
|
3316 |
newLine replaceFrom:1 to:(colNr - 1) |
|
3317 |
with:line startingAt:1. |
|
3318 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) |
|
3319 |
with:line startingAt:colNr |
|
3320 |
] |
|
3321 |
]. |
|
3322 |
newLine replaceFrom:colNr to:(colNr + strLen - 1) with:aString startingAt:1 |
|
3323 |
]. |
|
3324 |
||
3325 |
(aString includes:(Character tab)) ifTrue:[ |
|
3326 |
newLine := self withTabsExpanded:newLine |
|
3327 |
]. |
|
3328 |
||
3329 |
list at:lineNr put:newLine. |
|
3330 |
widthOfWidestLine notNil ifTrue:[ |
|
3331 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
|
3332 |
]. |
|
3333 |
self textChanged. |
|
3334 |
||
3335 |
"Modified: / 10.6.1998 / 19:01:52 / cg" |
|
3336 |
! |
|
3337 |
||
2952 | 3338 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3339 |
"delete characters from startCol to endCol in line lineNr |
|
3340 |
" |
|
3341 |
|deleted| |
|
3342 |
||
3343 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3344 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3345 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted ). |
|
3346 |
! |
|
3347 |
||
3348 |
deleteFromLine:startLineNr toLine:endLineNr |
|
3349 |
"delete some lines" |
|
3350 |
||
3351 |
|deleted| |
|
3352 |
||
3353 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3354 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3355 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted ). |
|
3356 |
! |
|
3357 |
||
3358 |
deleteLineWithoutRedraw:lineNr |
|
3359 |
"delete line - no redraw; |
|
3360 |
return true, if something was really deleted" |
|
3361 |
||
3362 |
|deleted ret| |
|
3363 |
||
3364 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3365 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3366 |
self addUndo:(PasteString line:lineNr col:1 string:deleted ). |
|
3367 |
^ ret. |
|
3368 |
! |
|
3369 |
||
3370 |
insert:aCharacter atLine:lineNr col:colNr |
|
3371 |
"insert a single character at lineNr/colNr; |
|
3372 |
set emphasis to character at current position" |
|
3373 |
||
3374 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3375 |
aCharacter ~~ Character cr ifTrue:[ |
|
3376 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr). |
|
3377 |
] |
|
3378 |
! |
|
3379 |
||
3380 |
insertLines:someText from:start to:end before:lineNr |
|
3381 |
"insert a bunch of lines before line lineNr" |
|
3382 |
||
2954 | 3383 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
3384 |
srcY "{ Class: SmallInteger }" |
|
3385 |
dstY "{ Class: SmallInteger }" | |
|
3386 |
||
3387 |
self isReadOnly ifTrue:[ |
|
3388 |
^ self |
|
3389 |
]. |
|
3390 |
||
3391 |
autoIndent ifTrue:[ |
|
3392 |
indent := self leftIndentForLine:lineNr. |
|
3393 |
||
3394 |
text := someText collect:[:ln||line| |
|
3395 |
ln notNil ifTrue:[ |
|
3396 |
line := ln withoutLeadingSeparators. |
|
3397 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3398 |
line := (String new:indent), line |
|
3399 |
]. |
|
3400 |
line |
|
3401 |
] ifFalse:[ |
|
3402 |
nil |
|
3403 |
] |
|
3404 |
]. |
|
3405 |
] ifFalse:[ |
|
3406 |
text := someText |
|
3407 |
]. |
|
3408 |
||
3409 |
visLine := self listLineToVisibleLine:lineNr. |
|
3410 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3411 |
self withoutRedrawInsertLines:text |
|
3412 |
from:start to:end |
|
3413 |
before:lineNr. |
|
3414 |
] ifFalse:[ |
|
3415 |
nLines := end - start + 1. |
|
3416 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3417 |
self withoutRedrawInsertLines:text |
|
3418 |
from:start to:end |
|
3419 |
before:lineNr. |
|
3420 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3421 |
] ifFalse:[ |
|
3422 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3423 |
and:(firstLineShown + nLines + nLinesShown). |
|
3424 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3425 |
dstY := srcY + (nLines * fontHeight). |
|
3426 |
||
3427 |
"/ |
|
3428 |
"/ scroll ... |
|
3429 |
"/ |
|
3430 |
" |
|
3431 |
stupid: must catchExpose before inserting new |
|
3432 |
stuff - since catchExpose may perform redraws |
|
3433 |
" |
|
3434 |
self catchExpose. |
|
3435 |
self withoutRedrawInsertLines:text |
|
3436 |
from:start to:end |
|
3437 |
before:lineNr. |
|
3438 |
self |
|
3439 |
copyFrom:self |
|
3440 |
x:textStartLeft y:srcY |
|
3441 |
toX:textStartLeft y:dstY |
|
3442 |
width:w |
|
3443 |
height:(height - dstY) |
|
3444 |
async:true. |
|
3445 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3446 |
self waitForExpose |
|
3447 |
]. |
|
3448 |
]. |
|
3449 |
widthOfWidestLine notNil ifTrue:[ |
|
3450 |
text do:[:line | |
|
3451 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3452 |
] |
|
3453 |
]. |
|
3454 |
self textChanged. |
|
3455 |
||
3456 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
2952 | 3457 |
! |
3458 |
||
3459 |
mergeLine:lineNr removeBlanks:removeBlanks |
|
3460 |
"merge line lineNr with line lineNr+1" |
|
3461 |
||
3462 |
|len| |
|
3463 |
||
3464 |
len := (self listAt:lineNr) size. |
|
3465 |
self nonUndoableDo:[ |
|
3466 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
|
3467 |
]. |
|
3468 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3469 |
! |
|
3470 |
||
3471 |
replace:aCharacter atLine:lineNr col:colNr |
|
3472 |
"replace a single character at lineNr/colNr" |
|
3473 |
||
3474 |
|originalChar| |
|
3475 |
||
3476 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3477 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3478 |
self addUndo:(ReplaceCharacter line:lineNr col:colNr character:originalChar). |
|
3479 |
! |
|
3480 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3481 |
replaceString:aString atLine:lineNr col:colNr |
1557 | 3482 |
"replace multiple characters starting at lineNr/colNr. |
1567
0eff7ca88e89
much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents:
1566
diff
changeset
|
3483 |
This is not prepared to encounter special chars (except TAB) |
0eff7ca88e89
much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents:
1566
diff
changeset
|
3484 |
in the string." |
1557 | 3485 |
|
3486 |
|line lineSize newLine endCol| |
|
3487 |
||
3488 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3489 |
||
3490 |
self checkForExistingLine:lineNr. |
|
3491 |
line := list at:lineNr. |
|
3492 |
lineSize := line size. |
|
3493 |
||
3494 |
endCol := colNr + aString size - 1. |
|
3495 |
(lineSize == 0) ifTrue:[ |
|
2357 | 3496 |
newLine := aString species new:endCol. |
1557 | 3497 |
] ifFalse: [ |
2357 | 3498 |
(endCol > lineSize) ifTrue: [ |
3499 |
aString isText ifTrue:[ |
|
3500 |
newLine := aString species new:endCol. |
|
3501 |
] ifFalse:[ |
|
3502 |
newLine := line species new:endCol. |
|
3503 |
]. |
|
3504 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3505 |
] ifFalse: [ |
|
3506 |
aString isText ifTrue:[ |
|
3507 |
newLine := aString species new:line size. |
|
3508 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3509 |
] ifFalse:[ |
|
3510 |
newLine := line copy. |
|
3511 |
] |
|
3512 |
] |
|
1557 | 3513 |
]. |
3514 |
newLine replaceFrom:colNr with:aString. |
|
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3515 |
(aString includes:(Character tab)) ifTrue:[ |
2357 | 3516 |
newLine := self withTabsExpanded:newLine. |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3517 |
]. |
1557 | 3518 |
list at:lineNr put:newLine. |
3519 |
widthOfWidestLine notNil ifTrue:[ |
|
2357 | 3520 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
1557 | 3521 |
]. |
3522 |
self textChanged. |
|
3523 |
shown ifTrue:[ |
|
2357 | 3524 |
self redrawLine:lineNr from:colNr |
1557 | 3525 |
] |
3526 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3527 |
"Created: / 11.6.1998 / 10:38:32 / cg" |
1599
63636b356b1f
care for emphasis when replacing.
Claus Gittinger <cg@exept.de>
parents:
1597
diff
changeset
|
3528 |
"Modified: / 20.6.1998 / 20:23:50 / cg" |
1557 | 3529 |
! |
3530 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3531 |
splitLine:lineNr before:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3532 |
"split the line linNr before colNr; the right part (from colNr) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3533 |
is cut off and inserted after lineNr; the view is redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3534 |
|
2952 | 3535 |
self basicSplitLine:lineNr before:colNr. |
3536 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0). |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3537 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3539 |
withoutRedrawInsertLine:aString before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3540 |
"insert the argument, aString before line lineNr; the string |
2954 | 3541 |
becomes line lineNr; everything else is moved down; the view |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3542 |
is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3543 |
|
2952 | 3544 |
self basicWithoutRedrawInsertLine:aString before:lineNr. |
3545 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0). |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3546 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3547 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3548 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3549 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3550 |
|
2954 | 3551 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
3552 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0). |
|
121 | 3553 |
! |
3554 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3555 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3556 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3557 |
|
2954 | 3558 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
3559 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1). |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3560 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3561 |
|
2752 | 3562 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3563 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3564 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3565 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3567 |
hasKeyboardFocus := true. |
2589 | 3568 |
dragIsActive := false. |
3569 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3570 |
cursorShown ifTrue: [ |
2357 | 3571 |
self drawCursor |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3572 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3573 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3574 |
((button == 1) or:[button == #select]) ifTrue:[ |
2357 | 3575 |
self hideCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3576 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3577 |
(button == #paste) ifTrue:[ |
2357 | 3578 |
self pasteOrReplace. |
3579 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3580 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3581 |
super buttonPress:button x:x y:y |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3582 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3583 |
"Modified: / 23.3.1999 / 13:51:40 / cg" |
121 | 3584 |
! |
3585 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3586 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3587 |
"move the cursor to the click-position of previous button press" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3588 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3589 |
((button == 1) or:[button == #select]) ifTrue:[ |
2589 | 3590 |
typeOfSelection := nil. |
3591 |
||
3592 |
dragIsActive ifTrue:[ |
|
3593 |
self unselect |
|
3594 |
]. |
|
2357 | 3595 |
selectionStartLine isNil ifTrue:[ |
3596 |
clickCol notNil ifTrue:[ |
|
3597 |
self cursorMovementAllowed ifTrue:[ |
|
3598 |
self cursorLine:clickLine col:clickCol |
|
3599 |
] |
|
3600 |
] |
|
3601 |
] ifFalse:[ |
|
3602 |
lastString := nil. "new selection invalidates remembered string" |
|
3603 |
]. |
|
3604 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3605 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3606 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3607 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3608 |
"Modified: / 18.6.1998 / 14:14:05 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3609 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3610 |
|
2580 | 3611 |
cursorKeyPress:key shifted:shifted |
3612 |
||
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3613 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3614 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
3615 |
self changeTypeOfSelectionTo:nil. |
2580 | 3616 |
|
3617 |
(key == #CursorRight) ifTrue:[ |
|
3618 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3619 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3620 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
3621 |
expandingTop := false. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3622 |
self validateNewSelection. |
2580 | 3623 |
self redrawLine:selectionStartLine. |
3624 |
^ self. |
|
3625 |
]. |
|
3626 |
||
3627 |
selectionStartLine notNil ifTrue:[ |
|
3628 |
self cursorMovementAllowed ifTrue:[ |
|
3629 |
"/ |
|
3630 |
"/ treat the whole selection as cursor |
|
3631 |
"/ |
|
3632 |
self setCursorLine:selectionEndLine. |
|
3633 |
selectionEndCol == 0 ifTrue:[ |
|
3634 |
selectionEndCol := 1. |
|
3635 |
]. |
|
3636 |
self setCursorCol:selectionEndCol. |
|
3637 |
shifted ifTrue:[ |
|
3638 |
self expandSelectionRight. |
|
3639 |
^ self |
|
3640 |
]. |
|
3641 |
self unselect; makeCursorVisible. |
|
3642 |
cursorCol == 1 ifTrue:[^ self]. |
|
3643 |
]. |
|
3644 |
]. |
|
3645 |
self cursorRight. |
|
3646 |
^ self |
|
3647 |
]. |
|
3648 |
(key == #CursorDown) ifTrue:[ |
|
3649 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3650 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
3651 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3652 |
self validateNewSelection. |
2580 | 3653 |
self redrawLine:selectionStartLine. |
3654 |
expandingTop := false. |
|
3655 |
self redrawLine:selectionEndLine. |
|
3656 |
^ self |
|
3657 |
]. |
|
3658 |
||
3659 |
selectionStartLine notNil ifTrue:[ |
|
3660 |
self cursorMovementAllowed ifTrue:[ |
|
3661 |
"/ |
|
3662 |
"/ treat the whole selection as cursor |
|
3663 |
"/ |
|
3664 |
self setCursorLine:selectionEndLine. |
|
3665 |
self setCursorCol:selectionStartCol. |
|
3666 |
cursorCol == 0 ifTrue:[ |
|
3667 |
self setCursorCol:1. |
|
3668 |
self setCursorLine:(cursorLine - 1). |
|
3669 |
]. |
|
3670 |
self makeCursorVisible. |
|
3671 |
||
3672 |
shifted ifTrue:[ |
|
3673 |
clickLine := cursorLine. |
|
3674 |
clickCol := cursorCol. |
|
3675 |
self expandSelectionDown. |
|
3676 |
^ self |
|
3677 |
]. |
|
3678 |
self unselect. |
|
3679 |
]. |
|
3680 |
]. |
|
3681 |
||
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3682 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
2580 | 3683 |
self cursorDown:n. |
3684 |
"/ |
|
3685 |
"/ flush keyboard to avoid runaway cursor |
|
3686 |
"/ |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3687 |
self sensor flushKeyboardFor:self. |
2580 | 3688 |
^ self |
3689 |
]. |
|
3690 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
3691 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3692 |
expandingTop := true. |
|
3693 |
key == #CursorLeft ifTrue:[ |
|
3694 |
cursorCol > 1 ifTrue:[ |
|
3695 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3696 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
3697 |
selectionStartCol := cursorCol-1. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3698 |
self validateNewSelection. |
2580 | 3699 |
self redrawLine:selectionStartLine. |
3700 |
^ self |
|
3701 |
] |
|
3702 |
] ifFalse:[ |
|
3703 |
cursorLine > 1 ifTrue:[ |
|
3704 |
selectionEndLine := clickStartLine := cursorLine. |
|
3705 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
3706 |
selectionStartLine := cursorLine - 1. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3707 |
self validateNewSelection. |
2580 | 3708 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3709 |
^ self |
|
3710 |
] |
|
3711 |
] |
|
3712 |
]. |
|
3713 |
||
3714 |
selectionStartLine notNil ifTrue:[ |
|
3715 |
self cursorMovementAllowed ifTrue:[ |
|
3716 |
"/ |
|
3717 |
"/ treat the whole selection as cursor |
|
3718 |
"/ |
|
3719 |
self setCursorLine:selectionStartLine. |
|
3720 |
self setCursorCol:selectionStartCol. |
|
3721 |
(key == #CursorLeft) ifTrue:[ |
|
3722 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
3723 |
]. |
|
3724 |
self makeCursorVisible. |
|
3725 |
||
3726 |
shifted ifTrue:[ |
|
3727 |
(key == #CursorUp) ifTrue:[ |
|
3728 |
clickLine := cursorLine. |
|
3729 |
self expandSelectionUp. |
|
3730 |
] ifFalse:[ |
|
3731 |
self expandSelectionLeft. |
|
3732 |
]. |
|
3733 |
^ self |
|
3734 |
]. |
|
3735 |
self unselect. |
|
3736 |
]. |
|
3737 |
]. |
|
3738 |
(key == #CursorLeft) ifTrue:[ |
|
3739 |
self cursorLeft. ^self |
|
3740 |
]. |
|
3741 |
(key == #CursorUp) ifTrue:[ |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3742 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
2580 | 3743 |
self cursorUp:n. |
3744 |
"/ |
|
3745 |
"/ flush keyboard to avoid runaway cursor |
|
3746 |
"/ |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3747 |
self sensor flushKeyboardFor:self. |
2580 | 3748 |
^ self |
3749 |
]. |
|
3750 |
]. |
|
3751 |
! |
|
3752 |
||
2952 | 3753 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3754 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3755 |
|
2978 | 3756 |
<resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept |
2017 | 3757 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3758 |
#SelectWord #DeleteSpaces |
2017 | 3759 |
#SearchMatchingParent #SelectMatchingParents |
3760 |
#SelectToEnd #SelectFromBeginning |
|
3761 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
3762 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3763 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
2017 | 3764 |
#GotoLine #Delete #BeginOfText #EndOfText |
3765 |
#SelectLine #ExpandSelectionByLine #DeleteLine |
|
3766 |
#InsertLine |
|
3767 |
#SelectLineFromBeginning |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3768 |
#LearnKeyboardMacro #ExecuteKeyboardMacro |
2017 | 3769 |
#'F*' #'f*')> |
3770 |
||
2720 | 3771 |
|fKeyMacros shifted i event cmdMacro| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3772 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3773 |
event := WindowGroup lastEventQuerySignal query. |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3774 |
shifted := event hasShift. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3775 |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3776 |
cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3777 |
cmdMacro notNil ifTrue:[ |
2720 | 3778 |
self executeKeyboardMacro:cmdMacro. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3779 |
^ self |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3780 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3781 |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3782 |
(key == #BackSpace |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3783 |
or:[key == #BasicBackspace]) ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3784 |
selectionStartLine notNil ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3785 |
(key == #BasicBackspace) ifTrue:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3786 |
self deleteSelection. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3787 |
] ifFalse: [ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3788 |
self copyAndDeleteSelection. |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3789 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3790 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3791 |
]. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3792 |
|
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3793 |
self makeCursorVisible. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3794 |
shifted ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3795 |
self deleteWordBeforeCursor. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3796 |
] ifFalse:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3797 |
self deleteCharBeforeCursor. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3798 |
]. |
2207 | 3799 |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3800 |
^ self |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3801 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3802 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3803 |
(key == #LearnKeyboardMacro) ifTrue:[ |
2580 | 3804 |
self toggleLearnMode. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3805 |
^ self |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3806 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3807 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
2580 | 3808 |
self executeLearnedKeyboardMacro. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3809 |
^ self. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3810 |
]. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
3811 |
self learnMode ifTrue:[ |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3812 |
learnedMacro add:event. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3813 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3814 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3815 |
(key isMemberOf:Character) ifTrue:[ |
2720 | 3816 |
self handleNonCommandKey:key. |
2017 | 3817 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3818 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3819 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3820 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3821 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3822 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3823 |
Fn pastes a key-sequence (but only if not overlayed with |
2017 | 3824 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3825 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3826 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3827 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
3828 |
(key at:1) asLowercase == $f ifTrue:[ |
2017 | 3829 |
(('[fF][0-9]' match:key) |
3830 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
3831 |
shifted ifFalse:[ |
|
3832 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
3833 |
fKeyMacros notNil ifTrue:[ |
|
3834 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
3835 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
3836 |
^ self |
|
3837 |
] |
|
3838 |
] |
|
3839 |
] |
|
3840 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3841 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3842 |
|
2506 | 3843 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3844 |
self parenthizeSelectionWith:$( and:$). |
|
3845 |
^ self. |
|
3846 |
]. |
|
3847 |
(key == #'Ctrl2') ifTrue:[ |
|
3848 |
self parenthizeSelectionWith:$" and:$". |
|
3849 |
^ self. |
|
3850 |
]. |
|
3851 |
(key == #'Ctrl#') ifTrue:[ |
|
3852 |
self parenthizeSelectionWith:$' and:$'. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3853 |
^ self. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3854 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3855 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
3856 |
(key == #Accept) ifTrue:[^ self accept]. |
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
3857 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3858 |
((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3859 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3860 |
(key == #Again) ifTrue:[self again. ^self]. |
2978 | 3861 |
(key == #Undo) ifTrue:[self undo. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3862 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3863 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3864 |
(key == #SelectWord) ifTrue:[ |
2017 | 3865 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3866 |
self selectWordUnderCursor. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3867 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3868 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3869 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3870 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3871 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3872 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3873 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3874 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3875 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3876 |
and if you like it, its better done in the keymap. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3877 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
3878 |
(key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
3879 |
(key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
3880 |
(key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
3881 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3882 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3883 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3884 |
(key == #BeginOfLine) ifTrue:[ |
2017 | 3885 |
self unselect. |
3886 |
shifted ifTrue:[ |
|
3887 |
self cursorHome |
|
3888 |
] ifFalse:[ |
|
3889 |
self cursorToBeginOfLine. |
|
3890 |
]. |
|
3891 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3892 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3893 |
(key == #EndOfLine) ifTrue:[ |
2017 | 3894 |
self unselect. |
3895 |
shifted ifTrue:[ |
|
3896 |
self cursorToBottom |
|
3897 |
] ifFalse:[ |
|
3898 |
self cursorToEndOfLine. |
|
3899 |
]. |
|
3900 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3901 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3902 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
499 | 3903 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3904 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3905 |
|
2580 | 3906 |
(key == #CursorRight |
3907 |
or:[key == #CursorDown |
|
3908 |
or:[key == #CursorLeft |
|
3909 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3910 |
self cursorKeyPress:key shifted:shifted. |
|
3911 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3912 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3913 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3914 |
(key == #Return) ifTrue:[ |
2017 | 3915 |
shifted ifTrue:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3916 |
self unselect. self cursorReturn. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3917 |
^ self |
2017 | 3918 |
]. |
3919 |
self isReadOnly ifTrue:[ |
|
3920 |
self unselect; makeCursorVisible. |
|
3921 |
self cursorReturn |
|
3922 |
] ifFalse:[ |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
3923 |
insertMode value ifFalse:[ |
2017 | 3924 |
self cursorReturn. |
3925 |
autoIndent == true ifTrue:[ |
|
3926 |
i := self leftIndentForLine:(cursorLine + 1). |
|
3927 |
self cursorCol:(i+1 max:1) |
|
3928 |
] |
|
3929 |
] ifTrue:[ |
|
3930 |
"/ old version just unselected ... |
|
3931 |
"/ self unselect; makeCursorVisible. |
|
3932 |
||
3933 |
"/ new version deletes ... |
|
3934 |
typeOfSelection == #paste ifTrue:[ |
|
3935 |
self unselect; makeCursorVisible. |
|
3936 |
] ifFalse:[ |
|
3937 |
self copyAndDeleteSelection. |
|
3938 |
]. |
|
3939 |
self insertCharAtCursor:(Character cr). |
|
3940 |
autoIndent == true ifTrue:[ |
|
3941 |
i := self leftIndentForLine:cursorLine. |
|
3942 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
3943 |
self cursorCol:(i+1 max:1) |
|
3944 |
]. |
|
3945 |
]. |
|
3946 |
]. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3947 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
3949 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3950 |
(key == #NonInsertingTab) ifTrue:[ |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3951 |
self unselect. self cursorTab. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3952 |
^ self |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3953 |
]. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3954 |
(key == #BackTab) ifTrue:[ |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3955 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3956 |
self unselect. self cursorBacktab. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3957 |
^ self |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3958 |
]. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
3959 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3960 |
(key == #Tab) ifTrue:[ |
2017 | 3961 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
3962 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
3963 |
insertMode value ifFalse:[ |
2017 | 3964 |
self unselect. self cursorTab. ^self |
3965 |
]. |
|
3966 |
self unselect. self insertTabAtCursor. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3967 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3968 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
3969 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3970 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3971 |
(key == #Delete) ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3972 |
shifted ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3973 |
[(cursorCol <= (self listAt:cursorLine) size) |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3974 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3975 |
self makeCursorVisible. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3976 |
self deleteCharAtCursor. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3977 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3978 |
^ self |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3979 |
] |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3980 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
3981 |
|
870 | 3982 |
(key == #Delete |
3983 |
or:[key == #BasicDelete]) ifTrue:[ |
|
2017 | 3984 |
selectionStartLine notNil ifTrue:[ |
3985 |
(key == #BasicDelete) ifTrue:[ |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3986 |
self deleteSelection. |
2017 | 3987 |
] ifFalse:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3988 |
self copyAndDeleteSelection. |
2017 | 3989 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3990 |
^ self |
2017 | 3991 |
]. |
3992 |
self makeCursorVisible. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3993 |
self deleteCharAtCursor. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3994 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3995 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
3996 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3997 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
2017 | 3998 |
self unselect. |
3999 |
cursorVisibleLine == 1 ifTrue:[ |
|
4000 |
self cursorHome. |
|
4001 |
] ifFalse:[ |
|
4002 |
self cursorToFirstVisibleLine |
|
4003 |
]. |
|
4004 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4005 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4006 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
2017 | 4007 |
self unselect. |
4008 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
4009 |
self cursorToBottom. |
|
4010 |
] ifFalse:[ |
|
4011 |
self cursorToLastVisibleLine |
|
4012 |
]. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4013 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4014 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4015 |
((key == #Escape) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4016 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
2017 | 4017 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4018 |
self unselect. self selectCursorLineFromBeginning. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4019 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
(key == #SelectLine) ifTrue:[ |
2017 | 4022 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4023 |
self unselect. self selectCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4024 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4025 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4026 |
(key == #ExpandSelectionByLine) ifTrue:[ |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4027 |
"/ self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4028 |
self selectExpandCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4029 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4030 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4031 |
(key == #DeleteLine) ifTrue:[ |
2017 | 4032 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4033 |
self unselect. self deleteCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4034 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4035 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4036 |
(key == #InsertLine) ifTrue:[ |
2017 | 4037 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4038 |
self unselect. self insertLine:nil before:cursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4039 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4040 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4041 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4042 |
|
1446
609e20a4a234
Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents:
1439
diff
changeset
|
4043 |
"Modified: / 6.2.1998 / 11:59:59 / stefan" |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4044 |
"Modified: / 22.2.2000 / 23:01:23 / cg" |
121 | 4045 |
! |
4046 |
||
2952 | 4047 |
executeKeyboardMacro:cmdMacro |
4048 |
Error handle:[:ex | |
|
4049 |
self warn:'Error in keyboard macro: ' , ex description. |
|
4050 |
ex return. |
|
4051 |
] do:[ |
|
4052 |
AbortSignal handle:[:ex | |
|
4053 |
self warn:'Keyboard macro aborted'. |
|
4054 |
ex return. |
|
4055 |
] do:[ |
|
4056 |
Parser |
|
4057 |
evaluate:cmdMacro asString |
|
4058 |
receiver:self |
|
4059 |
notifying:nil |
|
4060 |
compile:false. |
|
4061 |
]. |
|
4062 |
]. |
|
4063 |
! |
|
4064 |
||
4065 |
handleNonCommandKey:keyArg |
|
4066 |
|selStartLine selStartCol selEndLine selEndCol sel key| |
|
4067 |
||
4068 |
self isReadOnly ifTrue:[ |
|
4069 |
self flash. |
|
4070 |
^ self. |
|
4071 |
]. |
|
4072 |
||
4073 |
key := keyArg. |
|
4074 |
||
4075 |
typeOfSelection == #paste ifTrue:[ |
|
4076 |
"pasted selection will NOT be replaced by keystroke" |
|
4077 |
self unselect |
|
4078 |
]. |
|
4079 |
||
4080 |
selStartLine := selectionStartLine. |
|
4081 |
selStartCol := self selectionStartCol. |
|
4082 |
selEndLine := selectionEndLine. |
|
4083 |
selEndCol := self selectionEndCol. |
|
4084 |
sel := self selection. |
|
4085 |
||
4086 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
|
4087 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
|
4088 |
]. |
|
4089 |
||
4090 |
"replace selection by what is typed in - |
|
4091 |
if word was selected with a space, keep it" |
|
4092 |
||
4093 |
(selectStyle == #wordLeft) ifTrue:[ |
|
4094 |
self replaceSelectionBy:(' ' , key asString) |
|
4095 |
] ifFalse:[ |
|
4096 |
(selectStyle == #wordRight) ifTrue:[ |
|
4097 |
self replaceSelectionBy:(key asString , ' '). |
|
4098 |
self cursorLeft |
|
4099 |
] ifFalse:[ |
|
4100 |
self replaceSelectionBy:key |
|
4101 |
] |
|
4102 |
]. |
|
4103 |
selectStyle := nil. |
|
4104 |
||
4105 |
showMatchingParenthesis ifTrue:[ |
|
4106 |
"emacs style parenthesis shower" |
|
4107 |
||
4108 |
"claus: only do it for closing parenthesis - |
|
4109 |
otherwise its too anoying. |
|
4110 |
" |
|
4111 |
" |
|
4112 |
(#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[ |
|
4113 |
" |
|
4114 |
(#( $) $] $} ) includes:key) ifTrue:[ |
|
4115 |
self |
|
4116 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
4117 |
ifFound:[:line :col | |
|
4118 |
|savLine savCol sensor| |
|
4119 |
||
4120 |
self withCursor:Cursor eye do:[ |
|
4121 |
savLine := cursorLine. |
|
4122 |
savCol := cursorCol. |
|
4123 |
self cursorLine:line col:col. |
|
4124 |
device flush. |
|
4125 |
||
4126 |
"/ want to wait 200ms, but not if another keyPress |
|
4127 |
"/ arrives in the meantime ... |
|
4128 |
||
4129 |
sensor := self sensor. |
|
4130 |
5 timesRepeat:[ |
|
4131 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
4132 |
Processor activeProcess millisecondDelay:40. |
|
4133 |
] |
|
4134 |
]. |
|
4135 |
self cursorLine:savLine col:savCol |
|
4136 |
] |
|
4137 |
] |
|
4138 |
ifNotFound:[self showNotFound] |
|
4139 |
onError:[self beep] |
|
4140 |
]. |
|
4141 |
]. |
|
4142 |
||
4143 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
4144 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
4145 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
4146 |
"/ |
|
4147 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4148 |
"/ self selection. |
|
4149 |
"/ typeOfSelection := #paste. |
|
4150 |
"/ ]. |
|
4151 |
"/ ]. |
|
4152 |
! |
|
4153 |
||
4154 |
keyPress:key x:x y:y |
|
4155 |
"handle keyboard input" |
|
4156 |
||
4157 |
self undoableDo:[ |
|
4158 |
self doKeyPress:key x:x y:y |
|
4159 |
]. |
|
4160 |
! |
|
4161 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4162 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4163 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4165 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4166 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4167 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4168 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4169 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4170 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4171 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4172 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4173 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4174 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4175 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4176 |
cv notNil ifTrue:[ |
2357 | 4177 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4178 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4179 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4180 |
|
1807 | 4181 |
!EditTextView methodsFor:'focus handling'! |
4182 |
||
4183 |
hasKeyboardFocus:aBoolean |
|
4184 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
4185 |
(otherwise, I would not know about this)" |
|
4186 |
||
4187 |
hasKeyboardFocus := aBoolean. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4188 |
(cursorShown |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4189 |
and:[self enabled |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
4190 |
and:[readOnly value not]]) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
4191 |
self drawCursor |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4192 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4193 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4194 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 4195 |
! |
4196 |
||
4197 |
showFocus:explicit |
|
4198 |
"in addition to however my superclass thinks how a focusView is to be |
|
4199 |
displayed, show the cursor when I got the focus" |
|
4200 |
||
4201 |
self showCursor. |
|
4202 |
self hasKeyboardFocus:true. |
|
4203 |
super showFocus:explicit |
|
4204 |
||
4205 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4206 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4207 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4208 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4209 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4210 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4211 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4212 |
|pref| |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4213 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4214 |
pref := UserPreferences current focusFollowsMouse. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4215 |
(pref ~~ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4216 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4217 |
and:[self enabled |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4218 |
and:[readOnly not]]]) ifTrue:[ |
2357 | 4219 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4220 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4221 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4222 |
^ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4223 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4224 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4225 |
|
1807 | 4226 |
! ! |
4227 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4228 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4229 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4230 |
indent |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4231 |
"indent selected line-range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4232 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4233 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4234 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4235 |
selectionStartLine isNil ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4236 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4237 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4238 |
(selectionEndCol == 0) ifTrue:[ |
2357 | 4239 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4240 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4241 |
self unselect. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4242 |
self indentFromLine:start toLine:end |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4243 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4245 |
indentFromLine:start toLine:end |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4246 |
"indent a line-range - this is don by searching for the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4247 |
last non-empty line before start, and change the indent |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4248 |
of the line based on that indent." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4249 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4250 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4251 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4252 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4253 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4254 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4255 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4256 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4257 |
(delta > 0) ifTrue:[ |
2357 | 4258 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4259 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4260 |
start to:end do:[:lineNr | |
2357 | 4261 |
line := self listAt:lineNr. |
4262 |
line notNil ifTrue:[ |
|
4263 |
line isBlank ifTrue:[ |
|
4264 |
list at:lineNr put:nil |
|
4265 |
] ifFalse:[ |
|
4266 |
(delta > 0) ifTrue:[ |
|
4267 |
line := spaces , line. |
|
4268 |
widthOfWidestLine notNil ifTrue:[ |
|
4269 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4270 |
] |
|
4271 |
] ifFalse:[ |
|
4272 |
"check if deletion is ok" |
|
4273 |
d := delta negated + 1. |
|
4274 |
||
4275 |
line size > d ifTrue:[ |
|
4276 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
4277 |
line := line copyFrom:d |
|
4278 |
] |
|
4279 |
]. |
|
4280 |
widthOfWidestLine := nil |
|
4281 |
]. |
|
4282 |
list at:lineNr put:line. |
|
4283 |
self textChanged. |
|
4284 |
] |
|
4285 |
] |
|
121 | 4286 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4287 |
self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4288 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4289 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4290 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4291 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4292 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4293 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4294 |
this is done by searching for the last non-empty line before it |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4295 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4296 |
|
827 | 4297 |
"SHOULD GO TO ListView" |
4298 |
||
4299 |
|line lnr indent| |
|
4300 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4301 |
lnr := lineNr. |
827 | 4302 |
|
4303 |
[lnr ~~ 1] whileTrue:[ |
|
2357 | 4304 |
lnr := lnr - 1. |
4305 |
line := self listAt:lnr. |
|
4306 |
||
4307 |
line notNil ifTrue:[ |
|
4308 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
4309 |
indent ~~ 0 ifTrue:[ |
|
4310 |
^ indent - 1 |
|
4311 |
] |
|
4312 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4313 |
]. |
827 | 4314 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4315 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4316 |
"Created: 5.3.1996 / 14:58:53 / cg" |
105 | 4317 |
! ! |
4318 |
||
0 | 4319 |
!EditTextView methodsFor:'initialization'! |
4320 |
||
941 | 4321 |
fetchDeviceResources |
4322 |
"fetch device colors, to avoid reallocation at redraw time" |
|
4323 |
||
4324 |
super fetchDeviceResources. |
|
4325 |
||
1993 | 4326 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
4327 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
4328 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 4329 |
|
4330 |
"Created: 14.1.1997 / 00:15:24 / cg" |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4331 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 4332 |
! |
4333 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4334 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4335 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4336 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4337 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4338 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4339 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4340 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4341 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4342 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4343 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4344 |
super initStyle. |
2088 | 4345 |
lineSpacing := 1. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4346 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4347 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4348 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4349 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4350 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4351 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 4352 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4353 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
2088 | 4354 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4355 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4356 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4357 |
cursorNoFocusFgColor isNil ifTrue:[ |
2088 | 4358 |
cursorType ~~ #block ifTrue:[ |
4359 |
cursorNoFocusFgColor := cursorBgColor |
|
4360 |
] ifFalse:[ |
|
4361 |
cursorNoFocusFgColor := cursorFgColor |
|
4362 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4363 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4364 |
|
2088 | 4365 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4366 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4367 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4368 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4369 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4370 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4371 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4372 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4373 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4374 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4375 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4376 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4377 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4378 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4379 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4380 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4381 |
cursorCol := 1. |
2815 | 4382 |
cursorLineHolder := 1 asValue. |
4383 |
cursorColHolder := 1 asValue. |
|
2119 | 4384 |
modifiedChannel := ValueHolder with:false. |
4385 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
4386 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4387 |
showMatchingParenthesis := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4388 |
hasKeyboardFocus := false. "/ true. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4389 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4390 |
autoIndent := false. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4391 |
insertMode := true asValue. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4392 |
learnMode := false asValue. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4393 |
"/ trimBlankLines := st80Mode not. "true." |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4394 |
trimBlankLines := self st80EditMode not. "true." |
2131 | 4395 |
cursorMovementWhenUpdating := #beginOfText. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
4396 |
|
2589 | 4397 |
"/ on default enable drop |
4398 |
self allowDrop:true. "/ readOnly tested in #canDrop: |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4399 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4400 |
undoSupport := UndoSupport for:self. |
0 | 4401 |
! ! |
4402 |
||
2580 | 4403 |
!EditTextView methodsFor:'macros'! |
4404 |
||
4405 |
executeLearnedKeyboardMacro |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4406 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
2580 | 4407 |
learnedMacro do:[:event | |
4408 |
WindowGroup lastEventQuerySignal answer:event |
|
4409 |
do:[ |
|
4410 |
self |
|
4411 |
dispatchEvent:event |
|
4412 |
withFocusOn:nil |
|
4413 |
delegate:false |
|
4414 |
] |
|
4415 |
]. |
|
4416 |
] ifFalse:[ |
|
4417 |
self flash. |
|
4418 |
]. |
|
4419 |
! |
|
4420 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4421 |
learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4422 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4423 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4424 |
|
2580 | 4425 |
learnMode:aBoolean |
4426 |
|fg bg| |
|
4427 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4428 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4429 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4430 |
aBoolean ifTrue:[ |
2580 | 4431 |
learnedMacro := OrderedCollection new. |
4432 |
fg := Color white. |
|
4433 |
bg := Color black. |
|
4434 |
] ifFalse:[ |
|
4435 |
cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor. |
|
4436 |
cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor. |
|
4437 |
]. |
|
4438 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
4439 |
! |
|
4440 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4441 |
learnModeHolder |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4442 |
learnMode isNil ifTrue:[ |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4443 |
learnMode := false asValue |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4444 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4445 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4446 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4447 |
|
2580 | 4448 |
toggleLearnMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4449 |
self learnMode: self learnMode not. |
2580 | 4450 |
! ! |
4451 |
||
121 | 4452 |
!EditTextView methodsFor:'menu actions'! |
4453 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4454 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4455 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4456 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4457 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4458 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4459 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4460 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4461 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4462 |
self withWaitCursorDo:[ |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4463 |
SOAP::SoapImplError handle:[:ex | |
2682 | 4464 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4465 |
] do:[ |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4466 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4467 |
] |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4468 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4469 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4470 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4471 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4472 |
self unselect. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4473 |
self undoablePaste:translated |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4474 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4475 |
|
121 | 4476 |
cut |
4477 |
"cut selection into copybuffer" |
|
4478 |
||
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4479 |
|line col history sel s| |
121 | 4480 |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4481 |
(self checkModificationsAllowed) ifFalse:[ |
2121 | 4482 |
self flash. |
4483 |
^ self |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4484 |
]. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4485 |
|
121 | 4486 |
sel := self selection. |
4487 |
sel notNil ifTrue:[ |
|
2121 | 4488 |
lastString := s := sel asStringWithCRs. |
4489 |
line := selectionStartLine. |
|
4490 |
col := selectionStartCol. |
|
4491 |
||
4492 |
" |
|
4493 |
remember in CopyBuffer |
|
4494 |
" |
|
4495 |
self setTextSelection:sel. "/ lastString. |
|
4496 |
||
4497 |
" |
|
4498 |
append to DeleteHistory (if there is one) |
|
4499 |
" |
|
4500 |
history := Smalltalk at:#DeleteHistory. |
|
4501 |
history notNil ifTrue:[ |
|
4502 |
history addAll:(sel asStringCollection). |
|
4503 |
history size > 1000 ifTrue:[ |
|
4504 |
history := history copyFrom:(history size - 1000) |
|
4505 |
]. |
|
4506 |
]. |
|
4507 |
||
4508 |
" |
|
4509 |
now, delete it |
|
4510 |
" |
|
2952 | 4511 |
self undoableDo:[ |
4512 |
self deleteSelection. |
|
4513 |
]. |
|
2121 | 4514 |
lastReplacement := nil |
121 | 4515 |
] ifFalse:[ |
2121 | 4516 |
" |
4517 |
a cut without selection will search&cut again |
|
4518 |
" |
|
2952 | 4519 |
self undoableDo:[ |
4520 |
self again |
|
4521 |
] |
|
121 | 4522 |
] |
1290 | 4523 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4524 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
121 | 4525 |
! |
4526 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4527 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4528 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4529 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4530 |
cursorLine notNil ifTrue:[ |
2357 | 4531 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4532 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4533 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4534 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4535 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4536 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4537 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4538 |
|
488 | 4539 |
<resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
4540 |
<resource: #programMenu> |
1054 | 4541 |
|
2919 | 4542 |
|items m sub translateItems miscItems toolItems subSub toolSub| |
1515 | 4543 |
|
2460 | 4544 |
items := #( |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4545 |
('Redo' redo ) |
2540
56b92c7a787c
menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
4546 |
('Again (for All)' multipleAgain ) |
2460 | 4547 |
('-' ) |
4548 |
('Search...' search Find ) |
|
2944 | 4549 |
('Goto Line...' gotoLine GotoLine ) |
2460 | 4550 |
('-' ) |
2866 | 4551 |
('Tools' tools ) |
4552 |
('Misc' misc ) |
|
2580 | 4553 |
('-' ) |
2676 | 4554 |
('Insert File...' insertFile ) |
4555 |
('-' ) |
|
2540
56b92c7a787c
menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
4556 |
('Save As...' save SaveAs ) |
2460 | 4557 |
('Print' doPrint Print ) |
4558 |
). |
|
4559 |
||
2866 | 4560 |
miscItems := #( |
4561 |
('AutoIndent \c' autoIndent: ) |
|
4562 |
('InsertMode \c' insertMode: ) |
|
4563 |
('-' ) |
|
4564 |
('Learn Macro \c' learnMode: LearnKeyboardMacro) |
|
4565 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
2870 | 4566 |
('-' ) |
4567 |
('Font...' changeFont ) |
|
4568 |
"/ ('Encoding...' changeEncoding ) |
|
2866 | 4569 |
). |
4570 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4571 |
translateItems := #( |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4572 |
('English -> German' (babelFishTranslate: 'en_de') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4573 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4574 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4575 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4576 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4577 |
('-' ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4578 |
('German -> English' (babelFishTranslate: 'de_en') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4579 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4580 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4581 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4582 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4583 |
). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4584 |
|
2762 | 4585 |
toolItems := #( |
2866 | 4586 |
('Indent' indent ) |
4587 |
('-' ) |
|
4588 |
('Google Spell' googleSpellingSuggestion ) |
|
4589 |
('Translate' babelFishTranslate ) |
|
4590 |
('-' ) |
|
2870 | 4591 |
('Special Characters...' specialCharacters ) |
4592 |
('-' ) |
|
2866 | 4593 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
2762 | 4594 |
). |
4595 |
||
2460 | 4596 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 4597 |
sub receiver:self. |
2460 | 4598 |
|
2919 | 4599 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
4600 |
toolSub receiver:self. |
|
4601 |
sub subMenuAt:#tools put:toolSub. |
|
4602 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4603 |
subSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4604 |
subSub receiver:self. |
2919 | 4605 |
toolSub subMenuAt:#babelFishTranslate put:subSub. |
2762 | 4606 |
|
2866 | 4607 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
4608 |
subSub receiver:self. |
|
2952 | 4609 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
4610 |
subSub checkToggleAt:#insertMode: put:(self insertModeHolder value). |
|
4611 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
|
2866 | 4612 |
sub subMenuAt:#misc put:subSub. |
4613 |
||
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4614 |
self sensor ctrlDown ifTrue:[ |
2460 | 4615 |
m := sub |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4616 |
] ifFalse:[ |
2017 | 4617 |
items := #( |
2979 | 4618 |
('Undo' undo Undo ) |
2403 | 4619 |
('Again' again Again ) |
2017 | 4620 |
('-' ) |
2688
e32c9f26c9e4
editMenu: order is cut-copy-paste (as in windows)
Claus Gittinger <cg@exept.de>
parents:
2682
diff
changeset
|
4621 |
('Cut' cut Cut ) |
2403 | 4622 |
('Copy' copySelection Copy ) |
4623 |
('Paste' pasteOrReplace Paste ) |
|
2017 | 4624 |
('-' ) |
2403 | 4625 |
('Accept' accept Accept ) |
2017 | 4626 |
('=' ) |
2919 | 4627 |
('More' others Ctrl ) |
2017 | 4628 |
). |
2460 | 4629 |
m := PopUpMenu itemList:items resources:resources. |
4630 |
||
4631 |
m subMenuAt:#others put:sub. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4632 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4633 |
|
2676 | 4634 |
SOAP::GoogleClient isNil ifTrue:[ |
4635 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
|
4636 |
m disable:#googleSpellingSuggestion |
|
4637 |
]. |
|
4638 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4639 |
self isReadOnly ifTrue:[ |
2823 | 4640 |
m disableAll:#(paste pasteOrReplace cut indent autoIndent: insertMode: |
4641 |
insertFile babelFishTranslate googleSpellingSuggestion) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4642 |
]. |
2817 | 4643 |
self hasSelectionForCopy ifFalse:[ |
2017 | 4644 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4645 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4646 |
self hasSelection ifFalse:[ |
2762 | 4647 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt). |
4648 |
] ifTrue:[ |
|
2879 | 4649 |
(Error handle:[:ex | |
4650 |
ex return:false |
|
4651 |
] do:[ |
|
4652 |
self selectionAsString asSingleByteString asFilename exists |
|
4653 |
]) ifFalse:[ |
|
2762 | 4654 |
m disableAll:#(openFileBrowserOnIt). |
4655 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4656 |
]. |
2569 | 4657 |
self hasUndoAction ifFalse:[ |
2017 | 4658 |
m disable:#undo. |
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4659 |
]. |
2952 | 4660 |
self hasRedoAction ifFalse:[ |
4661 |
m disable:#redo. |
|
4662 |
]. |
|
1108 | 4663 |
acceptEnabled == false ifTrue:[ |
2017 | 4664 |
m disable:#accept |
1108 | 4665 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4666 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4667 |
|
2461 | 4668 |
"Modified: / 13.11.2001 / 10:39:16 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4669 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4670 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4671 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4672 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4673 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4674 |
history := device getCopyBufferHistory copy. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4675 |
list := history collect:[:entry | entry asString string asCollectionOfLines first]. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4676 |
box := ListSelectionBox |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4677 |
title:'CopyBuffer History' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4678 |
okText:'Paste' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4679 |
abortText:'Cancel' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4680 |
list:list |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4681 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4682 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4683 |
box show. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4684 |
^ sel. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4685 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4686 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4687 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4688 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4689 |
self sensor shiftDown ifTrue:[ |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4690 |
^ self getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4691 |
]. |
2724 | 4692 |
|
4693 |
"/ return either the (xterm-) selection or the clipBoard |
|
4694 |
^ self |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4695 |
getTextSelection:(self sensor ctrlDown |
2724 | 4696 |
ifTrue:#selection |
4697 |
ifFalse:#clipboard) |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4698 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4699 |
|
2676 | 4700 |
googleSpellingSuggestion |
4701 |
"insert the google-spelling suggestion for the selected text. |
|
4702 |
Requires that the SOAP stuff is loaded and working." |
|
4703 |
||
2677 | 4704 |
|text suggestion| |
2676 | 4705 |
|
4706 |
self withWaitCursorDo:[ |
|
2677 | 4707 |
text := self selection asString string withoutSeparators. |
4708 |
text size == 0 ifTrue:[^ self]. |
|
4709 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4710 |
SOAP::SoapImplError handle:[:ex | |
2682 | 4711 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4712 |
^ self. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4713 |
] do:[ |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4714 |
suggestion := SOAP::GoogleClient new spellingSuggestionOf:text. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4715 |
]. |
2677 | 4716 |
suggestion size == 0 ifTrue:[ |
4717 |
Transcript showCR:'No SpellingSuggestion from Google for: ' , text. |
|
4718 |
^ self. |
|
4719 |
]. |
|
2676 | 4720 |
]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4721 |
self undoablePaste:suggestion. |
2676 | 4722 |
! |
4723 |
||
4724 |
insertFile |
|
4725 |
"insert contents of a file |
|
4726 |
- ask user for filename using a fileSelectionBox." |
|
4727 |
||
2909 | 4728 |
|file text ok| |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4729 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4730 |
[ |
2909 | 4731 |
|why| |
4732 |
||
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4733 |
file := Dialog |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4734 |
requestFileName:(resources string:'Insert contents of:') |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4735 |
default:nil |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4736 |
ok:(resources string:'Insert') |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4737 |
abort:(resources string:'Cancel') |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4738 |
pattern:nil |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4739 |
fromDirectory:directoryForFileDialog. |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4740 |
file isNil ifTrue:[ |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4741 |
"cancel" |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4742 |
^ self. |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4743 |
]. |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4744 |
file := file asFilename. |
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4745 |
directoryForFileDialog := file. |
2909 | 4746 |
|
4747 |
ok := file isReadable and:[file isDirectory not]. |
|
4748 |
ok ifFalse:[ |
|
4749 |
file isReadable ifFalse:[ |
|
4750 |
why := '%1 is unreadable.\\Please try again.' |
|
4751 |
] ifTrue:[ |
|
4752 |
why := '%1 is a directory.\\Please try again.' |
|
4753 |
]. |
|
4754 |
Dialog warn:((resources string:why) withCRs bindWith:file pathName). |
|
4755 |
]. |
|
4756 |
] doUntil:[ok]. |
|
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4757 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4758 |
text := file contentsOfEntireFile. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4759 |
self undoablePaste:text. |
2676 | 4760 |
! |
4761 |
||
2762 | 4762 |
openFileBrowserOnIt |
4763 |
"open a fileBrowser on the selected fileName" |
|
4764 |
||
4765 |
|fn dir| |
|
4766 |
||
4767 |
fn := self selectionAsString asFilename. |
|
4768 |
fn exists ifFalse:[ |
|
4769 |
^ self warn:'Oops - file is gone'. |
|
4770 |
]. |
|
4771 |
(dir := fn) isDirectory ifFalse:[ |
|
4772 |
dir := fn directory |
|
4773 |
]. |
|
4774 |
UserPreferences fileBrowserClass openOn:dir |
|
4775 |
! |
|
4776 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4777 |
paste |
1289 | 4778 |
"paste the copybuffer; if there is a selection, unselect first. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4779 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4780 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4781 |
self checkModificationsAllowed ifTrue:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4782 |
self withSelfAndTextForPasteDo:[:me :text | |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4783 |
me unselect. |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4784 |
me undoablePaste:text |
2952 | 4785 |
] |
4786 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4787 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4788 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4789 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4790 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4791 |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4792 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4793 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4794 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4795 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4796 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4797 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4798 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4799 |
CharacterEncoderError handle:[:ex | |
2857 | 4800 |
|code msg| |
4801 |
||
4802 |
code := ex parameter. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4803 |
codingErrorReported ifFalse:[ |
2857 | 4804 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
4805 |
code notNil ifTrue:[ |
|
4806 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
4807 |
]. |
|
4808 |
Dialog warn:(resources string:msg) withCRs. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4809 |
codingErrorReported := true. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4810 |
]. |
2931
dcbb4ed67115
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
2919
diff
changeset
|
4811 |
ex proceedWith:($? codePoint) |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4812 |
] do:[ |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4813 |
s isString ifTrue:[ |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4814 |
s encoding ~~ characterEncoding ifTrue:[ |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4815 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4816 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4817 |
|
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4818 |
s := s asStringCollection. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4819 |
(someText endsWith:Character cr) ifTrue:[ |
2880 | 4820 |
"/ s := s copyWith:nil. |
4821 |
s := s copyWith:'' "/ an empty line at the end |
|
4822 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4823 |
] |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4824 |
] ifFalse:[ |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4825 |
(s isStringCollection) ifFalse:[ |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4826 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4827 |
^ self |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4828 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4829 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
2017 | 4830 |
]. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4831 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4832 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4833 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4834 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4835 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4836 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4837 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4838 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4839 |
startCol := c1 := cursorCol. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4840 |
self insertLines:(s withTabsExpanded) withCR:false. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4841 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4842 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4843 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4844 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
4845 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4846 |
"Modified: / 14.2.1996 / 11:14:14 / stefan" |
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4847 |
"Modified: / 30.1.2000 / 02:32:42 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4848 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4849 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4850 |
pasteOrReplace |
1289 | 4851 |
"paste the copybuffer; if there is a selection, replace it. |
2010 | 4852 |
otherwise paste at cursor position. |
4853 |
Replace is not done for selections which were created by a paste, |
|
4854 |
to allow multiple paste operations in a row." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4855 |
|
2724 | 4856 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4857 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4859 |
pasteOrReplace:someText |
1289 | 4860 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4861 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4862 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4863 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4864 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4865 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4866 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4867 |
self undoableDo:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4868 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4869 |
self replace:someText |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4870 |
] ifFalse:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4871 |
self paste:someText. |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4872 |
] |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4873 |
]. |
1289 | 4874 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4875 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4876 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4877 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4878 |
replace |
1289 | 4879 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4880 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4881 |
self checkModificationsAllowed ifTrue:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4882 |
self withSelfAndTextForPasteDo:[:me :text | |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4883 |
me undoableDo:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4884 |
me replace:text |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4885 |
] |
2952 | 4886 |
] |
4887 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4888 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4889 |
|
121 | 4890 |
replace:someText |
1289 | 4891 |
"replace the selection by someText" |
121 | 4892 |
|
2017 | 4893 |
|selected selectedString |
2952 | 4894 |
selStartLine selStartCol selEndLine selEndCol| |
121 | 4895 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4896 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4897 |
|
121 | 4898 |
selected := self selection. |
4899 |
selected isNil ifTrue:[ |
|
2017 | 4900 |
^ self paste:someText |
121 | 4901 |
]. |
2017 | 4902 |
|
121 | 4903 |
self deleteSelection. |
4904 |
||
4905 |
"take care, if we replace a selection without space by a word selected |
|
4906 |
with one - in this case we usually do not want the space. |
|
4907 |
But, if we replace a word-selected selection by something without a |
|
4908 |
space, we DO want the space added." |
|
4909 |
||
4910 |
selected size == 1 ifTrue:[ |
|
2017 | 4911 |
selectedString := selected at:1. |
7 | 4912 |
]. |
4913 |
||
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
4914 |
someText size == 1 ifTrue:[ |
2017 | 4915 |
|cutOffSpace addSpace replacement replacementString| |
4916 |
||
4917 |
cutOffSpace := false. |
|
4918 |
addSpace := false. |
|
2432
af5d3ff6204b
be careful if replacing a symbol (which cannot be changed)
Claus Gittinger <cg@exept.de>
parents:
2429
diff
changeset
|
4919 |
replacement := someText copyFrom:1. |
2017 | 4920 |
|
4921 |
selectedString notNil ifTrue:[ |
|
4922 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
4923 |
"selection has no space" |
|
4924 |
||
4925 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
4926 |
cutOffSpace := true |
|
4927 |
] |
|
4928 |
] ifTrue:[ |
|
4929 |
addSpace := true |
|
4930 |
] |
|
4931 |
]. |
|
4932 |
replacementString := replacement at:1. |
|
4933 |
cutOffSpace ifTrue:[ |
|
4934 |
(replacementString startsWith:' ') ifTrue:[ |
|
4935 |
replacementString := replacementString withoutSpaces |
|
4936 |
]. |
|
4937 |
] ifFalse:[ |
|
4938 |
selectStyle == #wordLeft ifTrue:[ |
|
4939 |
"want a space at left" |
|
4940 |
(replacementString startsWith:' ') ifFalse:[ |
|
4941 |
replacementString := replacementString withoutSpaces. |
|
4942 |
replacementString := ' ' , replacementString |
|
4943 |
] |
|
4944 |
]. |
|
4945 |
selectStyle == #wordRight ifTrue:[ |
|
4946 |
"want a space at right" |
|
4947 |
||
4948 |
(replacementString endsWith:' ') ifFalse:[ |
|
4949 |
replacementString := replacementString withoutSpaces. |
|
4950 |
replacementString := replacementString , ' ' |
|
4951 |
] |
|
4952 |
]. |
|
4953 |
]. |
|
4954 |
replacement at:1 put: replacementString. |
|
4955 |
self paste:replacement. |
|
121 | 4956 |
] ifFalse:[ |
2017 | 4957 |
self paste:someText |
7 | 4958 |
]. |
121 | 4959 |
lastString := selectedString. |
2017 | 4960 |
lastReplacement := someText. |
4961 |
||
4962 |
selStartLine := selectionStartLine. |
|
4963 |
selStartCol := self selectionStartCol. |
|
4964 |
selEndLine := selectionEndLine. |
|
4965 |
selEndCol := self selectionEndCol. |
|
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
4966 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4967 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4968 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 4969 |
! |
4970 |
||
4971 |
showDeleted |
|
4972 |
"open a readonly editor on all deleted text" |
|
4973 |
||
4974 |
|v| |
|
4975 |
||
4976 |
v := EditTextView openWith:(Smalltalk at:#DeleteHistory). |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4977 |
v readOnly:true. |
121 | 4978 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4979 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4980 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4981 |
specialCharacters |
2915 | 4982 |
CharacterSetView |
4983 |
openAsInputFor:self |
|
4984 |
label:'Special Character Input' |
|
4985 |
clickLabel:'Click to Insert Character'. |
|
2866 | 4986 |
! |
4987 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4988 |
undoablePaste:someText |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4989 |
self undoableDo:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4990 |
self paste:someText. |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4991 |
]. |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4992 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4993 |
|
2724 | 4994 |
withSelfAndTextForPasteDo:aBlock |
4995 |
"common code for paste/replace of the copybuffer" |
|
4996 |
||
4997 |
|sel| |
|
4998 |
||
4999 |
self checkModificationsAllowed ifFalse:[ |
|
5000 |
self flash. |
|
5001 |
^ self |
|
5002 |
]. |
|
5003 |
||
5004 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
5005 |
sel notNil ifTrue:[ |
|
5006 |
aBlock value:self value:sel. |
|
5007 |
] |
|
105 | 5008 |
! ! |
5009 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5010 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5011 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5012 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5013 |
"check if the text can be modified (i.e. is not readOnly). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5014 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5015 |
This block should be provided by the application or user of the textView, |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5016 |
and may show a warnBox or whatever." |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5017 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5018 |
self isReadOnly ifTrue: [ |
2357 | 5019 |
exceptionBlock isNil ifTrue:[ |
5020 |
^ false |
|
5021 |
]. |
|
5022 |
||
5023 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
5024 |
^ false |
|
5025 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5026 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5027 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5028 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5029 |
"Modified: / 17.6.1998 / 15:51:10 / cg" |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5030 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5031 |
|
2596 | 5032 |
currentSelectionBgColor |
5033 |
typeOfSelection == #paste ifTrue:[ |
|
5034 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
|
5035 |
]. |
|
5036 |
^ super currentSelectionBgColor |
|
5037 |
||
5038 |
" |
|
5039 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
5040 |
" |
|
5041 |
! |
|
5042 |
||
5043 |
currentSelectionFgColor |
|
5044 |
typeOfSelection == #paste ifTrue:[ |
|
5045 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
|
5046 |
]. |
|
5047 |
^ super currentSelectionFgColor |
|
5048 |
! |
|
5049 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5050 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5051 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5052 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5053 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5054 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5055 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5056 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5057 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5058 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5059 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5060 |
textChanged |
522 | 5061 |
"my text was modified (internally). |
5062 |
Sent whenever text has been edited (not to confuse with |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5063 |
contentsChanged, which is triggered when the size has changed, and |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5064 |
is used to notify scrollers, other views etc.)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5065 |
|
641 | 5066 |
self contentsChanged. |
1015 | 5067 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5068 |
contentsWasSaved := false |
641 | 5069 |
|
1015 | 5070 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 5071 |
! |
5072 |
||
2617 | 5073 |
textChangedButNoSizeChange |
2207 | 5074 |
"my text was modified (internally). |
5075 |
Sent whenever text has been edited (not to confuse with |
|
5076 |
contentsChanged, which is triggered when the size has changed, and |
|
5077 |
is used to notify scrollers, other views etc.)" |
|
5078 |
||
5079 |
self modified:true. |
|
5080 |
contentsWasSaved := false |
|
5081 |
||
5082 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5083 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5084 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5085 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5086 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5087 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5088 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5089 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5090 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5091 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5092 |
"Created: / 17.5.1998 / 20:07:52 / cg" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5093 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5094 |
|
1878 | 5095 |
isKeyboardConsumer |
5096 |
"return true, if the receiver is a keyboard consumer; |
|
5097 |
Return true here, redefined from SimpleView." |
|
5098 |
||
5099 |
^ true |
|
5100 |
||
5101 |
! |
|
5102 |
||
997 | 5103 |
specClass |
1390 | 5104 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
5105 |
||
997 | 5106 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 5107 |
^ super specClass |
5108 |
||
1390 | 5109 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 5110 |
! |
5111 |
||
324 | 5112 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5113 |
"return true, if a Tab character should shift focus." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5114 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5115 |
"if not readOnly, I want my tab keys ..." |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5116 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5117 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 5118 |
|
5119 |
"Created: 7.2.1996 / 19:15:31 / cg" |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5120 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5121 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5123 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5124 |
Redefined to add the size of a space (for the cursor). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5125 |
this enables us to scroll one position further than the longest |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5126 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5127 |
|
697 | 5128 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5130 |
w := super widthOfContents. |
697 | 5131 |
(dev := device) isNil ifTrue:[ |
2357 | 5132 |
"/ really dont know ... |
5133 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
5134 |
]. |
697 | 5135 |
^ w + (font widthOn:dev) |
5136 |
||
5137 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5138 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5139 |
|
1588 | 5140 |
!EditTextView methodsFor:'realization'! |
5141 |
||
5142 |
realize |
|
5143 |
"make the view visible - scroll to make the cursor visible." |
|
5144 |
||
5145 |
super realize. |
|
5146 |
||
5147 |
self makeCursorVisible. |
|
1993 | 5148 |
cursorFgColor := cursorFgColor onDevice:device. |
5149 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 5150 |
|
5151 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
5152 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
5153 |
! ! |
|
5154 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5155 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5156 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5157 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5158 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5159 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5160 |
cursorShown ifTrue:[ |
2357 | 5161 |
cursorVisibleLine notNil ifTrue:[ |
5162 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
5163 |
self drawCursorCharacter |
|
5164 |
] |
|
5165 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5166 |
] |
105 | 5167 |
! |
5168 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5169 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5170 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5171 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5172 |
cursorShown ifTrue:[ |
2357 | 5173 |
(visLine == cursorVisibleLine) ifTrue:[ |
5174 |
self drawCursorCharacter |
|
5175 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5176 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5177 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5178 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5179 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5180 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5181 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5182 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5183 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5184 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5185 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5186 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5187 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5188 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5189 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5190 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5191 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5192 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5193 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5194 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5195 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5196 |
cursorShown ifTrue:[ |
2357 | 5197 |
(visLine == cursorVisibleLine) ifTrue:[ |
5198 |
(colNr == cursorCol) ifTrue:[ |
|
5199 |
self drawCursorCharacter. |
|
5200 |
^ self |
|
5201 |
] |
|
5202 |
] |
|
0 | 5203 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5204 |
super redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5205 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5206 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5207 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5208 |
"redraw a visible line from startCol to the end of line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5209 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5210 |
super redrawVisibleLine:visLine from:startCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5211 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5212 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5213 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5214 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5215 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5216 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5217 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5218 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5219 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5220 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5221 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5223 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5224 |
"return the number of pixels by which we may scroll more than the actual |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5225 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5226 |
This is redefined by editable textViews, to allo for the cursor |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5227 |
to be visible if it is positioned right behind the longest line of text. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5228 |
The default returned here is 10 pixels, which should be ok for most cursors" |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5229 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5230 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5231 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5232 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5233 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5234 |
"half a page down - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5235 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5236 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5237 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5239 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5240 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5241 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5242 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5243 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5244 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5245 |
"half a page up - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5246 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5247 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5248 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5249 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5250 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5251 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5252 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5253 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5254 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5255 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5256 |
"sent after scrolling - have to show the cursor if it was on before" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5257 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5258 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5259 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5260 |
should we move the cursor with the scroll - or leave it ? |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5261 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5262 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5263 |
prevCursorState ifTrue:[ |
2357 | 5264 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5265 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5266 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5267 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5268 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5269 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5270 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5271 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5272 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5273 |
prevCursorState := cursorShown. |
1601 | 5274 |
"/ cursorShown := false. |
1591 | 5275 |
cursorShown ifTrue:[ |
2357 | 5276 |
self hideCursor |
1591 | 5277 |
] |
5278 |
||
1601 | 5279 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5280 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5281 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5282 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5283 |
"page down - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5284 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5285 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5286 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5287 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5288 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5289 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5290 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5291 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5292 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5293 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5294 |
"page up - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5295 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5296 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5297 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5298 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5299 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5300 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5301 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5302 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5303 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5304 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5305 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5306 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5307 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5308 |
|
2822 | 5309 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 5310 |
! |
5311 |
||
5312 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
5313 |
"do a backward search" |
|
5314 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5315 |
|pos startLine startCol| |
1339 | 5316 |
|
5317 |
cursorLine isNil ifTrue:[^ self]. |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5318 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5319 |
pos := self startPositionForSearchBackward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5320 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5321 |
startCol := pos x. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5322 |
|
1339 | 5323 |
self |
2357 | 5324 |
searchBackwardFor:pattern |
5325 |
ignoreCase:ign |
|
5326 |
startingAtLine:startLine col:startCol |
|
5327 |
ifFound:[:line :col | |
|
2822 | 5328 |
self cursorMovementAllowed ifTrue:[ |
5329 |
self cursorLine:line col:col. |
|
5330 |
]. |
|
2357 | 5331 |
self showMatch:pattern atLine:line col:col. |
1339 | 5332 |
"/ self makeLineVisible:cursorLine |
2357 | 5333 |
typeOfSelection := #search] |
5334 |
ifAbsent:aBlock |
|
1339 | 5335 |
|
5336 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5337 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5339 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5340 |
"select characters enclosed by matching parenthesis if one is under cusor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5341 |
|
2554 | 5342 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5343 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5345 |
searchForMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5346 |
"search for a matching parenthesis starting at cursor position. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5347 |
Search for the corresponding character is done forward if its an opening, |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5348 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5349 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5350 |
|
2822 | 5351 |
self cursorMovementAllowed ifFalse:[^ self]. |
5352 |
||
5353 |
self |
|
2357 | 5354 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
5355 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
5356 |
ifNotFound:[self showNotFound] |
|
5357 |
onError:[self beep] |
|
1339 | 5358 |
|
5359 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5360 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5361 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5362 |
searchFwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5363 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5364 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5365 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5366 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5367 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5368 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5369 |
startCol := pos x. |
1339 | 5370 |
|
5371 |
self |
|
2357 | 5372 |
searchFwd:pattern |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5373 |
startingAtLine:startLine col:startCol |
2357 | 5374 |
ifAbsent:aBlock |
1339 | 5375 |
|
5376 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5377 |
! |
|
5378 |
||
5379 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
5380 |
"do a forward search" |
|
5381 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5382 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5383 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5384 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5385 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5386 |
startCol := pos x. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5387 |
|
1339 | 5388 |
self |
2357 | 5389 |
searchFwd:pattern |
5390 |
ignoreCase:ign |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5391 |
startingAtLine:startLine col:startCol |
2357 | 5392 |
ifAbsent:aBlock |
1339 | 5393 |
|
5394 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5395 |
"Created: 9.10.1997 / 13:04:10 / cg" |
|
5396 |
! |
|
5397 |
||
5398 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
5399 |
"do a forward search" |
|
5400 |
||
5401 |
cursorLine isNil ifTrue:[^ self]. |
|
5402 |
self |
|
2357 | 5403 |
searchForwardFor:pattern |
5404 |
ignoreCase:ign |
|
5405 |
startingAtLine:startLine col:startCol |
|
5406 |
ifFound:[:line :col | |
|
2822 | 5407 |
self cursorMovementAllowed ifTrue:[ |
5408 |
self cursorLine:line col:col. |
|
5409 |
]. |
|
2357 | 5410 |
self showMatch:pattern atLine:line col:col. |
1339 | 5411 |
"/ self makeLineVisible:cursorLine |
2357 | 5412 |
typeOfSelection := #search] |
5413 |
ifAbsent:aBlock |
|
1339 | 5414 |
|
5415 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
5416 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5417 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5419 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5420 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5421 |
|
2822 | 5422 |
self searchFwd:pattern ignoreCase:false startingAtLine:startLine col:startCol ifAbsent:aBlock |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5423 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5424 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5425 |
setSearchPattern |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5426 |
"set the searchpattern from the selection if there is one, and position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5427 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5428 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5429 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5430 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5431 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5432 |
"/ if the last operation was a replcae, set pattern to last |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5433 |
"/ original string (for search after again) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5434 |
"/ |
565 | 5435 |
(lastString notNil |
5436 |
and:[lastReplacement notNil |
|
5437 |
and:[typeOfSelection ~~ #search]]) ifTrue:[ |
|
2950 | 5438 |
lastString isString ifTrue:[ |
5439 |
lastSearchPattern := lastString. |
|
5440 |
] ifFalse:[ |
|
5441 |
lastSearchPattern := lastString asStringWithoutFinalCR. |
|
5442 |
]. |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5443 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5444 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5445 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5446 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5447 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5448 |
"/ if there was no previous search, take it as search pattern. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5449 |
"/ if there was a previous search, only take the selection if |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5450 |
"/ it did not result from a paste. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5451 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5452 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5453 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5454 |
sel notNil ifTrue:[ |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5455 |
(lastSearchPattern isNil |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5456 |
or:[typeOfSelection ~~ #paste]) ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5457 |
self cursorLine:selectionStartLine col:selectionStartCol. |
2835
efe44fb65536
allow search for strings with whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2823
diff
changeset
|
5458 |
lastSearchPattern := sel asStringWithoutFinalCR withMatchEscapes |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5459 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5460 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5461 |
|
565 | 5462 |
"Modified: 20.4.1996 / 12:50:13 / cg" |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5463 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5464 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5465 |
startPositionForSearchBackward |
2822 | 5466 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
5467 |
! |
|
5468 |
||
5469 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5470 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5471 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5472 |
selectionStartLine notNil ifTrue:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5473 |
startLine := selectionStartLine. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5474 |
startCol := selectionStartCol |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5475 |
] ifFalse:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5476 |
cursorLine isNil ifTrue:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5477 |
startLine := list size. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5478 |
startCol := self listAt:startLine size. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5479 |
] ifFalse:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5480 |
startLine := cursorLine min:list size. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5481 |
startCol := cursorCol |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5482 |
] |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5483 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5484 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5485 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5486 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5487 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5488 |
startPositionForSearchForward |
2822 | 5489 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
5490 |
! |
|
5491 |
||
5492 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5493 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5494 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5495 |
"/ if there is no selection and the cursor is at the origin, |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5496 |
"/ assume its the first search and do not skip the very first match |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5497 |
startCol := cursorCol. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5498 |
self hasSelection ifFalse:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5499 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5500 |
startCol := 0 |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5501 |
] |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5502 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5503 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5504 |
^ startCol @ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5505 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5506 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5507 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5508 |
|
1850 | 5509 |
autoMoveCursorToEndOfSelection |
5510 |
"return true, if the cursor should be automatically moved to the |
|
5511 |
end of a selection. |
|
5512 |
Redefined to return false in terminaViews, where the cursor should |
|
5513 |
not be affected by selecting" |
|
5514 |
||
5515 |
^ true |
|
5516 |
! |
|
5517 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5518 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5519 |
typeOfSelection ~~ newType ifTrue:[ |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5520 |
typeOfSelection := newType. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5521 |
selectionStartLine notNil ifTrue:[ |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5522 |
self |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5523 |
redrawFromLine:selectionStartLine col:selectionStartCol |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5524 |
toLine:selectionEndLine col:selectionEndCol |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5525 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5526 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5527 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5528 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5529 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5530 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5531 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5532 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5533 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5534 |
list isNil ifTrue:[ |
2357 | 5535 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5536 |
] ifFalse:[ |
2357 | 5537 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
5538 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5539 |
] |
1082 | 5540 |
|
5541 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5542 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5543 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5544 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5545 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5547 |
self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5548 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5549 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5550 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5551 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5552 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5553 |
cursorCol > 1 ifTrue:[ |
2357 | 5554 |
self selectFromLine:cursorLine col:1 |
5555 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5556 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5557 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5558 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5559 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5560 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5561 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5562 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5563 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5564 |
selectionStartLine isNil ifTrue:[ |
2357 | 5565 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5566 |
] ifFalse:[ |
2357 | 5567 |
self selectFromLine:selectionStartLine col:selectionStartCol |
5568 |
toLine:cursorLine+1 col:0. |
|
5569 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5570 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5571 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5572 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5573 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5574 |
"select the text from the beginning to the current cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5575 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5576 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
list isNil ifTrue:[ |
2357 | 5579 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5580 |
] ifFalse:[ |
2357 | 5581 |
cursorCol == 0 ifTrue:[ |
5582 |
col := 0 |
|
5583 |
] ifFalse:[ |
|
5584 |
col := cursorCol - 1 |
|
5585 |
]. |
|
5586 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
5587 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5588 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5589 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5590 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5591 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
"when a range is selected, position the cursor behind the selection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5593 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5594 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5595 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 5596 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
2357 | 5597 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 5598 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5599 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5600 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5601 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5602 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5603 |
"select the text from the current cursor position to the end." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5604 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5605 |
list isNil ifTrue:[ |
2357 | 5606 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5607 |
] ifFalse:[ |
2357 | 5608 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
5609 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5610 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5611 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5612 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5613 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5614 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5615 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5616 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5617 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5618 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5619 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5620 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5621 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5622 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5623 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5624 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5625 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5626 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
wasOn ifTrue:[self showCursor] |
105 | 5628 |
! ! |
5629 |
||
5630 |
!EditTextView methodsFor:'undo & again'! |
|
5631 |
||
2952 | 5632 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5633 |
^ undoSupport addUndo:action. |
2952 | 5634 |
! |
5635 |
||
105 | 5636 |
again |
5637 |
"repeat the last action (which was a cut or replace). |
|
5638 |
If current selection is not last string, search forward to |
|
5639 |
next occurence of it before repeating the last operation." |
|
5640 |
||
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
5641 |
|s l c sel savedSelectStyle startColForSearch| |
105 | 5642 |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5643 |
lastString isNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5644 |
^ false |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5645 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5646 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5647 |
s := lastString asString. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5648 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5649 |
"remove final cr" |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5650 |
(s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1]. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
5651 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5652 |
savedSelectStyle := selectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5653 |
selectStyle := nil. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5654 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5655 |
sel := self selection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5656 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5657 |
"if we are already there (after a find), ommit search" |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5658 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5659 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5660 |
l := selectionStartLine "cursorLine". |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5661 |
c := selectionStartCol "cursorCol". |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5662 |
self deleteSelection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5663 |
lastReplacement notNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5664 |
self insertLines:lastReplacement asStringCollection withCR:false. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5665 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
5666 |
]. |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5667 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5668 |
^ true |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5669 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5670 |
startColForSearch := cursorCol. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5671 |
sel isNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5672 |
startColForSearch := startColForSearch - 1 |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5673 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5674 |
self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5675 |
ifFound: |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5676 |
[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5677 |
:line :col | |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5678 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5679 |
|repl| |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5680 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5681 |
self selectFromLine:line col:col |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5682 |
toLine:line col:(col + s size - 1). |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5683 |
self makeLineVisible:line. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5684 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5685 |
self deleteSelection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5686 |
lastReplacement notNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5687 |
lastReplacement isString ifFalse:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5688 |
repl := lastReplacement asString "withoutSpaces" |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5689 |
] ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5690 |
repl := lastReplacement "withoutSpaces". |
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
5691 |
]. |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5692 |
self insertLines:repl asStringCollection withCR:false. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5693 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5694 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5695 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5696 |
^ true |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5697 |
] |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5698 |
ifAbsent: |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5699 |
[ |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5700 |
self sensor compressKeyPressEventsWithKey:#Again. |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5701 |
self showNotFound. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5702 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5703 |
^ false |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5704 |
]. |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5705 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5706 |
^ true. |
501 | 5707 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
5708 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 5709 |
! |
5710 |
||
2952 | 5711 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5712 |
^ undoSupport hasRedoAction. |
2952 | 5713 |
! |
5714 |
||
5715 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5716 |
^ undoSupport hasUndoAction. |
2952 | 5717 |
! |
5718 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5719 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5720 |
"repeat the last action (which was a cut or replace) until search fails" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5721 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5722 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5723 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5724 |
|
2952 | 5725 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5726 |
undoSupport nonUndoableDo:aBlock. |
2952 | 5727 |
! |
5728 |
||
5729 |
redo |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5730 |
undoSupport hasRedoAction ifFalse:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5731 |
self beep |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5732 |
] ifTrue:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5733 |
undoSupport redo. |
2952 | 5734 |
] |
5735 |
! |
|
5736 |
||
121 | 5737 |
undo |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5738 |
undoSupport hasUndoAction ifFalse:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5739 |
self beep |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5740 |
] ifTrue:[ |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5741 |
undoSupport undo. |
121 | 5742 |
] |
2952 | 5743 |
! |
5744 |
||
5745 |
undoableDo:aBlock |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5746 |
self checkModificationsAllowed not ifTrue:[ |
2952 | 5747 |
aBlock value. |
5748 |
] ifFalse:[ |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5749 |
undoSupport undoableDo:aBlock. |
2952 | 5750 |
]. |
5751 |
! ! |
|
5752 |
||
5753 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
5754 |
||
5755 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
5756 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
5757 |
! |
|
5758 |
||
5759 |
line:arg1 col:arg2 character:arg3 |
|
5760 |
^ self new line:arg1 col:arg2 character:arg3 |
|
5761 |
! |
|
5762 |
||
5763 |
line:arg1 col:arg2 string:arg3 |
|
5764 |
^ self new line:arg1 col:arg2 string:arg3 |
|
5765 |
! ! |
|
5766 |
||
5767 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
|
5768 |
||
5769 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
|
5770 |
"set instance variables (automatically generated)" |
|
5771 |
||
5772 |
self assert:(line1Arg notNil). |
|
5773 |
self assert:(col1Arg notNil). |
|
5774 |
self assert:(line2Arg notNil). |
|
5775 |
self assert:(col2Arg notNil). |
|
5776 |
||
5777 |
line1 := line1Arg. |
|
5778 |
col1 := col1Arg. |
|
5779 |
line2 := line2Arg. |
|
5780 |
col2 := col2Arg. |
|
5781 |
! ! |
|
5782 |
||
5783 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
5784 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5785 |
executeIn:editor |
2952 | 5786 |
editor unselect. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5787 |
editor |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5788 |
deleteFromLine:line1 |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5789 |
col:col1 |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5790 |
toLine:line2 |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5791 |
col:col2. |
2952 | 5792 |
editor cursorLine:line1 col:col1. |
5793 |
! ! |
|
5794 |
||
5795 |
!EditTextView::InsertCharacter methodsFor:'accessing'! |
|
5796 |
||
5797 |
line:lineArg col:colArg character:characterArg |
|
5798 |
"set instance variables (automatically generated)" |
|
5799 |
||
5800 |
line := lineArg. |
|
5801 |
col := colArg. |
|
5802 |
character := characterArg. |
|
5803 |
! ! |
|
5804 |
||
5805 |
!EditTextView::InsertCharacter methodsFor:'execution'! |
|
5806 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5807 |
executeIn:editor |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5808 |
editor |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5809 |
replace:character |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5810 |
atLine:line |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5811 |
col:col. |
2952 | 5812 |
editor cursorLine:line col:col. |
5813 |
! ! |
|
5814 |
||
5815 |
!EditTextView::PasteString methodsFor:'accessing'! |
|
5816 |
||
5817 |
line:lineArg col:colArg string:stringArg |
|
5818 |
self assert:(lineArg notNil). |
|
5819 |
self assert:(colArg notNil). |
|
5820 |
self assert:(stringArg notNil). |
|
5821 |
||
5822 |
line := lineArg. |
|
5823 |
col := colArg. |
|
5824 |
string := stringArg. |
|
5825 |
! |
|
5826 |
||
5827 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
5828 |
self assert:(lineArg notNil). |
|
5829 |
self assert:(colArg notNil). |
|
5830 |
self assert:(stringArg notNil). |
|
5831 |
||
5832 |
line := lineArg. |
|
5833 |
col := colArg. |
|
5834 |
string := stringArg. |
|
5835 |
selected := selectedArg. |
|
5836 |
! ! |
|
5837 |
||
5838 |
!EditTextView::PasteString methodsFor:'execution'! |
|
5839 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5840 |
executeIn:editor |
2952 | 5841 |
editor cursorLine:line col:col. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5842 |
editor paste:string. |
2952 | 5843 |
selected ~~ true ifTrue:[ |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5844 |
editor unselect |
2952 | 5845 |
]. |
5846 |
! ! |
|
5847 |
||
5848 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
5849 |
||
5850 |
line:lineArg col:colArg character:characterArg |
|
5851 |
"set instance variables (automatically generated)" |
|
5852 |
||
5853 |
line := lineArg. |
|
5854 |
col := colArg. |
|
5855 |
character := characterArg. |
|
5856 |
! ! |
|
5857 |
||
5858 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
5859 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5860 |
executeIn:editor |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5861 |
editor |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5862 |
replace:character |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5863 |
atLine:line |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5864 |
col:col. |
2952 | 5865 |
editor cursorLine:line col:col. |
105 | 5866 |
! ! |
5867 |
||
865 | 5868 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5870 |
version |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
5871 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.356 2004-09-14 09:55:41 cg Exp $' |
0 | 5872 |
! ! |