author | Claus Gittinger <cg@exept.de> |
Wed, 06 Nov 2002 12:08:23 +0100 | |
changeset 2660 | 1352e7b3ac67 |
parent 2647 | 23dca8f032c3 |
child 2676 | cc61fa88a3fb |
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 |
2363 | 16 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
17 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
18 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
19 |
cursorTypeNoFocus undoAction typeOfSelection lastString |
|
20 |
lastReplacement lastAction replacing showMatchingParenthesis |
|
21 |
hasKeyboardFocus acceptAction lockUpdates tabMeansNextField |
|
22 |
autoIndent insertMode trimBlankLines wordWrap |
|
23 |
replacementWordSelectStyle acceptChannel acceptEnabled st80Mode |
|
24 |
disableIfInvisible cursorMovementWhenUpdating learnMode |
|
2589 | 25 |
learnedMacro cursorLineHolder cursorColHolder dropTarget' |
2363 | 26 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
27 |
DefaultCursorType DefaultCursorNoFocusForegroundColor ST80Mode |
|
28 |
DefaultCursorTypeNoFocus' |
|
29 |
poolDictionaries:'' |
|
30 |
category:'Views-Text' |
|
0 | 31 |
! |
32 |
||
865 | 33 |
!EditTextView class methodsFor:'documentation'! |
0 | 34 |
|
33 | 35 |
copyright |
36 |
" |
|
37 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
2357 | 38 |
All Rights Reserved |
33 | 39 |
|
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
48 |
||
0 | 49 |
documentation |
50 |
" |
|
51 |
a view for editable text - adds editing functionality to TextView |
|
125 | 52 |
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
|
53 |
acceptAction to be performed for accept |
125 | 54 |
|
55 |
If used with a model, this is informed by sending it a changeMsg with |
|
56 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
57 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 58 |
|
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
|
59 |
Please read the historic notice in the ListView class. |
0 | 60 |
|
586 | 61 |
[Instance variables:] |
0 | 62 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
63 |
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
|
64 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
65 |
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
|
66 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
67 |
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
|
68 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
69 |
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
|
70 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
71 |
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
|
72 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
73 |
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
|
74 |
cleared on accept. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
75 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
76 |
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
|
77 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
78 |
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
|
79 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
84 |
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
|
85 |
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
|
86 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
(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
|
90 |
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
|
91 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
95 |
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
|
96 |
(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
|
97 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
102 |
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
|
103 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
104 |
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
|
105 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
106 |
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
|
107 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
111 |
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
|
112 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
113 |
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
|
114 |
argument |
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 |
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
|
117 |
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
|
118 |
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
|
119 |
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
|
120 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
121 |
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
|
122 |
removed when editing. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
123 |
Default is true. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
124 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
125 |
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
|
126 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
127 |
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
|
128 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
129 |
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
|
130 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
131 |
cursorMovementWhenUpdating |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
132 |
<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
|
133 |
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
|
134 |
(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
|
135 |
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
|
136 |
#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
|
137 |
#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
|
138 |
#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
|
139 |
#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
|
140 |
#beginOfLine -> stay in the line, but move to begin |
2131 | 141 |
The default is #beginOfText |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
142 |
|
33 | 143 |
|
2589 | 144 |
|
145 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
146 |
||
147 |
||
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
148 |
class variables: |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
149 |
ST80Mode <Boolean> if true, cursor positioning is |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
This is not yet completely implemented. |
33 | 155 |
used globals: |
156 |
||
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
157 |
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
|
158 |
(but only if this variable exists already) |
586 | 159 |
|
160 |
[styleSheet parameters:] |
|
121 | 161 |
|
2589 | 162 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
163 |
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
|
164 |
textCursorNoFocusForegroundColor |
2589 | 165 |
<Color> cursor fg color if no focus; default: cursor fg color |
166 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 167 |
|
168 |
[author:] |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
169 |
Claus Gittinger |
586 | 170 |
|
171 |
[see also:] |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
172 |
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
|
173 |
EditField |
0 | 174 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
175 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
176 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
177 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
178 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
179 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
180 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
181 |
basic setup: |
2357 | 182 |
[exBegin] |
183 |
|top textView| |
|
184 |
||
185 |
top := StandardSystemView new. |
|
186 |
top extent:300@200. |
|
187 |
||
188 |
textView := EditTextView new. |
|
189 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
190 |
top addSubView:textView. |
|
191 |
||
192 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
193 |
||
194 |
top open. |
|
195 |
[exEnd] |
|
594 | 196 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
197 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
198 |
with vertical scrollbar: |
2357 | 199 |
[exBegin] |
200 |
|top scrollView textView| |
|
201 |
||
202 |
top := StandardSystemView new. |
|
203 |
top extent:300@200. |
|
204 |
||
205 |
scrollView := ScrollableView for:EditTextView. |
|
206 |
textView := scrollView scrolledView. |
|
207 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
208 |
top addSubView:scrollView. |
|
209 |
||
210 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
211 |
||
212 |
top open. |
|
213 |
[exEnd] |
|
594 | 214 |
|
297
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 |
with horizontal & vertical scrollbars: |
2357 | 217 |
[exBegin] |
218 |
|top scrollView textView| |
|
219 |
||
220 |
top := StandardSystemView new. |
|
221 |
top extent:300@200. |
|
222 |
||
223 |
scrollView := HVScrollableView for:EditTextView. |
|
224 |
textView := scrollView scrolledView. |
|
225 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
226 |
top addSubView:scrollView. |
|
227 |
||
228 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
229 |
||
230 |
top open. |
|
231 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
232 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
233 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
234 |
set the action for accept: |
2357 | 235 |
[exBegin] |
236 |
|top textView| |
|
237 |
||
238 |
top := StandardSystemView new. |
|
239 |
top extent:300@200. |
|
240 |
||
241 |
textView := EditTextView new. |
|
242 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
243 |
top addSubView:textView. |
|
244 |
||
245 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
246 |
textView acceptAction:[:contents | |
|
247 |
Transcript showCR:'will not overwrite the file with:'. |
|
248 |
Transcript showCR:contents asString |
|
249 |
]. |
|
250 |
top open. |
|
251 |
[exEnd] |
|
594 | 252 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
253 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
254 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
255 |
non-string (text) items: |
2357 | 256 |
[exBegin] |
257 |
|top textView list| |
|
258 |
||
259 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
260 |
1 to:list size by:2 do:[:nr | |
|
261 |
list at:nr put:(Text string:(list at:nr) |
|
262 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
263 |
]. |
|
264 |
||
265 |
top := StandardSystemView new. |
|
266 |
top extent:300@200. |
|
267 |
||
268 |
textView := EditTextView new. |
|
269 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
270 |
top addSubView:textView. |
|
271 |
||
272 |
textView contents:list. |
|
273 |
top open. |
|
274 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
275 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
276 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
277 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
278 |
MVC operation: |
594 | 279 |
(the examples model here is a plug simulating a real model; |
280 |
real world applications would not use a plug ..) |
|
2357 | 281 |
[exBegin] |
282 |
|top textView model| |
|
283 |
||
284 |
model := Plug new. |
|
285 |
model respondTo:#accepted: |
|
286 |
with:[:newContents | |
|
287 |
Transcript showCR:'will not overwrite the file with:'. |
|
288 |
Transcript showCR:newContents asString |
|
289 |
]. |
|
290 |
model respondTo:#getList |
|
291 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
|
2357 | 294 |
top := StandardSystemView new. |
295 |
top extent:300@200. |
|
296 |
||
297 |
textView := EditTextView new. |
|
298 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
299 |
top addSubView:textView. |
|
300 |
||
301 |
textView listMessage:#getList; |
|
302 |
model:model; |
|
303 |
changeMessage:#accepted:; |
|
304 |
aspect:#list. |
|
305 |
top open. |
|
306 |
[exEnd] |
|
594 | 307 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
308 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
309 |
two textViews on the same model: |
2357 | 310 |
[exBegin] |
311 |
|top1 textView1 top2 textView2 model currentContents| |
|
312 |
||
313 |
model := Plug new. |
|
314 |
model respondTo:#accepted: |
|
315 |
with:[:newContents | |
|
316 |
Transcript showCR:'accepted:'. |
|
317 |
Transcript showCR:newContents asString. |
|
318 |
currentContents := newContents. |
|
319 |
model changed:#contents |
|
320 |
]. |
|
321 |
model respondTo:#getList |
|
322 |
with:[Transcript showCR:'query'. |
|
323 |
currentContents]. |
|
324 |
||
325 |
||
326 |
top1 := StandardSystemView new. |
|
327 |
top1 extent:300@200. |
|
328 |
||
329 |
textView1 := EditTextView new. |
|
330 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
331 |
top1 addSubView:textView1. |
|
332 |
||
333 |
textView1 listMessage:#getList; |
|
334 |
model:model; |
|
335 |
aspect:#contents; |
|
336 |
changeMessage:#accepted:. |
|
337 |
top1 open. |
|
338 |
||
339 |
top2 := StandardSystemView new. |
|
340 |
top2 extent:300@200. |
|
341 |
||
342 |
textView2 := EditTextView new. |
|
343 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
344 |
top2 addSubView:textView2. |
|
345 |
||
346 |
textView2 listMessage:#getList; |
|
347 |
model:model; |
|
348 |
aspect:#contents; |
|
349 |
changeMessage:#accepted:. |
|
350 |
top2 open. |
|
351 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
352 |
" |
0 | 353 |
! ! |
354 |
||
865 | 355 |
!EditTextView class methodsFor:'defaults'! |
59 | 356 |
|
1419 | 357 |
st80Mode |
358 |
"return true, if the st80 editing mode is turned on. |
|
359 |
This setting affects the behavior of the cursor, when positioned |
|
360 |
behond the end of a line or the end of the text. |
|
361 |
The default is initialized from the viewStyle." |
|
362 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
363 |
^ UserPreferences current st80EditMode |
1419 | 364 |
|
365 |
" |
|
366 |
EditTextView st80Mode:true |
|
367 |
EditTextView st80Mode:false |
|
368 |
" |
|
369 |
||
370 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
371 |
! |
|
372 |
||
373 |
st80Mode:aBoolean |
|
374 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
375 |
behond the end of a line or the last line" |
|
376 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
377 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 378 |
|
379 |
" |
|
380 |
EditTextView st80Mode:true |
|
381 |
EditTextView st80Mode:false |
|
382 |
" |
|
383 |
||
384 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
385 |
! |
|
386 |
||
59 | 387 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
388 |
"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
|
389 |
|
1390 | 390 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
2357 | 391 |
#'textCursor.noFocusForegroundColor' |
392 |
#'textCursor.type' #'textCursor.typeNoFocus' |
|
393 |
#'editText.st80Mode')> |
|
1355 | 394 |
|
395 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
396 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
397 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
398 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
399 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
400 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
401 |
"/ ST80Mode := StyleSheet at:'editText.st80Mode' default:false. |
1419 | 402 |
|
403 |
" |
|
404 |
self updateStyleCache |
|
405 |
" |
|
406 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
407 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 408 |
! ! |
409 |
||
2101 | 410 |
!EditTextView methodsFor:'Compatibility - ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
411 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
412 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
413 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
414 |
|
2019 | 415 |
"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
|
416 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
417 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
418 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
419 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
420 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
421 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
422 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
423 |
|
1390 | 424 |
cutSelection |
425 |
self cut |
|
426 |
||
427 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
428 |
! |
|
429 |
||
1590 | 430 |
deselect |
431 |
"remove the selection" |
|
432 |
||
433 |
^ self unselect |
|
434 |
||
435 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
436 |
! |
|
437 |
||
2101 | 438 |
enabled:aBoolean |
439 |
||
440 |
self readOnly:aBoolean not |
|
441 |
||
442 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
443 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
444 |
! |
|
445 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
446 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
447 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
448 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
449 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
450 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
451 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
452 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
453 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
454 |
"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
|
455 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
456 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
457 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
458 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
459 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
460 |
col < 1 ifTrue:[ |
2357 | 461 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
462 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
463 |
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
|
464 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
465 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
466 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
467 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
468 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
469 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
470 |
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
|
471 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
475 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
476 |
"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
|
477 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
478 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
479 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
480 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
481 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
482 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
483 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
484 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 485 |
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
|
486 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
487 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 488 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
489 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
490 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
491 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
492 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
493 |
v insertAndSelect:'<- hello there' at:5. |
125 | 494 |
" |
1390 | 495 |
! |
496 |
||
497 |
pasteSelection |
|
498 |
self paste |
|
499 |
||
500 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 501 |
! |
502 |
||
503 |
replaceSelectionWith:aString |
|
504 |
^ self replaceSelectionBy:aString |
|
505 |
||
506 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
507 |
! |
|
508 |
||
509 |
selectAt:pos |
|
510 |
"move the cursor before cursorPosition." |
|
511 |
||
512 |
self cursorToCharacterPosition:pos |
|
513 |
||
514 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
515 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
516 |
! |
|
517 |
||
518 |
selectFrom:startPos to:endPos |
|
519 |
"change the selection given two aCharacterPositions." |
|
520 |
||
521 |
|line1 col1 line2 col2| |
|
522 |
||
523 |
startPos > endPos ifTrue:[ |
|
2357 | 524 |
^ self unselect |
1590 | 525 |
]. |
526 |
||
527 |
line1 := self lineOfCharacterPosition:startPos. |
|
528 |
col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1. |
|
529 |
col1 < 1 ifTrue:[ |
|
2357 | 530 |
col1 := 1 |
1590 | 531 |
]. |
532 |
line2 := self lineOfCharacterPosition:endPos. |
|
533 |
col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1. |
|
534 |
col2 < 1 ifTrue:[ |
|
2357 | 535 |
col2 := 1 |
1590 | 536 |
]. |
537 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
538 |
||
539 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
2101 | 540 |
! |
541 |
||
542 |
textHasChanged |
|
543 |
^ self modified |
|
544 |
||
545 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
546 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
547 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
548 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
549 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
550 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
551 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
552 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
553 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
554 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
555 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
556 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
557 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
558 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
559 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
560 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
561 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
562 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
563 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
564 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
565 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
567 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
568 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
569 |
|
1108 | 570 |
acceptEnabled:aBoolean |
571 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
572 |
||
573 |
acceptEnabled := aBoolean |
|
574 |
||
575 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
576 |
! |
|
577 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
578 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
579 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
580 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
581 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
582 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
583 |
|
2133 | 584 |
cursorMovementWhenUpdating:aSymbolOrNil |
585 |
"define what should be done with the cursor, |
|
586 |
when I get a new text (via the model or the #contents/#list) |
|
587 |
Allowed arguments are: |
|
588 |
#keep / nil -> stay where it was |
|
589 |
#endOfText -> position cursor to the end |
|
590 |
#beginOfText -> position cursor to the beginning |
|
591 |
#endOfLine -> position cursor to the current lines end |
|
592 |
#beginOfLine -> position cursor to the current lines start |
|
593 |
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
|
594 |
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
|
595 |
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
|
596 |
|
2133 | 597 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
598 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
599 |
"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
|
600 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
601 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
602 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
603 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
604 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
605 |
|
2438 | 606 |
dontReplaceSelectionOnInput |
607 |
typeOfSelection := #paste |
|
608 |
! |
|
609 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
610 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
611 |
"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
|
612 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
613 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
614 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
615 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
616 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
617 |
insertMode:aBoolean |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
618 |
insertMode := aBoolean |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
619 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
620 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
621 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
622 |
|
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
623 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
624 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
625 |
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
|
626 |
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
|
627 |
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
|
628 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
629 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
630 |
tabMeansNextField := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
631 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
632 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
633 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
634 |
|
1013 | 635 |
acceptChannel |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
636 |
"return the valueHolder holding true if text was accepted. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
637 |
By placing a true into this channel, an accept can also be forced." |
1013 | 638 |
|
639 |
^ acceptChannel |
|
640 |
||
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
641 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
642 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
643 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
644 |
acceptChannel:aValueHolder |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
645 |
"set the valueHolder holding true if text was accepted. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
646 |
By placing a true into this channel, an accept can also be forced." |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
647 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
648 |
|prev| |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
649 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
650 |
prev := acceptChannel. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
651 |
acceptChannel := aValueHolder. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
652 |
self setupChannel:aValueHolder for:nil withOld:prev |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
653 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
654 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
1013 | 655 |
! |
656 |
||
657 |
accepted |
|
658 |
"return true if text was accepted" |
|
659 |
||
660 |
^ acceptChannel value |
|
661 |
||
662 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
663 |
! |
|
664 |
||
665 |
accepted:aBoolean |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
666 |
"set/clear the accepted flag. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
667 |
This may force my current contents to be placed into my model." |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
668 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
669 |
acceptChannel value:aBoolean. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
670 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
671 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
672 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
1013 | 673 |
! |
674 |
||
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
675 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
676 |
"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
|
677 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
678 |
(self at:lineNr) = aLine ifFalse:[ |
2357 | 679 |
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
|
680 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
681 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
682 |
|
522 | 683 |
at:lineNr put:aLine |
684 |
(self at:lineNr) = aLine ifFalse:[ |
|
2357 | 685 |
super at:lineNr put:aLine. |
686 |
self textChanged |
|
522 | 687 |
]. |
688 |
! |
|
689 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
690 |
characterBeforeCursor |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
691 |
"return the character under the cursor - space if behond line. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
692 |
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
|
693 |
of the insertion-bar or caret." |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
694 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
695 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
696 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
697 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
698 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
699 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
700 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
701 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
702 |
characterUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
703 |
"return the character under the cursor - space if behond line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
704 |
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
|
705 |
of the insertion-bar or caret." |
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 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
708 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
709 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
710 |
contents |
2213 | 711 |
"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
|
712 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
713 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
714 |
self removeTrailingBlankLines. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
715 |
^ list asStringWithCRs |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
716 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
717 |
|
2213 | 718 |
contentsAsString |
719 |
"return the contents as a String (i.e. without emphasis)" |
|
720 |
||
721 |
list isNil ifTrue:[^ '']. |
|
722 |
self removeTrailingBlankLines. |
|
723 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
724 |
ifFalse:[each string] |
|
725 |
]) asStringWithCRs |
|
726 |
! |
|
727 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
728 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
729 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
730 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
731 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
732 |
^ cursorCol |
125 | 733 |
! |
734 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
735 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
736 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
737 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
738 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
739 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
740 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
741 |
cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
742 |
"return the cursors line (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
743 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
744 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
745 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
746 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
747 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
748 |
cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
749 |
"return a valueHolder for the cursors line (1..). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
750 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
751 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
752 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
753 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
754 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
755 |
fixedSize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
756 |
"make the texts size fixed (no lines may be added). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
757 |
OBSOLETE: use readOnly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
758 |
|
2363 | 759 |
<resource:#obsolete> |
760 |
||
1018 | 761 |
self obsoleteMethodWarning:'use #readOnly:'. |
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
762 |
readOnly == true ifFalse:[ |
2357 | 763 |
readOnly := true. |
764 |
middleButtonMenu notNil ifTrue:[ |
|
765 |
middleButtonMenu disableAll:#(cut paste replace indent) |
|
766 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
767 |
] |
1018 | 768 |
|
769 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
|
127 | 770 |
! |
771 |
||
1037 | 772 |
isReadOnly |
773 |
"return true, if the text is readonly." |
|
774 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
775 |
^ readOnly value |
1037 | 776 |
|
777 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
778 |
! |
|
779 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
780 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
781 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
782 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
783 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
784 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
785 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
786 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
787 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
788 |
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
|
789 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
790 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
791 |
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
|
792 |
^ self cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
793 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
794 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
795 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
796 |
^ 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
|
797 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
798 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
799 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
800 |
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
|
801 |
^ self cursorHome |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
802 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
803 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
804 |
^ 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
|
805 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
806 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
807 |
"/ 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
|
808 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
809 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
810 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
811 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
812 |
modified |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
813 |
"return true if text was modified" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
814 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
815 |
^ modifiedChannel value |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
816 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
817 |
|
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
818 |
modified:aBoolean |
1013 | 819 |
"set/clear the modified flag" |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
820 |
|
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
821 |
modifiedChannel value:aBoolean |
1013 | 822 |
|
823 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
824 |
! |
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
825 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
826 |
modifiedChannel |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
827 |
"return the valueHolder holding true if text was modified" |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
828 |
|
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
829 |
^ modifiedChannel |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
830 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
831 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
832 |
modifiedChannel:aValueHolder |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
833 |
"set the valueHolder holding true if text was modified" |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
834 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
835 |
|prev| |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
836 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
837 |
prev := modifiedChannel. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
838 |
modifiedChannel := aValueHolder. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
839 |
self setupChannel:aValueHolder for:nil withOld:prev |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
840 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
841 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
842 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
843 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
844 |
readOnly |
1018 | 845 |
"make the text readonly. |
846 |
Somewhat obsolete - use #readOnly:" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
847 |
|
2363 | 848 |
<resource:#obsolete> |
849 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
850 |
self obsoleteMethodWarning:'use #readOnly:'. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
851 |
readOnly := true |
1018 | 852 |
|
853 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
854 |
! |
|
855 |
||
856 |
readOnly:aBoolean |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
857 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
858 |
The argument may also be a valueHolder." |
1018 | 859 |
|
860 |
readOnly := aBoolean |
|
861 |
||
862 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
863 |
! |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
864 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
865 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
866 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
867 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
868 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
869 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
870 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
871 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
872 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
873 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
874 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
875 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
876 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
877 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
878 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
879 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
880 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
881 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
882 |
wasOn := self hideCursor. |
1993 | 883 |
cursorFgColor := color1 onDevice:device. |
884 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
885 |
wasOn ifTrue:[self showCursor] |
1333 | 886 |
! |
887 |
||
1899 | 888 |
cursorType |
889 |
"return the style of the text cursor. |
|
890 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
2357 | 891 |
#bigCaret and #bigSolidCaret" |
1899 | 892 |
|
893 |
^ cursorType |
|
894 |
||
895 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
896 |
! |
|
897 |
||
1333 | 898 |
cursorType:aCursorTypeSymbol |
899 |
"set the style of the text cursor. |
|
900 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
2357 | 901 |
#bigCaret and #bigSolidCaret" |
1333 | 902 |
|
1334 | 903 |
cursorType := aCursorTypeSymbol. |
1333 | 904 |
|
905 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
906 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 907 |
! |
908 |
||
1899 | 909 |
cursorTypeNoFocus |
910 |
"return the style of the text cursor when the view has no focus. |
|
911 |
If left unspecified, this is the same as the regular cursorType." |
|
912 |
||
913 |
^ cursorTypeNoFocus |
|
914 |
||
915 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
916 |
! |
|
917 |
||
1334 | 918 |
cursorTypeNoFocus:aCursorTypeSymbol |
919 |
"set the style of the text cursor when the view has no focus. |
|
920 |
If left unspecified, this is the same as the regular cursorType." |
|
921 |
||
922 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
923 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
924 |
|
2119 | 925 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
926 |
|
125 | 927 |
accept |
928 |
"accept the current contents by executing the accept-action and/or |
|
929 |
changeMessage." |
|
930 |
||
1108 | 931 |
acceptEnabled == false ifTrue:[ |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
932 |
device beep. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
933 |
^ self |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
934 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
935 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
936 |
^ self |
1108 | 937 |
]. |
938 |
||
125 | 939 |
lockUpdates := true. |
1013 | 940 |
|
941 |
"/ |
|
942 |
"/ ST-80 way of doing it |
|
943 |
"/ |
|
944 |
model notNil ifTrue:[ |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
945 |
self sendChangeMessageWith:self argForChangeMessage. |
1013 | 946 |
]. |
947 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
948 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
949 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
950 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
951 |
"/ 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
|
952 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
953 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
954 |
acceptAction notNil ifTrue:[ |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
955 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
956 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
957 |
|
1811
348df65055eb
do not clear the modified flag on accept.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
958 |
"/ NO - must be manually reset by application |
348df65055eb
do not clear the modified flag on accept.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
959 |
"/ self modified:false. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
960 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
961 |
"/ self accepted:true. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
962 |
"/ changed to: |
2344
da0c69b10f2f
only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents:
2331
diff
changeset
|
963 |
model notNil ifTrue:[ |
da0c69b10f2f
only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents:
2331
diff
changeset
|
964 |
acceptChannel value:true withoutNotifying:self. |
da0c69b10f2f
only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents:
2331
diff
changeset
|
965 |
]. |
125 | 966 |
|
967 |
lockUpdates := false. |
|
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
968 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
969 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 970 |
! |
971 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
972 |
argForChangeMessage |
597 | 973 |
"return the argument to be passed with the change notification. |
974 |
Defined as separate method for easier subclassability." |
|
975 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
976 |
^ self contents |
597 | 977 |
|
978 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 979 |
! |
980 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
981 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
982 |
"get my contents from the model. |
597 | 983 |
Redefined to ignore updates resulting from my own changes |
984 |
(i.e. if lockUpdates is true)." |
|
121 | 985 |
|
986 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
987 |
ignore updates from my own change |
121 | 988 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
989 |
lockUpdates ifTrue:[ |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
990 |
lockUpdates := false. |
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
991 |
^ self |
121 | 992 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
993 |
super getListFromModel. |
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
994 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
995 |
"/ validate the cursorLine |
2310 | 996 |
(cursorLine notNil |
997 |
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
|
998 |
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
|
999 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1000 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1001 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1002 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1003 |
changedObject == acceptChannel ifTrue:[ |
2357 | 1004 |
acceptChannel value == true ifTrue:[ |
1005 |
self accept. |
|
1006 |
]. |
|
1007 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1008 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1009 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1010 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1011 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1012 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1013 |
! ! |
1014 |
||
1015 |
!EditTextView methodsFor:'cursor handling'! |
|
1016 |
||
2406 | 1017 |
characterPositionOfCursor |
1018 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1019 |
! |
|
1020 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1021 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1022 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1023 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1024 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1025 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1027 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1028 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1029 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1030 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1031 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1032 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1033 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1034 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1035 |
|
1036 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1037 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1038 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1039 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1040 |
"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
|
1041 |
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
|
1042 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1043 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1044 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1045 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1046 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1047 |
"/ cursor behond text ? |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1048 |
cursorLine > list size ifTrue:[ |
2357 | 1049 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1050 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
2357 | 1051 |
self makeCursorVisibleAndShowCursor:wasOn. |
1052 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1053 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1054 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1055 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1056 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1057 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1058 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1059 |
"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
|
1060 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1061 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1063 |
cursorVisibleLine notNil ifTrue:[ |
2357 | 1064 |
wasOn := self hideCursor. |
1065 |
nv := cursorVisibleLine + n - 1. |
|
1066 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1067 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1068 |
]. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1069 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
2357 | 1070 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1071 |
] ifFalse:[ |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1072 |
(nL := cursorLine) isNil ifTrue:[ |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1073 |
nL := firstLineShown |
2357 | 1074 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1075 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
2357 | 1076 |
self makeCursorVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1077 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1078 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1079 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1080 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1081 |
|
121 | 1082 |
cursorHome |
597 | 1083 |
"scroll to top AND move cursor to first line of text." |
121 | 1084 |
|
674 | 1085 |
self cursorLine:1 col:1 |
1086 |
||
1087 |
"/ |wasOn| |
|
1088 |
"/ |
|
1089 |
"/ wasOn := self hideCursor. |
|
1090 |
"/ self scrollToTop. |
|
1091 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1092 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1093 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1094 |
||
1095 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1096 |
! |
1097 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1098 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1099 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1100 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1101 |
(cursorCol ~~ 1) ifTrue:[ |
2357 | 1102 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1103 |
] ifFalse:[ |
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1104 |
"/ 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
|
1105 |
"/ cursorLine ~~ 1 ifTrue:[ |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1106 |
"/ 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
|
1107 |
"/ self cursorUp. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1108 |
"/ self cursorToEndOfLine. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1109 |
"/ ] |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1110 |
"/ ] |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1111 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1112 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1113 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
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 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1117 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1118 |
|
676 | 1119 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1120 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1121 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1122 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1123 |
|
672 | 1124 |
(col < 1) ifTrue:[ |
2357 | 1125 |
newCol := 1 |
672 | 1126 |
] ifFalse:[ |
2357 | 1127 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1128 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1129 |
self st80EditMode ifTrue:[ |
2357 | 1130 |
(cursorLine == list size |
1131 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1132 |
newCol := (self listAt:(list size)) size + 1. |
|
1133 |
] |
|
1419 | 1134 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1135 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1136 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1137 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1138 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1139 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1140 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1141 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1142 |
"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
|
1143 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1144 |
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
|
1145 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1146 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1147 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1148 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1149 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1150 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1151 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1152 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1153 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1154 |
"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
|
1155 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1156 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1157 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1158 |
self checkForExistingLine:(cursorLine + 1). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1159 |
cursorVisibleLine notNil ifTrue:[ |
2357 | 1160 |
nFullLinesShown notNil ifTrue:[ |
1161 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1162 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1163 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1165 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1166 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1167 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1168 |
|
674 | 1169 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1170 |
! |
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 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1173 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1174 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1175 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1176 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1177 |
self st80EditMode == true ifTrue:[ |
2357 | 1178 |
l := (self listAt:cursorLine). |
1179 |
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
|
1180 |
"/ 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
|
1181 |
"/ 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
|
1182 |
"/ self cursorReturn. |
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1183 |
"/ ]. |
2357 | 1184 |
^ self |
1185 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1186 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1187 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1188 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1189 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1190 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1191 |
|
1833 | 1192 |
cursorShown:aBoolean |
1193 |
"change cursor visibility |
|
1194 |
return true if cursor was visible before." |
|
1195 |
||
1196 |
|oldState| |
|
1197 |
||
1198 |
oldState := cursorShown. |
|
1199 |
||
1200 |
aBoolean ifTrue:[ |
|
2357 | 1201 |
self drawCursor. |
1833 | 1202 |
] ifFalse:[ |
2357 | 1203 |
(cursorShown and:[shown]) ifTrue: [ |
1204 |
self undrawCursor. |
|
1205 |
]. |
|
1833 | 1206 |
]. |
1207 |
cursorShown := aBoolean. |
|
1208 |
||
1209 |
^ oldState |
|
1210 |
||
1211 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1212 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1213 |
! |
|
1214 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1215 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1216 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1217 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1218 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1219 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1220 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1221 |
cursorToBeginOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1222 |
"move cursor to start of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1223 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1224 |
self cursorCol:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1225 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1226 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1227 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1228 |
"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
|
1229 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1230 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1231 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1232 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1233 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1234 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1235 |
(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
|
1236 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1237 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1238 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1239 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1240 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1241 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1242 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1243 |
|
674 | 1244 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1245 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1246 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1247 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1248 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1249 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1250 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1251 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1252 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1253 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1254 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1255 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1256 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1257 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1258 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1259 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1260 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1261 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1262 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1263 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1264 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1265 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1266 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1267 |
cursorLine >= lineNr ifTrue:[ |
2357 | 1268 |
line := self listAt:cursorLine. |
1269 |
(line isNil or:[line isEmpty]) ifTrue:[ |
|
1270 |
^ self |
|
1271 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1272 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1273 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1274 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1275 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1276 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1277 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1278 |
(newTop < 1) ifTrue:[ |
2357 | 1279 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1280 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1281 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1282 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1283 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1284 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1285 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1286 |
|
674 | 1287 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1288 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1289 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1290 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1291 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1292 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1293 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1294 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1295 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1296 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1297 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1298 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1299 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1300 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1301 |
cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1302 |
"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
|
1303 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1304 |
|wasOn newTop| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1305 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1306 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1307 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1308 |
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
|
1309 |
(newTop < 1) ifTrue:[ |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1310 |
newTop := 1 |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1311 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1312 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1313 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1314 |
self setValidatedCursorLine:list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1315 |
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
|
1316 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1317 |
self makeCursorVisibleAndShowCursor:wasOn. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1318 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1319 |
|
131 | 1320 |
cursorToFirstVisibleLine |
1321 |
"place cursor into the first visible line; do not scroll." |
|
1322 |
||
1323 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1324 |
! |
|
1325 |
||
1326 |
cursorToLastVisibleLine |
|
1327 |
"place cursor into the first visible line; do not scroll." |
|
1328 |
||
1329 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1330 |
! |
|
1331 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1332 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1333 |
"move the cursor to the beginning of the next word" |
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 |
|col line searching| |
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 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1338 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1339 |
self wordAtLine:cursorLine col:cursorCol do:[ |
2357 | 1340 |
:beginLine :beginCol :endLine :endCol :style | |
1341 |
||
1342 |
line := endLine. |
|
1343 |
col := endCol + 1. |
|
1344 |
searching := true. |
|
1345 |
[searching |
|
1346 |
and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
1347 |
self wordAtLine:line col:col do:[ |
|
1348 |
:beginLine :beginCol :endLine :endCol :style | |
|
1349 |
||
1350 |
(line > list size) ifTrue:[ |
|
1351 |
"break out" |
|
1352 |
searching := false |
|
1353 |
] ifFalse:[ |
|
1354 |
line := endLine. |
|
1355 |
col := endCol + 1. |
|
1356 |
] |
|
1357 |
] |
|
1358 |
]. |
|
1359 |
self cursorLine:line col:col |
|
121 | 1360 |
] |
1361 |
! |
|
1362 |
||
499 | 1363 |
cursorToPreviousWord |
1364 |
"move the cursor to the beginning of this or the previous word" |
|
1365 |
||
1366 |
|col line searching l| |
|
1367 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1368 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1369 |
|
1370 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
2357 | 1371 |
:beginLine :beginCol :endLine :endCol :style | |
1372 |
||
1373 |
line := beginLine. |
|
1374 |
col := beginCol. |
|
1375 |
style == #wordLeft ifTrue:[ |
|
1376 |
col := col + 1 |
|
1377 |
]. |
|
1378 |
||
1379 |
(cursorLine == line |
|
1380 |
and:[cursorCol == col]) ifTrue:[ |
|
1381 |
searching := true. |
|
1382 |
||
1383 |
col > 1 ifTrue:[ |
|
1384 |
col := col - 1. |
|
1385 |
]. |
|
1386 |
||
1387 |
[searching] whileTrue:[ |
|
1388 |
(col == 1) ifTrue:[ |
|
1389 |
line == 1 ifTrue:[ |
|
1390 |
searching := false |
|
1391 |
] ifFalse:[ |
|
1392 |
line := line - 1. |
|
1393 |
l := list at:line. |
|
1394 |
col := l size + 1. |
|
1395 |
] |
|
1396 |
] ifFalse:[ |
|
1397 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
1398 |
self wordAtLine:line col:col do:[ |
|
1399 |
:beginLine :beginCol :endLine :endCol :style | |
|
1400 |
||
1401 |
line := beginLine. |
|
1402 |
col := beginCol. |
|
1403 |
style == #wordLeft ifTrue:[ |
|
1404 |
col := col + 1 |
|
1405 |
]. |
|
1406 |
searching := false. |
|
1407 |
] |
|
1408 |
] ifTrue:[ |
|
1409 |
col := col - 1 |
|
1410 |
] |
|
1411 |
] |
|
1412 |
] |
|
1413 |
]. |
|
1414 |
self cursorLine:line col:col |
|
499 | 1415 |
] |
1416 |
||
1417 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
1418 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
1419 |
! |
|
1420 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1421 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1422 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1423 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1424 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1425 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1426 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1427 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1428 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1429 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1430 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1431 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1432 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1433 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1434 |
"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
|
1435 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1436 |
|wasOn nv nl| |
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 |
cursorLine isNil ifTrue:[ |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1439 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1440 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1443 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1444 |
(nl ~~ cursorLine) ifTrue: [ |
2357 | 1445 |
wasOn := self hideCursor. |
1446 |
cursorVisibleLine notNil ifTrue:[ |
|
1447 |
nv := cursorVisibleLine - n. |
|
1448 |
nv < 1 ifTrue:[ |
|
1449 |
self scrollUp:(nv negated + 1) |
|
1450 |
]. |
|
1451 |
]. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1452 |
self setValidatedCursorLine:nl col:cursorCol. |
2357 | 1453 |
wasOn ifTrue:[self showCursor]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1454 |
] |
672 | 1455 |
|
674 | 1456 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1457 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1458 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1459 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1460 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1461 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1462 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1463 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1464 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1465 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1466 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1467 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1468 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1469 |
|
676 | 1470 |
newCol := colNr. |
1471 |
(newCol < 1) ifTrue:[ |
|
2357 | 1472 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1473 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1474 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1475 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1476 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1477 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
1478 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1479 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1480 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1481 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1482 |
"put cursor to position next to x/y coordinate in view" |
121 | 1483 |
|
1484 |
|line col| |
|
1485 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1486 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1487 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1488 |
self cursorVisibleLine:line col:col. |
121 | 1489 |
! |
1490 |
||
1491 |
drawCursor |
|
1492 |
"draw the cursor if shown and cursor is visible. |
|
1493 |
(but not, if there is a selection - to avoid confusion)" |
|
1494 |
||
1495 |
shown ifTrue:[ |
|
2357 | 1496 |
cursorVisibleLine notNil ifTrue:[ |
1497 |
self hasSelection ifFalse:[ |
|
1498 |
self drawCursorCharacter |
|
1499 |
] |
|
1500 |
] |
|
121 | 1501 |
] |
1502 |
! |
|
1503 |
||
1504 |
drawCursor:cursorType with:fgColor and:bgColor |
|
1505 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 1506 |
of cursor should be drawn. |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1507 |
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
|
1508 |
#bigCaret and #bigSolidCaret" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1509 |
|
2570 | 1510 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 1511 |
|
1512 |
self hasSelection ifTrue:[ |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1513 |
" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1514 |
hide cursor, if there is a selection |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1515 |
" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1516 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 1517 |
]. |
1518 |
||
1334 | 1519 |
cursorType == #none ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1520 |
^ self |
1334 | 1521 |
]. |
1522 |
||
121 | 1523 |
cursorType == #block ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1524 |
super drawVisibleLine:cursorVisibleLine |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1525 |
col:cursorCol |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1526 |
with:fgColor |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1527 |
and:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1528 |
^ self |
121 | 1529 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1530 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 1531 |
y := self yOfVisibleLine:cursorVisibleLine. |
1532 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
1533 |
oldPaint := self paint. "/ do not clobber GC |
121 | 1534 |
cursorType == #frame ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1535 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1536 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1537 |
char := self characterUnderCursor asString. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1538 |
self paint:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1539 |
self displayRectangleX:x y:y |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1540 |
width:(font widthOf:char) height:fontHeight. |
133 | 1541 |
] ifFalse:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1542 |
self paint:bgColor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1543 |
cursorType == #ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1544 |
x1 := x - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1545 |
y2 := y + fontHeight - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1546 |
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
|
1547 |
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
|
1548 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1549 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1550 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1551 |
cursorType == #Ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1552 |
x1 := x - 1. |
2088 | 1553 |
y := y + 1. |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1554 |
y2 := y + fontHeight - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1555 |
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
|
1556 |
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
|
1557 |
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
|
1558 |
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
|
1559 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1560 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1561 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1562 |
y := y + fontHeight - 3. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1563 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1564 |
w := (fontWidth * 2 // 3) max:4. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1565 |
y2 := y + w + (w//2). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1566 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1567 |
w := (fontWidth // 2) max:4. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1568 |
y2 := y + w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1569 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1570 |
x1 := x - w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1571 |
x2 := x + w. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1572 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1573 |
oldClip := self clippingRectangleOrNil. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1574 |
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
|
1575 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1576 |
cursorType == #caret ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1577 |
self lineWidth:2. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1578 |
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
|
1579 |
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
|
1580 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1581 |
"anything else: solidCaret" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1582 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1583 |
self fillPolygon:(Array with:(x1 @ y2) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1584 |
with:(x @ y) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1585 |
with:(x2 @ y2)) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1586 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1587 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1588 |
self clippingRectangle:oldClip |
121 | 1589 |
]. |
133 | 1590 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
1591 |
|
2088 | 1592 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 1593 |
! |
1594 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1595 |
drawCursorCharacter |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1596 |
"draw the cursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1597 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1598 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1599 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1600 |
(hasKeyboardFocus |
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1601 |
and:[self enabled |
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1602 |
and:[readOnly not]]) ifTrue:[ |
2357 | 1603 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1604 |
] ifFalse:[ |
2357 | 1605 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1606 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1607 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1608 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1610 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1611 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1612 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1613 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1614 |
self hasSelection ifTrue:[ |
2357 | 1615 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 1616 |
]. |
1617 |
cursorType == #none ifTrue:[ |
|
2357 | 1618 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1620 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 1621 |
|
1622 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1624 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1625 |
drawNoFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1626 |
"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
|
1627 |
|
1334 | 1628 |
|cType| |
1629 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1630 |
self hasSelection ifTrue:[ |
2357 | 1631 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 1632 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1633 |
|
1334 | 1634 |
cType := cursorTypeNoFocus ? cursorType. |
1635 |
cType == #none ifTrue:[ |
|
2357 | 1636 |
^ self undrawCursor |
1334 | 1637 |
]. |
1638 |
||
1639 |
cType == #block ifTrue:[ |
|
2357 | 1640 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1641 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1642 |
|
1334 | 1643 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
1644 |
||
1645 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1646 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1648 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1649 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1650 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1651 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1652 |
self makeLineVisible:aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1653 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1654 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1655 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1656 |
hideCursor |
1833 | 1657 |
"make cursor invisible if currently invisible" |
1658 |
||
1659 |
^ self cursorShown:false |
|
1660 |
||
1661 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 1662 |
! |
1663 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1664 |
makeCursorVisible |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
"scroll text to make cursorline visible |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1666 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1667 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1668 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1669 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1670 |
cursorLine notNil ifTrue:[ |
2357 | 1671 |
line := cursorLine. |
1672 |
col := cursorCol. |
|
1673 |
" |
|
1674 |
if there is a selection, its better to |
|
1675 |
have its start being visible, instead of the end |
|
1676 |
" |
|
1677 |
(selectionStartLine notNil |
|
1678 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
1679 |
expandingTop ~~ false ifTrue:[ |
|
1680 |
line := selectionStartLine. |
|
1681 |
col := selectionStartCol. |
|
1682 |
] ifFalse:[ |
|
1683 |
line := selectionEndLine. |
|
1684 |
col := selectionEndCol |
|
1685 |
] |
|
1686 |
]. |
|
1687 |
self makeLineVisible:line. |
|
1688 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1689 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1690 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1691 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1692 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1693 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1694 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1695 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1696 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1697 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1698 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1699 |
flag ifTrue:[self showCursor] |
121 | 1700 |
! |
1701 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1702 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1703 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1704 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1705 |
cursorCol := colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1706 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1707 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1708 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1709 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1710 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1711 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1712 |
cursorLine := lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1713 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1714 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1715 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1716 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1717 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1718 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1719 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1720 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1721 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1722 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1723 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1724 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1725 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1726 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1727 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1728 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1729 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1730 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1731 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1732 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1733 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1734 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1735 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1736 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1737 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1738 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1739 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1740 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1741 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1742 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1743 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1744 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1745 |
|
1833 | 1746 |
^ self cursorShown:true |
1747 |
||
1748 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
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 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1752 |
"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
|
1753 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1754 |
|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
|
1755 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1756 |
cursorVisibleLine notNil ifTrue:[ |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1757 |
prevCol := cursorCol - 1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1758 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1759 |
"/ 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
|
1760 |
"/ redraw it completely (because characters overlap). |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1761 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1762 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1763 |
line hasChangeOfEmphasis ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1764 |
line size >= (cursorCol-1) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1765 |
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
|
1766 |
line size >= (cursorCol) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1767 |
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
|
1768 |
line size >= (cursorCol+1) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1769 |
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
|
1770 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1771 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1772 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1773 |
(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
|
1774 |
^ super redrawVisibleLine:cursorVisibleLine |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1775 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1776 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1777 |
] |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1778 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1779 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1780 |
((cursorType == #caret) |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1781 |
or:[cursorType == #solidCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1782 |
or:[cursorType == #bigSolidCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1783 |
or:[cursorType == #bigCaret |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1784 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1785 |
"caret-cursor touches 4 characters" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1786 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
2088 | 1787 |
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
|
1788 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1789 |
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
|
1790 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1791 |
"care for left margin" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1792 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1793 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1794 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1795 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1796 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1797 |
cursorType == #ibeam ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1798 |
"ibeam-cursor touches 2 characters" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1799 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1800 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1801 |
] ifFalse:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1802 |
"care for left margin" |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1803 |
super redrawVisibleLine:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1804 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1805 |
^ self |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1806 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1807 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1808 |
"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
|
1809 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1810 |
"/ 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
|
1811 |
"/ for the chars before/after the cursor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1812 |
"/ 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
|
1813 |
"/ detroyed by the block cursor. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1814 |
"/ (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
|
1815 |
|
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1816 |
line := self visibleAt:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1817 |
(line notNil and:[line isText]) ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1818 |
cursorCol > 1 ifTrue:[ |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1819 |
oldClip := self clippingRectangleOrNil. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1820 |
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
|
1821 |
y := self yOfVisibleLine:cursorVisibleLine. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1822 |
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
|
1823 |
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
|
1824 |
self clippingRectangle:oldClip. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1825 |
^ self. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1826 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1827 |
]. |
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1828 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1829 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1830 |
|
2088 | 1831 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 1832 |
! |
1833 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1834 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1835 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1836 |
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
|
1837 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1838 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
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 |
|
672 | 1841 |
validateCursorCol:col inLine:line |
674 | 1842 |
"check of col is a valid cursor position; return a new col-nr if not. |
1843 |
Here, no limits are enforced (and col is returned), |
|
1844 |
but it may be redefined in EditFields or views which dont like the |
|
1845 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
|
672 | 1846 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1847 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1848 |
|
1419 | 1849 |
"/ in ST80 mode, |
1850 |
"/ the cursor may not be positioned behond the |
|
1851 |
"/ end of a line or behond the last line of the text |
|
1852 |
"/ |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1853 |
self st80EditMode == true ifTrue:[ |
2357 | 1854 |
l := (self listAt:line). |
1855 |
max := l size + 1. |
|
1856 |
col > max ifTrue:[ |
|
1857 |
^ max |
|
1858 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1859 |
]. |
672 | 1860 |
^ col |
1861 |
||
1419 | 1862 |
"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
|
1863 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 1864 |
! |
1865 |
||
1866 |
validateCursorLine:line |
|
1867 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
1868 |
Here, no limits are enforced (and line is returned), but it may be |
|
1869 |
redefined in views which dont like the cursor to be positioned |
|
1870 |
behind the end of the text (vi/st-80 behavior), or want to |
|
1871 |
skip reserved regions" |
|
1872 |
||
1419 | 1873 |
"/ |
1874 |
"/ in st80Mode, the cursor may not be positioned |
|
1875 |
"/ behond the last line |
|
1876 |
"/ |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1877 |
self st80EditMode == true ifTrue:[ |
2357 | 1878 |
^ (line min:(list size)) max:1 |
1419 | 1879 |
]. |
674 | 1880 |
^ line |
1881 |
||
1419 | 1882 |
"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
|
1883 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 1884 |
! |
1885 |
||
121 | 1886 |
withCursorOffDo:aBlock |
1887 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
1888 |
||
1889 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
2357 | 1890 |
^ aBlock value |
121 | 1891 |
]. |
1892 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
1893 |
aBlock ensure:[ |
2357 | 1894 |
self showCursor |
121 | 1895 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1896 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1897 |
|
2589 | 1898 |
!EditTextView methodsFor:'drag & drop'! |
1899 |
||
1900 |
allowDrop:aBoolean |
|
1901 |
"enable/disable drop support |
|
1902 |
" |
|
1903 |
aBoolean ifFalse:[ |
|
1904 |
dropTarget := nil. |
|
1905 |
] ifTrue:[ |
|
1906 |
dropTarget ifNil:[ |
|
1907 |
dropTarget := DropTarget receiver:self |
|
1908 |
argument:nil |
|
1909 |
dropSelector:#'drop:' |
|
1910 |
canDropSelector:#'canDrop:' |
|
1911 |
] |
|
1912 |
]. |
|
1913 |
! |
|
1914 |
||
1915 |
canDrop:aContext |
|
1916 |
"I accept textObjects and fileObjects only |
|
1917 |
" |
|
1918 |
|objects| |
|
1919 |
||
1920 |
aContext sourceWidget == self ifTrue:[ |
|
1921 |
^ false |
|
1922 |
]. |
|
1923 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
1924 |
||
1925 |
objects := aContext dropObjects. |
|
1926 |
objects isEmpty ifTrue:[ ^ false ]. |
|
1927 |
||
1928 |
objects do:[:el| |
|
1929 |
(el isTextObject or:[el isFileObject]) ifFalse:[^ false]. |
|
1930 |
]. |
|
1931 |
^ true |
|
1932 |
! |
|
1933 |
||
1934 |
drop:aContext |
|
1935 |
"drop objects |
|
1936 |
" |
|
1937 |
|text| |
|
1938 |
||
1939 |
(self canDrop:aContext) ifFalse:[^ false]. |
|
1940 |
||
1941 |
text := StringCollection new. |
|
1942 |
||
1943 |
aContext dropObjects do:[:el| |obj| |
|
1944 |
obj := el theObject. |
|
1945 |
el isTextObject ifTrue:[ text addAll:obj ] |
|
1946 |
ifFalse:[ text add:(obj asString) ] |
|
1947 |
]. |
|
1948 |
self pasteOrReplace:text. |
|
1949 |
^ true |
|
1950 |
! |
|
1951 |
||
1952 |
dropTarget |
|
1953 |
"returns the dropTarget or nil |
|
1954 |
" |
|
1955 |
^ dropTarget |
|
1956 |
! |
|
1957 |
||
1958 |
dropTarget:aDropTragetOrNil |
|
1959 |
"set the dropTarget or nil |
|
1960 |
" |
|
1961 |
dropTarget := aDropTragetOrNil. |
|
1962 |
! ! |
|
1963 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1964 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1965 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1966 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1967 |
"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
|
1968 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1969 |
selectionStartLine notNil ifTrue:[ |
2357 | 1970 |
self setTextSelection:(self selection). |
1971 |
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
|
1972 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1973 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1974 |
"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
|
1975 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1976 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1977 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1978 |
"delete single character under cursor; does not merge lines" |
121 | 1979 |
|
1980 |
|wasOn| |
|
1981 |
||
1982 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 1984 |
wasOn ifTrue:[self showCursor] |
1985 |
! |
|
1986 |
||
827 | 1987 |
deleteCharAtLine:lineNr col:colNr |
1988 |
"delete a single character at colNr in line lineNr" |
|
1989 |
||
1990 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
|
1991 |
! |
|
1992 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1993 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
"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
|
1995 |
|
2491 | 1996 |
|soCol wasOn lineNrAboveCursor ln prevTab| |
121 | 1997 |
|
1998 |
wasOn := self hideCursor. |
|
2491 | 1999 |
autoIndent ifTrue:[ |
2000 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
|
2001 |
ln := (list at:cursorLine) ? ''. |
|
2002 |
ln size < prevTab ifTrue:[ |
|
2003 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2004 |
]. |
|
2005 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2006 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2007 |
cursorCol > prevTab ifTrue:[ |
|
2008 |
self cursorLine:cursorLine col:prevTab. |
|
2009 |
wasOn ifTrue:[ self showCursor ]. |
|
2010 |
^ self |
|
2011 |
]. |
|
2012 |
] ifFalse:[ |
|
2013 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2014 |
self cursorLine:cursorLine col:prevTab. |
|
2015 |
wasOn ifTrue:[ self showCursor ]. |
|
2016 |
^ self. |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2017 |
] |
2491 | 2018 |
]. |
827 | 2019 |
]. |
2020 |
||
2491 | 2021 |
"/ (autoIndent |
2022 |
"/ and:[cursorCol ~~ 1 |
|
2023 |
"/ and:[cursorLine <= (list size)]]) |
|
2024 |
"/ ifTrue:[ |
|
2025 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2026 |
"/ |
|
2027 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2028 |
"/ ln := list at:cursorLine. |
|
2029 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2030 |
"/ soCol := 1 |
|
2031 |
"/ ] |
|
2032 |
"/ ] |
|
2033 |
"/ ] ifFalse:[ |
|
2034 |
soCol := 1. |
|
2035 |
"/ ]. |
|
2036 |
||
1419 | 2037 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2038 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2039 |
somewhere in the middle of a line |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2040 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2041 |
self cursorLeft. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2042 |
self deleteCharAtLine:cursorLine col:cursorCol. |
1419 | 2043 |
] ifFalse:[ |
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2044 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2045 |
at begin of line - merge with previous line; |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2046 |
except for the very first line. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2047 |
" |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2048 |
(cursorLine == 1) ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2049 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2050 |
lineNrAboveCursor < cursorLine ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2051 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2052 |
"/ we are behond the end of the text. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2053 |
"/ move the cursor to the previous line. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2054 |
self cursorLine:lineNrAboveCursor col:1. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2055 |
] ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2056 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2057 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2058 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2059 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2060 |
]. |
827 | 2061 |
wasOn ifTrue:[ self showCursor ] |
2062 |
||
1419 | 2063 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2064 |
! |
2065 |
||
2066 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2067 |
"delete characters from colNr up to the end in line lineNr" |
|
2068 |
||
2069 |
|line| |
|
2070 |
||
2071 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
2357 | 2072 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2073 |
] |
2074 |
||
2075 |
! |
|
2076 |
||
2077 |
deleteCharsAtLine:lineNr toCol:colNr |
|
2078 |
"delete characters from start up to colNr in line lineNr" |
|
2079 |
||
2080 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2081 |
||
2082 |
||
121 | 2083 |
! |
2084 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2086 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
self deleteLine:cursorLine |
121 | 2089 |
! |
2090 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2091 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2092 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2093 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2094 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2095 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2096 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2097 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2098 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2099 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2100 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2101 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2102 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2103 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2104 |
|
827 | 2105 |
deleteLine:lineNr |
2106 |
"delete line" |
|
2107 |
||
2108 |
self deleteFromLine:lineNr toLine:lineNr |
|
2109 |
||
2110 |
||
2111 |
! |
|
2112 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2116 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2117 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2118 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2119 |
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
|
2120 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2121 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2122 |
(endLine > list size) ifTrue:[ |
2357 | 2123 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2124 |
] ifFalse:[ |
2357 | 2125 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2126 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2127 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2128 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2129 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2130 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2131 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2132 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2134 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2135 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2136 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2141 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2142 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2143 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2144 |
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
|
2145 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
selectionStartLine notNil ifTrue:[ |
2357 | 2147 |
wasOn := self hideCursor. |
2148 |
||
2149 |
startLine := selectionStartLine. |
|
2150 |
startCol := selectionStartCol. |
|
2151 |
endLine := selectionEndLine. |
|
2152 |
endCol := selectionEndCol. |
|
2153 |
self unselectWithoutRedraw. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2154 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2155 |
self setCursorLine:startLine col:startCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2156 |
|
2357 | 2157 |
self makeCursorVisibleAndShowCursor:wasOn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2158 |
] |
121 | 2159 |
! |
2160 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2161 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2162 |
"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
|
2163 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2164 |
|wasOn beginCol beginLine endCol endLine deletedText| |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2165 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2166 |
wasOn := self hideCursor. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2167 |
endCol := cursorCol-1. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2168 |
endLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2169 |
self cursorToPreviousWord. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2170 |
beginCol := cursorCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2171 |
beginLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2172 |
deletedText := self textFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2173 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2174 |
undoAction := [ |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2175 |
self cursorLine:beginLine col:beginCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2176 |
self paste:deletedText |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2177 |
]. |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2178 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2179 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2180 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2181 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2182 |
|
121 | 2183 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2184 |
"insert a single character at cursor-position - advance cursor." |
121 | 2185 |
|
2186 |
|wasOn| |
|
2187 |
||
2188 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2189 |
aCharacter == Character tab ifTrue:[ |
2357 | 2190 |
"/ needs special care to advance cursor correctly |
2191 |
self insertTabAtCursor |
|
121 | 2192 |
] ifFalse:[ |
2357 | 2193 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
2194 |
aCharacter == (Character cr) ifTrue:[ |
|
2195 |
self cursorReturn |
|
2196 |
] ifFalse:[ |
|
2197 |
self cursorRight. |
|
2198 |
]. |
|
121 | 2199 |
]. |
2200 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2201 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2202 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 2203 |
! |
2204 |
||
641 | 2205 |
insertLine:aString before:lineNr |
2206 |
"insert the line aString before line lineNr" |
|
2207 |
||
2208 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
2209 |
||
2210 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
2211 |
! |
|
2212 |
||
155 | 2213 |
insertLines:aStringCollection before:lineNr |
2214 |
"insert a bunch before line lineNr" |
|
2215 |
||
2216 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
2217 |
||
2218 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
2219 |
! |
|
2220 |
||
654 | 2221 |
insertLines:lines withCR:withCr |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2222 |
"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
|
2223 |
Cursor is moved behind insertion. |
641 | 2224 |
If withCr is true, append cr after last line" |
2225 |
||
2226 |
|start end nLines wasOn| |
|
2227 |
||
2228 |
lines notNil ifTrue:[ |
|
2357 | 2229 |
nLines := lines size. |
2230 |
(nLines == 1) ifTrue:[ |
|
2231 |
self insertStringAtCursor:(lines at:1). |
|
2232 |
withCr ifTrue:[ |
|
2233 |
self insertCharAtCursor:(Character cr) |
|
2234 |
] |
|
2235 |
] ifFalse:[ |
|
2236 |
(cursorCol ~~ 1) ifTrue:[ |
|
2237 |
self insertStringAtCursor:(lines at:1). |
|
2238 |
self insertCharAtCursor:(Character cr). |
|
2239 |
start := 2 |
|
2240 |
] ifFalse:[ |
|
2241 |
start := 1 |
|
2242 |
]. |
|
2243 |
withCr ifTrue:[ |
|
2244 |
end := nLines |
|
2245 |
] ifFalse:[ |
|
2246 |
end := nLines - 1 |
|
2247 |
]. |
|
2248 |
(start < nLines) ifTrue:[ |
|
2249 |
(end >= start) ifTrue:[ |
|
2250 |
wasOn := self hideCursor. |
|
2251 |
self insertLines:lines from:start to:end before:cursorLine. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2252 |
self setCursorLine:(cursorLine + (end - start + 1)). |
2357 | 2253 |
wasOn ifTrue:[self showCursor]. |
2254 |
] |
|
2255 |
]. |
|
2256 |
withCr ifFalse:[ |
|
2257 |
"last line without cr" |
|
2258 |
self insertStringAtCursor:(lines at:nLines) |
|
2259 |
] |
|
2260 |
] |
|
641 | 2261 |
] |
654 | 2262 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2263 |
"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
|
2264 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 2265 |
! |
2266 |
||
2267 |
insertLines:lines withCr:withCr |
|
2268 |
"insert a bunch of lines at cursor position. Cursor |
|
2269 |
is moved behind insertion. |
|
2270 |
If withCr is true, append cr after last line" |
|
2271 |
||
2363 | 2272 |
<resource:#obsolete> |
2273 |
||
1292 | 2274 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
2275 |
self insertLines:lines withCR:withCr. |
|
2276 |
||
2277 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 2278 |
! |
2279 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2283 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2284 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2285 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2287 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2288 |
self selectFromLine:startLine col:startCol |
2357 | 2289 |
toLine:cursorLine col:(cursorCol - 1) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2292 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2293 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2294 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2295 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2296 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2297 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2298 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2299 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2300 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2301 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2302 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2304 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2306 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2307 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2308 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2309 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2310 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2311 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2312 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2313 |
(aString includes:(Character cr)) ifFalse:[ |
2357 | 2314 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 2315 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2316 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2318 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2321 |
[start <= end] whileTrue:[ |
2357 | 2322 |
stop := aString indexOf:(Character cr) startingAt:start. |
2323 |
stop == 0 ifTrue:[ |
|
2324 |
stop := end + 1 |
|
2325 |
]. |
|
2326 |
subString := aString copyFrom:start to:(stop - 1). |
|
2327 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
2328 |
(stop <= end) ifTrue:[ |
|
2329 |
c := c + subString size. |
|
2330 |
self insert:(Character cr) atLine:l col:c. |
|
2331 |
l := l + 1. |
|
2332 |
c := 1 |
|
2333 |
]. |
|
2334 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2335 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2336 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2337 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 2338 |
! |
2339 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2340 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2341 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2342 |
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
|
2343 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2344 |
aString isNil ifTrue:[ |
2357 | 2345 |
"new:" |
2346 |
self insertCharAtCursor:(Character cr). |
|
2347 |
^ self |
|
105 | 2348 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2349 |
(aString includes:(Character cr)) ifFalse:[ |
2357 | 2350 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 2351 |
]. |
2352 |
||
654 | 2353 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2354 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2355 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 2356 |
! |
2357 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2358 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2359 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2361 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2362 |
shown ifTrue:[self redrawLine:lineNr from:colNr] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2363 |
|
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2364 |
"Modified: / 5.4.1998 / 16:51:14 / cg" |
105 | 2365 |
! |
2366 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2367 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2368 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2369 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2370 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2371 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2372 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2373 |
aString size > 0 ifTrue:[ |
2357 | 2374 |
wasOn := self hideCursor. |
2375 |
(aString includes:Character tab) ifTrue:[ |
|
2376 |
self checkForExistingLine:cursorLine. |
|
2377 |
oldLen := (list at:cursorLine) size. |
|
2378 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
2379 |
newLen := (list at:cursorLine) size. |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2380 |
deltaLen := newLen - oldLen. |
2357 | 2381 |
] ifFalse:[ |
2574 | 2382 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2383 |
deltaLen := aString size. |
2357 | 2384 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2385 |
self setCursorCol:(cursorCol + deltaLen). |
2357 | 2386 |
wasOn ifTrue:[self showCursor] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2387 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2388 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2389 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2390 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2391 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2392 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2393 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
|wasOn nextTab| |
105 | 2396 |
|
121 | 2397 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2400 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 2401 |
! |
2402 |
||
2506 | 2403 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2404 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2405 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2406 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2407 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2408 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2409 |
|
2506 | 2410 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
2411 |
(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
|
2412 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2413 |
newSelectionEnd := newSelectionEnd-1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2414 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2415 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2416 |
selectionStartLine == selectionEndLine ifTrue:[ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2417 |
newSelectionEnd := newSelectionEnd-1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2418 |
] |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2419 |
] ifFalse:[ |
2506 | 2420 |
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
|
2421 |
newSelectionEnd := newSelectionEnd+1. |
2506 | 2422 |
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
|
2423 |
selectionStartLine == selectionEndLine ifTrue:[ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2424 |
newSelectionEnd := newSelectionEnd+1. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2425 |
] |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2426 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2427 |
self |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2428 |
selectFromLine:selectionStartLine col:selectionStartCol |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2429 |
toLine:selectionEndLine col:newSelectionEnd. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2430 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2431 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2432 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2433 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2434 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2435 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2436 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2437 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2438 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2439 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2440 |
[finished] whileFalse:[ |
2357 | 2441 |
(lastLine <= 1) ifTrue:[ |
2442 |
finished := true |
|
2443 |
] ifFalse:[ |
|
2444 |
line := list at:lastLine. |
|
2445 |
line notNil ifTrue:[ |
|
2446 |
line isBlank ifTrue:[ |
|
2447 |
list at:lastLine put:nil. |
|
2448 |
line := nil |
|
2449 |
] |
|
2450 |
]. |
|
2451 |
line notNil ifTrue:[ |
|
2452 |
finished := true |
|
2453 |
] ifFalse:[ |
|
2454 |
lastLine := lastLine - 1 |
|
2455 |
] |
|
2456 |
] |
|
118 | 2457 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2458 |
(lastLine ~~ list size) ifTrue:[ |
2357 | 2459 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2460 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2461 |
] |
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 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2464 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2465 |
"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
|
2466 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2467 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2468 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2469 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2470 |
aCharacter == (Character cr) ifTrue:[ |
2357 | 2471 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2472 |
] ifFalse:[ |
2357 | 2473 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
2474 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2475 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2476 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2477 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2478 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2479 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2480 |
|
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2481 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2482 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2483 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2484 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2485 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2486 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2487 |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2488 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2489 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2490 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2491 |
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
|
2492 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2493 |
|
1809 | 2494 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2495 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2496 |
lines notNil ifTrue:[ |
2357 | 2497 |
wasOn := self hideCursor. |
2498 |
nLines := lines size. |
|
2499 |
line := cursorLine. |
|
2500 |
col := cursorCol. |
|
2501 |
lines keysAndValuesDo:[:i :l | |
|
2502 |
self replaceString:l atLine:line col:col. |
|
2503 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
2504 |
line := line + 1. |
|
2505 |
col := 1. |
|
2506 |
] ifFalse:[ |
|
2507 |
col := col + (l size). |
|
2508 |
] |
|
2509 |
]. |
|
2510 |
self cursorLine:line col:col. |
|
2511 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2512 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2513 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2514 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2515 |
"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
|
2516 |
"Modified: / 12.6.1998 / 22:05:51 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2517 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2518 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2519 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2520 |
"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
|
2521 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2522 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2523 |
self replaceSelectionBy:something keepCursor:false |
105 | 2524 |
! |
2525 |
||
2526 |
replaceSelectionBy:something keepCursor:keep |
|
2527 |
"delete the selection (if any) and insert something, a character or string; |
|
2528 |
leave cursor after insertion or leave it, depending on keep" |
|
2529 |
||
2530 |
|sel l c| |
|
2531 |
||
2532 |
l := cursorLine. |
|
2533 |
c := cursorCol. |
|
2534 |
||
2535 |
sel := self selection. |
|
2536 |
sel notNil ifTrue:[ |
|
2357 | 2537 |
lastString := sel. |
2538 |
self deleteSelection. |
|
2539 |
replacing := true. |
|
2540 |
lastReplacement := '' |
|
105 | 2541 |
]. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2542 |
|
105 | 2543 |
(something isMemberOf:Character) ifTrue:[ |
2357 | 2544 |
lastReplacement notNil ifTrue:[ |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2545 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2546 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2547 |
"/ lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2548 |
"/ lastReplacement := lastReplacement copyWith:something. |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2549 |
"/ lastReplacement := lastReplacement copyWith:Character space |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2550 |
"/ ] ifFalse:[ |
2357 | 2551 |
lastReplacement := lastReplacement copyWith:something. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2552 |
"/ ] |
2357 | 2553 |
]. |
2554 |
insertMode ifTrue:[ |
|
2555 |
self insertCharAtCursor:something |
|
2556 |
] ifFalse:[ |
|
2557 |
self replaceCharAtCursor:something |
|
2558 |
] |
|
105 | 2559 |
] ifFalse:[ |
2357 | 2560 |
lastReplacement := something. |
2561 |
insertMode ifTrue:[ |
|
2562 |
self insertStringAtCursor:something |
|
2563 |
] ifFalse:[ |
|
2564 |
self replaceStringAtCursor |
|
2565 |
] |
|
105 | 2566 |
]. |
2567 |
keep ifTrue:[ |
|
2357 | 2568 |
self cursorLine:l col:c |
105 | 2569 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2570 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2571 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2572 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2573 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2574 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2575 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2576 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2577 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2578 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2579 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2580 |
(aString includes:Character tab) ifTrue:[ |
2357 | 2581 |
"/ need special care for TAB (to move cursor correctly) |
2582 |
i1 := 1. |
|
2583 |
[i1 ~~ 0] whileTrue:[ |
|
2584 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
2585 |
i2 ~~ 0 ifTrue:[ |
|
2586 |
i1 ~~ i2 ifTrue:[ |
|
2587 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
2588 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
2589 |
]. |
|
2590 |
self replaceTABAtCursor. |
|
2591 |
i2 := i2 + 1. |
|
2592 |
] ifFalse:[ |
|
2593 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
2594 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
2595 |
]. |
|
2596 |
i1 := i2. |
|
2597 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2598 |
] ifFalse:[ |
2357 | 2599 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
2600 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2601 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2602 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2603 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2604 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2605 |
"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
|
2606 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2607 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2608 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2609 |
"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
|
2610 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2611 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2612 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2613 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2614 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2615 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2616 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2617 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2618 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2619 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2620 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2621 |
!EditTextView methodsFor:'editing - basic'! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2622 |
|
827 | 2623 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2624 |
"delete characters from startCol to endCol in line lineNr |
|
2625 |
" |
|
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
2626 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2627 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2628 |
line := self listAt:lineNr. |
827 | 2629 |
|
2630 |
(self checkModificationsAllowed and:[line notNil]) ifTrue:[ |
|
2207 | 2631 |
lineSize := line size. |
2632 |
||
2633 |
startCol == 0 ifFalse:[ start := startCol ] |
|
2634 |
ifTrue:[ start := 1 ]. |
|
2635 |
||
2636 |
endCol > lineSize ifFalse:[ stop := endCol ] |
|
2637 |
ifTrue:[ stop := lineSize ]. |
|
2638 |
||
2639 |
stop >= start ifTrue:[ |
|
2640 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
2641 |
ifFalse:[ newLine := '' ]. |
|
2642 |
||
2643 |
stop == lineSize ifFalse:[ |
|
2644 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
2645 |
newLine := line string species fromString:newLine. |
|
2646 |
]. |
|
2647 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
2648 |
]. |
|
2649 |
||
2650 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
2651 |
newLine := nil |
|
2652 |
]. |
|
2653 |
||
2654 |
prevWidth := self widthOfLine:lineNr. |
|
2655 |
||
2656 |
list at:lineNr put:newLine. |
|
2657 |
||
2658 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
2659 |
"/ remember old width of this line, |
|
2660 |
"/ only clear widthOfWidestLine, if this lines |
|
2661 |
"/ length was (one of) the longest. |
|
2662 |
"/ avoids slow delete with huge texts. |
|
2663 |
widthOfWidestLine := nil. "i.e. unknown" |
|
2664 |
||
2665 |
"/ scroll left if reqiured |
|
2666 |
viewOrigin x > 0 ifTrue:[ |
|
2667 |
newWidth := self widthOfLine:lineNr. |
|
2668 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
2669 |
self scrollHorizontalTo:(newWidth |
|
2670 |
- width |
|
2671 |
+ margin + margin |
|
2672 |
+ (font widthOf:' ')) |
|
2673 |
] |
|
2674 |
]. |
|
2675 |
self textChanged. |
|
2676 |
] ifFalse:[ |
|
2617 | 2677 |
self textChanged "/ textChangedButNoSizeChange |
2207 | 2678 |
]. |
2679 |
self redrawLine:lineNr from:start. |
|
2680 |
||
2681 |
] |
|
827 | 2682 |
] |
2683 |
||
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2684 |
"Modified: / 11.11.1998 / 00:01:09 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2685 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2686 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2687 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2688 |
"delete all text from startLine/startCol to endLine/endCol - |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2689 |
joining lines if nescessary" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2690 |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
2691 |
|line newLine lineSize nMore| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2692 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2693 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2694 |
list isNil ifTrue:[^ self]. |
960
29a592101ad4
care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2695 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2696 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2697 |
(startLine == endLine) ifTrue:[ |
2357 | 2698 |
"/ delete chars within a line |
2699 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2700 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2701 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2702 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2703 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
2357 | 2704 |
"/ delete full lines only |
2705 |
endLine > startLine ifTrue:[ |
|
2706 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2707 |
]. |
|
2708 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2709 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2710 |
|
641 | 2711 |
"/ delete right rest of 1st line |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2712 |
self deleteCharsAtLine:startLine fromCol:startCol. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2713 |
|
641 | 2714 |
"/ delete the inner lines ... |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2715 |
endLine > (startLine + 1) ifTrue:[ |
2357 | 2716 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2717 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2718 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2719 |
(endCol ~~ 0) ifTrue:[ |
2357 | 2720 |
"/ delete the left rest of the last line |
2721 |
||
2722 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2723 |
||
2724 |
"/ must add blanks, if startCol lies behond end of startLine |
|
2725 |
||
2726 |
line := list at:startLine. |
|
2727 |
lineSize := line size. |
|
2728 |
(startCol > lineSize) ifTrue:[ |
|
2729 |
newLine := line. |
|
2730 |
line isNil ifTrue:[ |
|
2731 |
newLine := String new:(startCol - 1) |
|
2732 |
] ifFalse:[ |
|
2733 |
nMore := startCol - 1 - lineSize. |
|
2734 |
nMore > 0 ifTrue:[ |
|
2735 |
newLine := line , (line species new:nMore) |
|
2736 |
] |
|
2737 |
]. |
|
2738 |
newLine ~~ line ifTrue:[ |
|
2739 |
list at:startLine put:newLine. |
|
2740 |
]. |
|
2741 |
"/ TODO: remember old maxwidth of linerange, |
|
2742 |
"/ only clear widthOfWidestLine, if this max |
|
2743 |
"/ length was (one of) the longest. |
|
2744 |
"/ avoids slow delete with huge texts. |
|
2745 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2746 |
self textChanged. |
|
2747 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2748 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2749 |
|
641 | 2750 |
"/ merge the left rest of 1st line with right rest of last line into one |
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
2751 |
self mergeLine:startLine removeBlanks:false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2752 |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2753 |
"Modified: / 10.11.1998 / 23:52:59 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2754 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2755 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2756 |
deleteFromLine:startLineNr toLine:endLineNr |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2757 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2758 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2759 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2760 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2761 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2762 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2763 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2764 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2765 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2766 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2767 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2768 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2769 |
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
|
2770 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2771 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2772 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2773 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2774 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2775 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2776 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2777 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2778 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2779 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2780 |
(firstLineShown >= nLines) ifTrue:[ |
2357 | 2781 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2782 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2783 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2784 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2785 |
"Modified: / 10.11.1998 / 23:55:05 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2786 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2787 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2788 |
deleteLineWithoutRedraw:lineNr |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2789 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2790 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2791 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2792 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2793 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2794 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2795 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2796 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2797 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2798 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2799 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2800 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2801 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2802 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2803 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2804 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2805 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2806 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2807 |
insert:aCharacter atLine:lineNr col:colNr |
827 | 2808 |
"insert a single character at lineNr/colNr; |
2809 |
set emphasis to character at current position" |
|
2810 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
2811 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2812 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2813 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2814 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2815 |
aCharacter == (Character cr) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2816 |
self splitLine:lineNr before:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2817 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2818 |
]. |
827 | 2819 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2820 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2821 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2822 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2823 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
2824 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2825 |
self st80EditMode ~~ true ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2826 |
(trimBlankLines |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2827 |
and:[colNr > lineSize |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2828 |
and:[aCharacter == Character space]]) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2829 |
^ self |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2830 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2831 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
2832 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2833 |
(lineSize == 0) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2834 |
newLine := aCharacter asString species new:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2835 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2836 |
] ifFalse: [ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2837 |
(colNr > lineSize) ifTrue: [ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2838 |
colNr == (lineSize +1) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2839 |
attribute := line emphasisAt:lineSize |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2840 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2841 |
newLine := line species new:colNr. |
2210 | 2842 |
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
|
2843 |
drawCharacterOnly := true |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2844 |
] ifFalse: [ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2845 |
attribute := line emphasisAt:colNr. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2846 |
newLine := line species new:(lineSize + 1). |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2847 |
|
2210 | 2848 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
2849 |
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
|
2850 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2851 |
]. |
827 | 2852 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2853 |
newLine at:colNr put:aCharacter. |
827 | 2854 |
|
2855 |
attribute notNil ifTrue:[ |
|
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2856 |
newLine emphasisAt:colNr put:attribute |
827 | 2857 |
]. |
2858 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2859 |
aCharacter == (Character tab) ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2860 |
newLine := self withTabsExpanded:newLine. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2861 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2862 |
]. |
827 | 2863 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2864 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2865 |
widthOfWidestLine notNil ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2866 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2867 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2868 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2869 |
shown ifTrue:[ |
2029
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2870 |
"/ 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
|
2871 |
"/ 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
|
2872 |
"/ 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
|
2873 |
"/ (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
|
2874 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2875 |
colNr > 1 ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2876 |
cursorVisibleLine notNil ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2877 |
oldClip := self clippingRectangleOrNil. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2878 |
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
|
2879 |
y := self yOfVisibleLine:cursorVisibleLine. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2880 |
drawCharacterOnly ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2881 |
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
|
2882 |
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
|
2883 |
] ifFalse:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2884 |
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
|
2885 |
self redrawLine:lineNr from:colNr-1 |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2886 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2887 |
self clippingRectangle:oldClip. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2888 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2889 |
^ self. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2890 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2891 |
]. |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2892 |
drawCharacterOnly ifTrue:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2893 |
self redrawLine:lineNr col:colNr |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2894 |
] ifFalse:[ |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2895 |
self redrawLine:lineNr from:colNr |
22629607c6eb
care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents:
2022
diff
changeset
|
2896 |
] |
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 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2899 |
"Modified: / 20.6.1998 / 18:19:22 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2900 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2901 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2902 |
insertLines:someText from:start to:end before:lineNr |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2903 |
"insert a bunch of lines before line lineNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2904 |
|
827 | 2905 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2906 |
srcY "{ Class: SmallInteger }" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2907 |
dstY "{ Class: SmallInteger }" | |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2908 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
2909 |
self isReadOnly ifTrue:[ |
2357 | 2910 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2911 |
]. |
827 | 2912 |
|
2913 |
autoIndent ifTrue:[ |
|
2357 | 2914 |
indent := self leftIndentForLine:lineNr. |
2915 |
||
2916 |
text := someText collect:[:ln||line| |
|
2917 |
ln notNil ifTrue:[ |
|
2918 |
line := ln withoutLeadingSeparators. |
|
2919 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
2920 |
line := (String new:indent), line |
|
2921 |
]. |
|
2922 |
line |
|
2923 |
] ifFalse:[ |
|
2924 |
nil |
|
2925 |
] |
|
2926 |
]. |
|
827 | 2927 |
] ifFalse:[ |
2357 | 2928 |
text := someText |
827 | 2929 |
]. |
2930 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2931 |
visLine := self listLineToVisibleLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2932 |
(shown not or:[visLine isNil]) ifTrue:[ |
2357 | 2933 |
self withoutRedrawInsertLines:text |
2934 |
from:start to:end |
|
2935 |
before:lineNr. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2936 |
] ifFalse:[ |
2357 | 2937 |
nLines := end - start + 1. |
2938 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
2939 |
self withoutRedrawInsertLines:text |
|
2940 |
from:start to:end |
|
2941 |
before:lineNr. |
|
2942 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
2943 |
] ifFalse:[ |
|
2944 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
2945 |
and:(firstLineShown + nLines + nLinesShown). |
|
2946 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
2947 |
dstY := srcY + (nLines * fontHeight). |
|
2948 |
||
2949 |
"/ |
|
2950 |
"/ scroll ... |
|
2951 |
"/ |
|
2952 |
" |
|
2953 |
stupid: must catchExpose before inserting new |
|
2954 |
stuff - since catchExpose may perform redraws |
|
2955 |
" |
|
2956 |
self catchExpose. |
|
2957 |
self withoutRedrawInsertLines:text |
|
2958 |
from:start to:end |
|
2959 |
before:lineNr. |
|
2960 |
self |
|
2961 |
copyFrom:self |
|
2962 |
x:textStartLeft y:srcY |
|
2963 |
toX:textStartLeft y:dstY |
|
2964 |
width:w |
|
2965 |
height:(height - dstY) |
|
2966 |
async:true. |
|
2967 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
2968 |
self waitForExpose |
|
2969 |
]. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2970 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2971 |
widthOfWidestLine notNil ifTrue:[ |
2357 | 2972 |
text do:[:line | |
2973 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
2974 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2975 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2976 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2977 |
|
984 | 2978 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2979 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2980 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2981 |
mergeLine:lineNr |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2982 |
"merge line lineNr with line lineNr+1" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2983 |
|
1319 | 2984 |
self mergeLine:lineNr removeBlanks:true |
2985 |
||
2986 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
2987 |
! |
|
2988 |
||
2989 |
mergeLine:lineNr removeBlanks:removeBlanks |
|
2990 |
"merge line lineNr with line lineNr+1" |
|
2991 |
||
827 | 2992 |
|leftPart rightPart bothParts nextLineNr i| |
2993 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2994 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2995 |
"/ empty list or behond end of text |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
2996 |
^ self |
827 | 2997 |
]. |
2998 |
leftPart := self listAt:lineNr. |
|
2999 |
||
3000 |
leftPart isNil ifTrue:[ |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3001 |
leftPart := ''. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3002 |
autoIndent ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3003 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3004 |
leftPart := String new:i |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3005 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3006 |
] |
827 | 3007 |
]. |
3008 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
3009 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
3010 |
||
3011 |
nextLineNr > (list size) ifFalse:[ |
|
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3012 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3013 |
rightPart := '' |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3014 |
] ifFalse:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3015 |
removeBlanks ifTrue:[ |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3016 |
rightPart := rightPart withoutLeadingSeparators. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3017 |
] |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3018 |
]. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3019 |
|
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3020 |
bothParts := leftPart , rightPart. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3021 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3022 |
list at:lineNr put:bothParts. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3023 |
self redrawLine:lineNr. |
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3024 |
self deleteLine:nextLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3025 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3026 |
|
1319 | 3027 |
"Created: 9.9.1997 / 09:27:38 / cg" |
3028 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3029 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3030 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3031 |
replace:aCharacter atLine:lineNr col:colNr |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3032 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3033 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3034 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3035 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3036 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3037 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3038 |
aCharacter == (Character cr) ifTrue:[ |
2357 | 3039 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3040 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3041 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3042 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3043 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3044 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3045 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3046 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3047 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3048 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3049 |
and:[aCharacter == Character space]]) ifTrue:[ |
2357 | 3050 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3051 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3052 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3053 |
(lineSize == 0) ifTrue:[ |
2357 | 3054 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3055 |
] ifFalse: [ |
2357 | 3056 |
(colNr > lineSize) ifTrue: [ |
3057 |
newLine := line species new:colNr. |
|
3058 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3059 |
] ifFalse: [ |
|
3060 |
newLine := line copy. |
|
3061 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3062 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3063 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3064 |
aCharacter == (Character tab) ifTrue:[ |
2357 | 3065 |
newLine := self withTabsExpanded:newLine. |
3066 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3067 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3068 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3069 |
widthOfWidestLine notNil ifTrue:[ |
2357 | 3070 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3071 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3072 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3073 |
shown ifTrue:[ |
2357 | 3074 |
drawCharacterOnly ifTrue:[ |
3075 |
self redrawLine:lineNr col:colNr |
|
3076 |
] ifFalse:[ |
|
3077 |
self redrawLine:lineNr from:colNr |
|
3078 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3079 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3080 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3081 |
"Created: / 6.3.1996 / 12:29:20 / cg" |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3082 |
"Modified: / 10.6.1998 / 18:50:18 / cg" |
105 | 3083 |
! |
3084 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3085 |
replaceString:aString atLine:lineNr col:colNr |
1557 | 3086 |
"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
|
3087 |
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
|
3088 |
in the string." |
1557 | 3089 |
|
3090 |
|line lineSize newLine endCol| |
|
3091 |
||
3092 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3093 |
||
3094 |
self checkForExistingLine:lineNr. |
|
3095 |
line := list at:lineNr. |
|
3096 |
lineSize := line size. |
|
3097 |
||
3098 |
endCol := colNr + aString size - 1. |
|
3099 |
(lineSize == 0) ifTrue:[ |
|
2357 | 3100 |
newLine := aString species new:endCol. |
1557 | 3101 |
] ifFalse: [ |
2357 | 3102 |
(endCol > lineSize) ifTrue: [ |
3103 |
aString isText ifTrue:[ |
|
3104 |
newLine := aString species new:endCol. |
|
3105 |
] ifFalse:[ |
|
3106 |
newLine := line species new:endCol. |
|
3107 |
]. |
|
3108 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3109 |
] ifFalse: [ |
|
3110 |
aString isText ifTrue:[ |
|
3111 |
newLine := aString species new:line size. |
|
3112 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3113 |
] ifFalse:[ |
|
3114 |
newLine := line copy. |
|
3115 |
] |
|
3116 |
] |
|
1557 | 3117 |
]. |
3118 |
newLine replaceFrom:colNr with:aString. |
|
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3119 |
(aString includes:(Character tab)) ifTrue:[ |
2357 | 3120 |
newLine := self withTabsExpanded:newLine. |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3121 |
]. |
1557 | 3122 |
list at:lineNr put:newLine. |
3123 |
widthOfWidestLine notNil ifTrue:[ |
|
2357 | 3124 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
1557 | 3125 |
]. |
3126 |
self textChanged. |
|
3127 |
shown ifTrue:[ |
|
2357 | 3128 |
self redrawLine:lineNr from:colNr |
1557 | 3129 |
] |
3130 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3131 |
"Created: / 11.6.1998 / 10:38:32 / cg" |
1599
63636b356b1f
care for emphasis when replacing.
Claus Gittinger <cg@exept.de>
parents:
1597
diff
changeset
|
3132 |
"Modified: / 20.6.1998 / 20:23:50 / cg" |
1557 | 3133 |
! |
3134 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3135 |
splitLine:lineNr before:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3136 |
"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
|
3137 |
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
|
3138 |
|
981
6e52d3876ea7
dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents:
960
diff
changeset
|
3139 |
|line lineSize leftRest rightRest visLine w h mustWait |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3140 |
srcY "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3141 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3142 |
list isNil ifFalse:[ |
2357 | 3143 |
lineNr > (list size) ifFalse:[ |
3144 |
(colNr == 1) ifTrue:[ |
|
3145 |
self insertLine:nil before:lineNr. |
|
3146 |
^ self |
|
3147 |
]. |
|
3148 |
line := list at:lineNr. |
|
3149 |
line isNil ifFalse:[ |
|
3150 |
lineSize := line size. |
|
3151 |
(colNr <= lineSize) ifTrue:[ |
|
3152 |
rightRest := line copyFrom:colNr to:lineSize. |
|
3153 |
(colNr > 1) ifTrue:[ |
|
3154 |
leftRest := line copyTo:(colNr - 1) |
|
3155 |
] |
|
3156 |
] ifFalse:[ |
|
3157 |
leftRest := line |
|
3158 |
] |
|
3159 |
]. |
|
3160 |
leftRest notNil ifTrue:[ |
|
3161 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
|
3162 |
]. |
|
3163 |
list at:lineNr put:leftRest. |
|
3164 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
|
3165 |
||
3166 |
visLine := self listLineToVisibleLine:(lineNr). |
|
3167 |
visLine notNil ifTrue:[ |
|
3168 |
w := self widthForScrollBetween:lineNr |
|
3169 |
and:(firstLineShown + nLinesShown). |
|
3170 |
srcY := topMargin + (visLine * fontHeight). |
|
3171 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
3172 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
3173 |
self catchExpose. |
|
3174 |
self |
|
3175 |
copyFrom:self |
|
3176 |
x:textStartLeft y:srcY |
|
3177 |
toX:textStartLeft y:(srcY + fontHeight) |
|
3178 |
width:w |
|
3179 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
3180 |
async:true. |
|
3181 |
]. |
|
3182 |
self redrawLine:lineNr. |
|
3183 |
self redrawLine:(lineNr + 1). |
|
3184 |
mustWait ifTrue:[self waitForExpose] |
|
3185 |
]. |
|
3186 |
widthOfWidestLine := nil. "/ unknown |
|
3187 |
self textChanged. |
|
3188 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3189 |
] |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3190 |
|
984 | 3191 |
"Modified: 29.1.1997 / 13:03:22 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3192 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3194 |
withoutRedrawInsertLine:aString before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3195 |
"insert the argument, aString before line lineNr; the string |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3196 |
becomes line nileNr; everything else is moved down; the view |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3197 |
is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3198 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3199 |
|line| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3200 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3201 |
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
|
3202 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3203 |
line := aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3204 |
line notNil ifTrue:[ |
2357 | 3205 |
line isString ifTrue:[ |
3206 |
line isBlank ifTrue:[ |
|
3207 |
line := nil |
|
3208 |
] ifFalse:[ |
|
3209 |
(line includes:(Character tab)) ifTrue:[ |
|
3210 |
line := self withTabsExpanded:line |
|
3211 |
] |
|
3212 |
] |
|
3213 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3214 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3215 |
list isNil ifTrue: [ |
2357 | 3216 |
list := StringCollection new:lineNr |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3217 |
] ifFalse: [ |
2357 | 3218 |
list grow:((list size + 1) max:lineNr) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3219 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3220 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3221 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3222 |
overlapping copy - if it didn't, we had to use:" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3223 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3224 |
index := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3225 |
[index > lineNr] whileTrue: [ |
2357 | 3226 |
pIndex := index - 1. |
3227 |
list at:index put:(list at:pIndex). |
|
3228 |
index := pIndex |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3229 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3230 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3231 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3232 |
list at:lineNr put:line. |
991
2d97ed971ce4
need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents:
984
diff
changeset
|
3233 |
self contentsChanged |
2d97ed971ce4
need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents:
984
diff
changeset
|
3234 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3235 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3236 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3237 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3238 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3239 |
"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
|
3240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3241 |
|newLine newLines nLines| |
121 | 3242 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3243 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3245 |
nLines := end - start + 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3246 |
newLines := Array new:(lines size). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3247 |
start to:end do:[:index | |
2357 | 3248 |
newLine := lines at:index. |
3249 |
newLine notNil ifTrue:[ |
|
3250 |
newLine isString ifTrue:[ |
|
3251 |
newLine isBlank ifTrue:[ |
|
3252 |
newLine := nil |
|
3253 |
] ifFalse:[ |
|
3254 |
(newLine includes:(Character tab)) ifTrue:[ |
|
3255 |
newLine := self withTabsExpanded:newLine |
|
3256 |
] |
|
3257 |
] |
|
3258 |
] |
|
3259 |
]. |
|
3260 |
newLines at:index put:newLine |
|
121 | 3261 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3262 |
list isNil ifTrue: [ |
2357 | 3263 |
list := StringCollection new:(lineNr + nLines + 1) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3264 |
] ifFalse: [ |
2357 | 3265 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3266 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3267 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3268 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3269 |
overlapping copy - if it didn't, we had to use:" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3270 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3271 |
index := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3272 |
[index > lineNr] whileTrue: [ |
2357 | 3273 |
pIndex := index - 1. |
3274 |
list at:index put:(list at:pIndex). |
|
3275 |
index := pIndex |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3276 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3277 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3278 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3279 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
991
2d97ed971ce4
need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents:
984
diff
changeset
|
3280 |
self contentsChanged |
2d97ed971ce4
need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents:
984
diff
changeset
|
3281 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3282 |
"Modified: / 10.6.1998 / 19:01:16 / cg" |
121 | 3283 |
! |
3284 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3285 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3286 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3287 |
|
827 | 3288 |
|isText strLen line lineSize newLine stringType sz| |
3289 |
||
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3290 |
(aString notNil) ifFalse:[ ^ self]. |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3291 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3292 |
strLen := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3293 |
self checkForExistingLine:lineNr. |
400
70fb3a81922f
better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents:
387
diff
changeset
|
3294 |
|
827 | 3295 |
stringType := aString string species. |
3296 |
isText := aString isText. |
|
3297 |
line := list at:lineNr. |
|
3298 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3299 |
line notNil ifTrue:[ |
2357 | 3300 |
lineSize := line size. |
2560 | 3301 |
line isString ifFalse:[ |
3302 |
stringType := line species |
|
3303 |
] ifTrue:[ |
|
3304 |
line bitsPerCharacter > aString bitsPerCharacter ifTrue:[ |
|
3305 |
stringType := line string species |
|
3306 |
]. |
|
3307 |
line isText ifTrue:[ isText := true ] |
|
2357 | 3308 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3309 |
] ifFalse:[ |
2357 | 3310 |
lineSize := 0 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3311 |
]. |
827 | 3312 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3313 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
2357 | 3314 |
newLine := aString |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3315 |
] ifFalse:[ |
2357 | 3316 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
3317 |
sz := colNr + strLen - 1 |
|
3318 |
] ifFalse:[ |
|
3319 |
sz := lineSize + strLen |
|
3320 |
]. |
|
3321 |
||
3322 |
isText ifFalse:[ |
|
3323 |
newLine := stringType new:sz |
|
3324 |
] ifTrue:[ |
|
3325 |
newLine := Text string:(stringType new:sz) |
|
3326 |
]. |
|
3327 |
||
3328 |
(lineSize ~~ 0) ifTrue: [ |
|
3329 |
(colNr > lineSize) ifTrue: [ |
|
3330 |
newLine replaceFrom:1 to:lineSize |
|
3331 |
with:line startingAt:1 |
|
3332 |
] ifFalse: [ |
|
3333 |
newLine replaceFrom:1 to:(colNr - 1) |
|
3334 |
with:line startingAt:1. |
|
3335 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) |
|
3336 |
with:line startingAt:colNr |
|
3337 |
] |
|
3338 |
]. |
|
3339 |
newLine replaceFrom:colNr to:(colNr + strLen - 1) |
|
3340 |
with:aString startingAt:1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3341 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3342 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3343 |
(aString includes:(Character tab)) ifTrue:[ |
2357 | 3344 |
newLine := self withTabsExpanded:newLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3345 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3346 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3347 |
list at:lineNr put:newLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3348 |
widthOfWidestLine notNil ifTrue:[ |
2357 | 3349 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3350 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3351 |
self textChanged. |
385
a373f2dd9c60
care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents:
362
diff
changeset
|
3352 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3353 |
"Modified: / 10.6.1998 / 19:01:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3354 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3355 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3356 |
!EditTextView methodsFor:'event processing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3357 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3358 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3359 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3361 |
hasKeyboardFocus := true. |
2589 | 3362 |
dragIsActive := false. |
3363 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3364 |
cursorShown ifTrue: [ |
2357 | 3365 |
self drawCursor |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3366 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3367 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3368 |
((button == 1) or:[button == #select]) ifTrue:[ |
2357 | 3369 |
self hideCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3370 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3371 |
(button == #paste) ifTrue:[ |
2357 | 3372 |
self pasteOrReplace. |
3373 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3374 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3375 |
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
|
3376 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3377 |
"Modified: / 23.3.1999 / 13:51:40 / cg" |
121 | 3378 |
! |
3379 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3380 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3381 |
"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
|
3382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3383 |
((button == 1) or:[button == #select]) ifTrue:[ |
2589 | 3384 |
typeOfSelection := nil. |
3385 |
||
3386 |
dragIsActive ifTrue:[ |
|
3387 |
self unselect |
|
3388 |
]. |
|
2357 | 3389 |
selectionStartLine isNil ifTrue:[ |
3390 |
clickCol notNil ifTrue:[ |
|
3391 |
self cursorMovementAllowed ifTrue:[ |
|
3392 |
self cursorLine:clickLine col:clickCol |
|
3393 |
] |
|
3394 |
] |
|
3395 |
] ifFalse:[ |
|
3396 |
lastString := nil. "new selection invalidates remembered string" |
|
3397 |
]. |
|
3398 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3399 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3400 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3401 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3402 |
"Modified: / 18.6.1998 / 14:14:05 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3403 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3404 |
|
2580 | 3405 |
cursorKeyPress:key shifted:shifted |
3406 |
||
3407 |
|sensor n| |
|
3408 |
||
3409 |
sensor := self sensor. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
3410 |
self changeTypeOfSelectionTo:nil. |
2580 | 3411 |
|
3412 |
(key == #CursorRight) ifTrue:[ |
|
3413 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3414 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3415 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
3416 |
expandingTop := false. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3417 |
self validateNewSelection. |
2580 | 3418 |
self redrawLine:selectionStartLine. |
3419 |
^ self. |
|
3420 |
]. |
|
3421 |
||
3422 |
selectionStartLine notNil ifTrue:[ |
|
3423 |
self cursorMovementAllowed ifTrue:[ |
|
3424 |
"/ |
|
3425 |
"/ treat the whole selection as cursor |
|
3426 |
"/ |
|
3427 |
self setCursorLine:selectionEndLine. |
|
3428 |
selectionEndCol == 0 ifTrue:[ |
|
3429 |
selectionEndCol := 1. |
|
3430 |
]. |
|
3431 |
self setCursorCol:selectionEndCol. |
|
3432 |
shifted ifTrue:[ |
|
3433 |
self expandSelectionRight. |
|
3434 |
^ self |
|
3435 |
]. |
|
3436 |
self unselect; makeCursorVisible. |
|
3437 |
cursorCol == 1 ifTrue:[^ self]. |
|
3438 |
]. |
|
3439 |
]. |
|
3440 |
self cursorRight. |
|
3441 |
^ self |
|
3442 |
]. |
|
3443 |
(key == #CursorDown) ifTrue:[ |
|
3444 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3445 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
3446 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3447 |
self validateNewSelection. |
2580 | 3448 |
self redrawLine:selectionStartLine. |
3449 |
expandingTop := false. |
|
3450 |
self redrawLine:selectionEndLine. |
|
3451 |
^ self |
|
3452 |
]. |
|
3453 |
||
3454 |
selectionStartLine notNil ifTrue:[ |
|
3455 |
self cursorMovementAllowed ifTrue:[ |
|
3456 |
"/ |
|
3457 |
"/ treat the whole selection as cursor |
|
3458 |
"/ |
|
3459 |
self setCursorLine:selectionEndLine. |
|
3460 |
self setCursorCol:selectionStartCol. |
|
3461 |
cursorCol == 0 ifTrue:[ |
|
3462 |
self setCursorCol:1. |
|
3463 |
self setCursorLine:(cursorLine - 1). |
|
3464 |
]. |
|
3465 |
self makeCursorVisible. |
|
3466 |
||
3467 |
shifted ifTrue:[ |
|
3468 |
clickLine := cursorLine. |
|
3469 |
clickCol := cursorCol. |
|
3470 |
self expandSelectionDown. |
|
3471 |
^ self |
|
3472 |
]. |
|
3473 |
self unselect. |
|
3474 |
]. |
|
3475 |
]. |
|
3476 |
||
3477 |
sensor isNil ifTrue:[ |
|
3478 |
n := 1 |
|
3479 |
] ifFalse:[ |
|
3480 |
n := 1 + (sensor compressKeyPressEventsWithKey:#CursorDown). |
|
3481 |
]. |
|
3482 |
self cursorDown:n. |
|
3483 |
"/ |
|
3484 |
"/ flush keyboard to avoid runaway cursor |
|
3485 |
"/ |
|
3486 |
sensor notNil ifTrue:[self sensor flushKeyboardFor:self]. |
|
3487 |
^ self |
|
3488 |
]. |
|
3489 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
3490 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
|
3491 |
expandingTop := true. |
|
3492 |
key == #CursorLeft ifTrue:[ |
|
3493 |
cursorCol > 1 ifTrue:[ |
|
3494 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3495 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
3496 |
selectionStartCol := cursorCol-1. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3497 |
self validateNewSelection. |
2580 | 3498 |
self redrawLine:selectionStartLine. |
3499 |
^ self |
|
3500 |
] |
|
3501 |
] ifFalse:[ |
|
3502 |
cursorLine > 1 ifTrue:[ |
|
3503 |
selectionEndLine := clickStartLine := cursorLine. |
|
3504 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
3505 |
selectionStartLine := cursorLine - 1. |
|
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
3506 |
self validateNewSelection. |
2580 | 3507 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3508 |
^ self |
|
3509 |
] |
|
3510 |
] |
|
3511 |
]. |
|
3512 |
||
3513 |
selectionStartLine notNil ifTrue:[ |
|
3514 |
self cursorMovementAllowed ifTrue:[ |
|
3515 |
"/ |
|
3516 |
"/ treat the whole selection as cursor |
|
3517 |
"/ |
|
3518 |
self setCursorLine:selectionStartLine. |
|
3519 |
self setCursorCol:selectionStartCol. |
|
3520 |
(key == #CursorLeft) ifTrue:[ |
|
3521 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
3522 |
]. |
|
3523 |
self makeCursorVisible. |
|
3524 |
||
3525 |
shifted ifTrue:[ |
|
3526 |
(key == #CursorUp) ifTrue:[ |
|
3527 |
clickLine := cursorLine. |
|
3528 |
self expandSelectionUp. |
|
3529 |
] ifFalse:[ |
|
3530 |
self expandSelectionLeft. |
|
3531 |
]. |
|
3532 |
^ self |
|
3533 |
]. |
|
3534 |
self unselect. |
|
3535 |
]. |
|
3536 |
]. |
|
3537 |
(key == #CursorLeft) ifTrue:[ |
|
3538 |
self cursorLeft. ^self |
|
3539 |
]. |
|
3540 |
(key == #CursorUp) ifTrue:[ |
|
3541 |
sensor isNil ifTrue:[ |
|
3542 |
n := 1 |
|
3543 |
] ifFalse:[ |
|
3544 |
n := 1 + (sensor compressKeyPressEventsWithKey:#CursorUp). |
|
3545 |
]. |
|
3546 |
self cursorUp:n. |
|
3547 |
"/ |
|
3548 |
"/ flush keyboard to avoid runaway cursor |
|
3549 |
"/ |
|
3550 |
sensor notNil ifTrue:[sensor flushKeyboardFor:self]. |
|
3551 |
^ self |
|
3552 |
]. |
|
3553 |
]. |
|
3554 |
! |
|
3555 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3556 |
keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3557 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3558 |
|
922 | 3559 |
<resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Accept |
2017 | 3560 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
3561 |
#SelectWord |
|
3562 |
#SearchMatchingParent #SelectMatchingParents |
|
3563 |
#SelectToEnd #SelectFromBeginning |
|
3564 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
3565 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
3566 |
#Return #Tab #Escape |
|
3567 |
#GotoLine #Delete #BeginOfText #EndOfText |
|
3568 |
#SelectLine #ExpandSelectionByLine #DeleteLine |
|
3569 |
#InsertLine |
|
3570 |
#SelectLineFromBeginning |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3571 |
#LearnKeyboardMacro #ExecuteKeyboardMacro |
2017 | 3572 |
#'F*' #'f*')> |
3573 |
||
2580 | 3574 |
|sensor fKeyMacros shifted i |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3575 |
selStartLine selEndLine selStartCol selEndCol sel event cmdMacro| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3576 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3577 |
event := WindowGroup lastEventQuerySignal query. |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3578 |
shifted := event hasShift. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3579 |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3580 |
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
|
3581 |
cmdMacro notNil ifTrue:[ |
2528
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3582 |
Error handle:[:ex | |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3583 |
self warn:'Error in keyboard macro: ' , ex description. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3584 |
ex return. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3585 |
] do:[ |
2528
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3586 |
AbortSignal handle:[:ex | |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3587 |
self warn:'Keyboard macro aborted'. |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3588 |
ex return. |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3589 |
] do:[ |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3590 |
Parser |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3591 |
evaluate:cmdMacro asString |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3592 |
receiver:self |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3593 |
notifying:nil |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3594 |
compile:false. |
65403577bfe6
catch errors while executing a macro
Claus Gittinger <cg@exept.de>
parents:
2522
diff
changeset
|
3595 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3596 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3597 |
^ self |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3598 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3599 |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3600 |
(key == #BackSpace |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3601 |
or:[key == #BasicBackspace]) ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3602 |
selectionStartLine notNil ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3603 |
(key == #BasicBackspace) ifTrue:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3604 |
self deleteSelection. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3605 |
] ifFalse: [ |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3606 |
self copyAndDeleteSelection. |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3607 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3608 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3609 |
]. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3610 |
|
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3611 |
self makeCursorVisible. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3612 |
shifted ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3613 |
self deleteWordBeforeCursor. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3614 |
] ifFalse:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3615 |
self deleteCharBeforeCursor. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3616 |
]. |
2207 | 3617 |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3618 |
^ self |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3619 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3620 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3621 |
(key == #LearnKeyboardMacro) ifTrue:[ |
2580 | 3622 |
self toggleLearnMode. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3623 |
^ self |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3624 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3625 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
2580 | 3626 |
self executeLearnedKeyboardMacro. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3627 |
^ self. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3628 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3629 |
learnMode == true ifTrue:[ |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3630 |
learnedMacro add:event. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3631 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3632 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3633 |
sensor := self sensor. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3634 |
"/ shifted := (sensor ? device) shiftDown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3635 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
(key isMemberOf:Character) ifTrue:[ |
2017 | 3637 |
self isReadOnly ifTrue:[ |
3638 |
self flash |
|
3639 |
] ifFalse:[ |
|
3640 |
typeOfSelection == #paste ifTrue:[ |
|
3641 |
"pasted selection will NOT be replaced by keystroke" |
|
3642 |
self unselect |
|
3643 |
]. |
|
3644 |
||
3645 |
selStartLine := selectionStartLine. |
|
3646 |
selStartCol := self selectionStartCol. |
|
3647 |
selEndLine := selectionEndLine. |
|
3648 |
selEndCol := self selectionEndCol. |
|
3649 |
sel := self selection. |
|
3650 |
||
3651 |
"replace selection by what is typed in - |
|
3652 |
if word was selected with a space, keep it" |
|
3653 |
||
3654 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3655 |
self replaceSelectionBy:(' ' copyWith:key) |
|
3656 |
] ifFalse:[ |
|
3657 |
(selectStyle == #wordRight) ifTrue:[ |
|
3658 |
self replaceSelectionBy:(key asString , ' '). |
|
3659 |
self cursorLeft |
|
3660 |
] ifFalse:[ |
|
3661 |
self replaceSelectionBy:key |
|
3662 |
] |
|
3663 |
]. |
|
3664 |
selectStyle := nil. |
|
3665 |
||
2018 | 3666 |
sel size > 0 ifTrue:[ |
3667 |
undoAction := [ |
|
3668 |
self cursorLine:selStartLine col:selStartCol. |
|
3669 |
self deleteCharAtCursor. |
|
3670 |
self paste:sel. |
|
3671 |
]. |
|
3672 |
]. |
|
2017 | 3673 |
|
3674 |
showMatchingParenthesis ifTrue:[ |
|
3675 |
"emacs style parenthesis shower" |
|
3676 |
||
3677 |
"claus: only do it for closing parenthesis - |
|
3678 |
otherwise its too anoying. |
|
3679 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3680 |
" |
2017 | 3681 |
(#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3682 |
" |
2017 | 3683 |
(#( $) $] $} ) includes:key) ifTrue:[ |
2554 | 3684 |
self |
3685 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
3686 |
ifFound:[:line :col | |
|
3687 |
|savLine savCol| |
|
3688 |
||
3689 |
self withCursor:Cursor eye do:[ |
|
3690 |
savLine := cursorLine. |
|
3691 |
savCol := cursorCol. |
|
3692 |
self cursorLine:line col:col. |
|
3693 |
device flush. |
|
3694 |
"/ want to wait 200ms, but not if another keyPress |
|
3695 |
"/ arrives in the meantime ... |
|
3696 |
"/ |
|
3697 |
5 timesRepeat:[ |
|
3698 |
(sensor notNil and:[sensor hasKeyPressEventFor:self]) ifFalse:[ |
|
3699 |
Processor activeProcess millisecondDelay:40. |
|
3700 |
] |
|
3701 |
]. |
|
3702 |
self cursorLine:savLine col:savCol |
|
3703 |
] |
|
3704 |
] |
|
3705 |
ifNotFound:[self showNotFound] |
|
3706 |
onError:[self beep] |
|
2017 | 3707 |
]. |
3708 |
]. |
|
3709 |
]. |
|
3710 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3711 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3712 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3713 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3714 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3715 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3716 |
Fn pastes a key-sequence (but only if not overlayed with |
2017 | 3717 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3718 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3719 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3720 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
3721 |
(key at:1) asLowercase == $f ifTrue:[ |
2017 | 3722 |
(('[fF][0-9]' match:key) |
3723 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
3724 |
shifted ifFalse:[ |
|
3725 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
3726 |
fKeyMacros notNil ifTrue:[ |
|
3727 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
3728 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
3729 |
^ self |
|
3730 |
] |
|
3731 |
] |
|
3732 |
] |
|
3733 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3734 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3735 |
|
2506 | 3736 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3737 |
self parenthizeSelectionWith:$( and:$). |
|
3738 |
^ self. |
|
3739 |
]. |
|
3740 |
(key == #'Ctrl2') ifTrue:[ |
|
3741 |
self parenthizeSelectionWith:$" and:$". |
|
3742 |
^ self. |
|
3743 |
]. |
|
3744 |
(key == #'Ctrl#') ifTrue:[ |
|
3745 |
self parenthizeSelectionWith:$' and:$'. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3746 |
^ self. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3747 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3748 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
3749 |
(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
|
3750 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3751 |
((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3752 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3753 |
(key == #Again) ifTrue:[self again. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3754 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3755 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3756 |
(key == #SelectWord) ifTrue:[ |
2017 | 3757 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3758 |
self selectWordUnderCursor. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3759 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3760 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3761 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3762 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3763 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3764 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3765 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3766 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3767 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3768 |
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
|
3769 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
3770 |
(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
|
3771 |
(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
|
3772 |
(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
|
3773 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3774 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3775 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3776 |
(key == #BeginOfLine) ifTrue:[ |
2017 | 3777 |
self unselect. |
3778 |
shifted ifTrue:[ |
|
3779 |
self cursorHome |
|
3780 |
] ifFalse:[ |
|
3781 |
self cursorToBeginOfLine. |
|
3782 |
]. |
|
3783 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3784 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3785 |
(key == #EndOfLine) ifTrue:[ |
2017 | 3786 |
self unselect. |
3787 |
shifted ifTrue:[ |
|
3788 |
self cursorToBottom |
|
3789 |
] ifFalse:[ |
|
3790 |
self cursorToEndOfLine. |
|
3791 |
]. |
|
3792 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
3793 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3794 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
499 | 3795 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3796 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3797 |
|
2580 | 3798 |
(key == #CursorRight |
3799 |
or:[key == #CursorDown |
|
3800 |
or:[key == #CursorLeft |
|
3801 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3802 |
self cursorKeyPress:key shifted:shifted. |
|
3803 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3804 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3805 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3806 |
(key == #Return) ifTrue:[ |
2017 | 3807 |
shifted ifTrue:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3808 |
self unselect. self cursorReturn. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3809 |
^ self |
2017 | 3810 |
]. |
3811 |
self isReadOnly ifTrue:[ |
|
3812 |
self unselect; makeCursorVisible. |
|
3813 |
self cursorReturn |
|
3814 |
] ifFalse:[ |
|
3815 |
insertMode ifFalse:[ |
|
3816 |
self cursorReturn. |
|
3817 |
autoIndent == true ifTrue:[ |
|
3818 |
i := self leftIndentForLine:(cursorLine + 1). |
|
3819 |
self cursorCol:(i+1 max:1) |
|
3820 |
] |
|
3821 |
] ifTrue:[ |
|
3822 |
"/ old version just unselected ... |
|
3823 |
"/ self unselect; makeCursorVisible. |
|
3824 |
||
3825 |
"/ new version deletes ... |
|
3826 |
typeOfSelection == #paste ifTrue:[ |
|
3827 |
self unselect; makeCursorVisible. |
|
3828 |
] ifFalse:[ |
|
3829 |
self copyAndDeleteSelection. |
|
3830 |
]. |
|
3831 |
self insertCharAtCursor:(Character cr). |
|
3832 |
autoIndent == true ifTrue:[ |
|
3833 |
i := self leftIndentForLine:cursorLine. |
|
3834 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
3835 |
self cursorCol:(i+1 max:1) |
|
3836 |
]. |
|
3837 |
]. |
|
3838 |
]. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3839 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3840 |
]. |
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
|
3841 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3842 |
(key == #Tab) ifTrue:[ |
2017 | 3843 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
3844 |
||
3845 |
shifted ifTrue:[ |
|
3846 |
" |
|
3847 |
the old version used shift-tab as backtab, |
|
3848 |
however, backtab was seldom used. |
|
3849 |
An alternative is to make it a non-inserting tab ... |
|
3850 |
" |
|
3851 |
"/ self unselect. self cursorBacktab. |
|
3852 |
self unselect. self cursorTab. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3853 |
^ self |
2017 | 3854 |
]. |
3855 |
||
3856 |
" |
|
3857 |
uncomment line below, if you like RAND/INed/MAXed editor behavior |
|
3858 |
(where tab-key is only cursor positioning) |
|
3859 |
this was the original behavior of the TAB key, but many people |
|
3860 |
complained .... |
|
3861 |
" |
|
3862 |
insertMode ifFalse:[ |
|
3863 |
self unselect. self cursorTab. ^self |
|
3864 |
]. |
|
3865 |
self unselect. self insertTabAtCursor. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3866 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3867 |
]. |
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
|
3868 |
|
870 | 3869 |
(key == #Delete |
3870 |
or:[key == #BasicDelete]) ifTrue:[ |
|
2017 | 3871 |
selectionStartLine notNil ifTrue:[ |
3872 |
(key == #BasicDelete) ifTrue:[ |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3873 |
self deleteSelection. |
2017 | 3874 |
] ifFalse:[ |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3875 |
self copyAndDeleteSelection. |
2017 | 3876 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3877 |
^ self |
2017 | 3878 |
]. |
3879 |
self makeCursorVisible. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3880 |
self deleteCharAtCursor. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3881 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3882 |
]. |
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
|
3883 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3884 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
2017 | 3885 |
self unselect. |
3886 |
cursorVisibleLine == 1 ifTrue:[ |
|
3887 |
self cursorHome. |
|
3888 |
] ifFalse:[ |
|
3889 |
self cursorToFirstVisibleLine |
|
3890 |
]. |
|
3891 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3892 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3893 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
2017 | 3894 |
self unselect. |
3895 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
3896 |
self cursorToBottom. |
|
3897 |
] ifFalse:[ |
|
3898 |
self cursorToLastVisibleLine |
|
3899 |
]. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3900 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3901 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3902 |
((key == #Escape) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3903 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
2017 | 3904 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3905 |
self unselect. self selectCursorLineFromBeginning. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3906 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3907 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3908 |
(key == #SelectLine) ifTrue:[ |
2017 | 3909 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3910 |
self unselect. self selectCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
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 |
(key == #ExpandSelectionByLine) ifTrue:[ |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3914 |
"/ self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3915 |
self selectExpandCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3916 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3917 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3918 |
(key == #DeleteLine) ifTrue:[ |
2017 | 3919 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3920 |
self unselect. self deleteCursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3921 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3922 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3923 |
(key == #InsertLine) ifTrue:[ |
2017 | 3924 |
self makeCursorVisible. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3925 |
self unselect. self insertLine:nil before:cursorLine. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3926 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3927 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3928 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3929 |
|
1446
609e20a4a234
Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents:
1439
diff
changeset
|
3930 |
"Modified: / 6.2.1998 / 11:59:59 / stefan" |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3931 |
"Modified: / 22.2.2000 / 23:01:23 / cg" |
121 | 3932 |
! |
3933 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3934 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3935 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3937 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3938 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3939 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3940 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3941 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3942 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3944 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3945 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3946 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3947 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
cv notNil ifTrue:[ |
2357 | 3949 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3950 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3951 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3952 |
|
1807 | 3953 |
!EditTextView methodsFor:'focus handling'! |
3954 |
||
3955 |
hasKeyboardFocus:aBoolean |
|
3956 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
3957 |
(otherwise, I would not know about this)" |
|
3958 |
||
3959 |
hasKeyboardFocus := aBoolean. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
3960 |
(cursorShown |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
3961 |
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
|
3962 |
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
|
3963 |
self drawCursor |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
3964 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
3965 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
3966 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 3967 |
! |
3968 |
||
3969 |
showFocus:explicit |
|
3970 |
"in addition to however my superclass thinks how a focusView is to be |
|
3971 |
displayed, show the cursor when I got the focus" |
|
3972 |
||
3973 |
self showCursor. |
|
3974 |
self hasKeyboardFocus:true. |
|
3975 |
super showFocus:explicit |
|
3976 |
||
3977 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3978 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3979 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3980 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3981 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3982 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3983 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3984 |
|pref| |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3985 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3986 |
pref := UserPreferences current focusFollowsMouse. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3987 |
(pref ~~ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3988 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3989 |
and:[self enabled |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3990 |
and:[readOnly not]]]) ifTrue:[ |
2357 | 3991 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3992 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3993 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3994 |
^ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3995 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3996 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
3997 |
|
1807 | 3998 |
! ! |
3999 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4000 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4001 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4002 |
indent |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4003 |
"indent selected line-range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4004 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4005 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4007 |
selectionStartLine isNil ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4008 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4009 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4010 |
(selectionEndCol == 0) ifTrue:[ |
2357 | 4011 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4012 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4013 |
self unselect. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4014 |
self indentFromLine:start toLine:end |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4015 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4016 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4017 |
indentFromLine:start toLine:end |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4018 |
"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
|
4019 |
last non-empty line before start, and change the indent |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
of the line based on that indent." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4022 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4023 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4024 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4025 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4027 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4028 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4029 |
(delta > 0) ifTrue:[ |
2357 | 4030 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4031 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4032 |
start to:end do:[:lineNr | |
2357 | 4033 |
line := self listAt:lineNr. |
4034 |
line notNil ifTrue:[ |
|
4035 |
line isBlank ifTrue:[ |
|
4036 |
list at:lineNr put:nil |
|
4037 |
] ifFalse:[ |
|
4038 |
(delta > 0) ifTrue:[ |
|
4039 |
line := spaces , line. |
|
4040 |
widthOfWidestLine notNil ifTrue:[ |
|
4041 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4042 |
] |
|
4043 |
] ifFalse:[ |
|
4044 |
"check if deletion is ok" |
|
4045 |
d := delta negated + 1. |
|
4046 |
||
4047 |
line size > d ifTrue:[ |
|
4048 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
4049 |
line := line copyFrom:d |
|
4050 |
] |
|
4051 |
]. |
|
4052 |
widthOfWidestLine := nil |
|
4053 |
]. |
|
4054 |
list at:lineNr put:line. |
|
4055 |
self textChanged. |
|
4056 |
] |
|
4057 |
] |
|
121 | 4058 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4059 |
self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4060 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4061 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4062 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4063 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4064 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4065 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4066 |
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
|
4067 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4068 |
|
827 | 4069 |
"SHOULD GO TO ListView" |
4070 |
||
4071 |
|line lnr indent| |
|
4072 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4073 |
lnr := lineNr. |
827 | 4074 |
|
4075 |
[lnr ~~ 1] whileTrue:[ |
|
2357 | 4076 |
lnr := lnr - 1. |
4077 |
line := self listAt:lnr. |
|
4078 |
||
4079 |
line notNil ifTrue:[ |
|
4080 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
4081 |
indent ~~ 0 ifTrue:[ |
|
4082 |
^ indent - 1 |
|
4083 |
] |
|
4084 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4085 |
]. |
827 | 4086 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4087 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4088 |
"Created: 5.3.1996 / 14:58:53 / cg" |
105 | 4089 |
! ! |
4090 |
||
0 | 4091 |
!EditTextView methodsFor:'initialization'! |
4092 |
||
941 | 4093 |
fetchDeviceResources |
4094 |
"fetch device colors, to avoid reallocation at redraw time" |
|
4095 |
||
4096 |
super fetchDeviceResources. |
|
4097 |
||
1993 | 4098 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
4099 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
4100 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 4101 |
|
4102 |
"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
|
4103 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 4104 |
! |
4105 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4106 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4107 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4108 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4109 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4110 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4111 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4112 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4113 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4114 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4116 |
super initStyle. |
2088 | 4117 |
lineSpacing := 1. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4118 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4119 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4120 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4121 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4122 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4123 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 4124 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4125 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
2088 | 4126 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4127 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4128 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4129 |
cursorNoFocusFgColor isNil ifTrue:[ |
2088 | 4130 |
cursorType ~~ #block ifTrue:[ |
4131 |
cursorNoFocusFgColor := cursorBgColor |
|
4132 |
] ifFalse:[ |
|
4133 |
cursorNoFocusFgColor := cursorFgColor |
|
4134 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4135 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4136 |
|
2088 | 4137 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4138 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4139 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4140 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4141 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4142 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4143 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4144 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4145 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4146 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4147 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4148 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4149 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4150 |
cursorShown := prevCursorState := true. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4151 |
cursorLineHolder := 1 asValue. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4152 |
cursorColHolder := 1 asValue. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4153 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4154 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4155 |
cursorCol := 1. |
2119 | 4156 |
modifiedChannel := ValueHolder with:false. |
4157 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
4158 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4159 |
showMatchingParenthesis := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4160 |
hasKeyboardFocus := false. "/ true. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4161 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4162 |
autoIndent := false. |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4163 |
insertMode := true. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4164 |
"/ st80Mode := ST80Mode. |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4165 |
"/ trimBlankLines := st80Mode not. "true." |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4166 |
trimBlankLines := self st80EditMode not. "true." |
2131 | 4167 |
cursorMovementWhenUpdating := #beginOfText. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
4168 |
|
2589 | 4169 |
"/ on default enable drop |
4170 |
self allowDrop:true. "/ readOnly tested in #canDrop: |
|
0 | 4171 |
! ! |
4172 |
||
2580 | 4173 |
!EditTextView methodsFor:'macros'! |
4174 |
||
4175 |
executeLearnedKeyboardMacro |
|
4176 |
((learnMode == false) and:[learnedMacro size > 0]) ifTrue:[ |
|
4177 |
learnedMacro do:[:event | |
|
4178 |
WindowGroup lastEventQuerySignal answer:event |
|
4179 |
do:[ |
|
4180 |
self |
|
4181 |
dispatchEvent:event |
|
4182 |
withFocusOn:nil |
|
4183 |
delegate:false |
|
4184 |
] |
|
4185 |
]. |
|
4186 |
] ifFalse:[ |
|
4187 |
self flash. |
|
4188 |
]. |
|
4189 |
! |
|
4190 |
||
4191 |
learnMode:aBoolean |
|
4192 |
|fg bg| |
|
4193 |
||
4194 |
learnMode := aBoolean. |
|
4195 |
learnMode ifTrue:[ |
|
4196 |
learnedMacro := OrderedCollection new. |
|
4197 |
fg := Color white. |
|
4198 |
bg := Color black. |
|
4199 |
] ifFalse:[ |
|
4200 |
cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor. |
|
4201 |
cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor. |
|
4202 |
]. |
|
4203 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
4204 |
! |
|
4205 |
||
4206 |
toggleLearnMode |
|
4207 |
self learnMode: (learnMode ? false) not. |
|
4208 |
! ! |
|
4209 |
||
121 | 4210 |
!EditTextView methodsFor:'menu actions'! |
4211 |
||
4212 |
cut |
|
4213 |
"cut selection into copybuffer" |
|
4214 |
||
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4215 |
|line col history sel s| |
121 | 4216 |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4217 |
(self checkModificationsAllowed) ifFalse:[ |
2121 | 4218 |
self flash. |
4219 |
^ self |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4220 |
]. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4221 |
|
121 | 4222 |
sel := self selection. |
4223 |
sel notNil ifTrue:[ |
|
2121 | 4224 |
lastString := s := sel asStringWithCRs. |
4225 |
line := selectionStartLine. |
|
4226 |
col := selectionStartCol. |
|
4227 |
undoAction := [ |
|
4228 |
self cursorLine:line col:col. |
|
4229 |
self paste:sel "/ (Array with:s) withCR:false. |
|
4230 |
]. |
|
4231 |
||
4232 |
" |
|
4233 |
remember in CopyBuffer |
|
4234 |
" |
|
4235 |
self setTextSelection:sel. "/ lastString. |
|
4236 |
||
4237 |
" |
|
4238 |
append to DeleteHistory (if there is one) |
|
4239 |
" |
|
4240 |
history := Smalltalk at:#DeleteHistory. |
|
4241 |
history notNil ifTrue:[ |
|
4242 |
history addAll:(sel asStringCollection). |
|
4243 |
history size > 1000 ifTrue:[ |
|
4244 |
history := history copyFrom:(history size - 1000) |
|
4245 |
]. |
|
4246 |
]. |
|
4247 |
||
4248 |
" |
|
4249 |
now, delete it |
|
4250 |
" |
|
4251 |
self deleteSelection. |
|
4252 |
lastReplacement := nil |
|
121 | 4253 |
] ifFalse:[ |
2121 | 4254 |
" |
4255 |
a cut without selection will search&cut again |
|
4256 |
" |
|
4257 |
self again |
|
121 | 4258 |
] |
1290 | 4259 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4260 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
121 | 4261 |
! |
4262 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4263 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4264 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4265 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4266 |
cursorLine notNil ifTrue:[ |
2357 | 4267 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4268 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4269 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4270 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4271 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4272 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4273 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4274 |
|
488 | 4275 |
<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
|
4276 |
<resource: #programMenu> |
1054 | 4277 |
|
1809 | 4278 |
|items m sub sensor| |
1515 | 4279 |
|
2460 | 4280 |
items := #( |
2540
56b92c7a787c
menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
4281 |
('Again (for All)' multipleAgain ) |
2460 | 4282 |
('-' ) |
4283 |
('Search...' search Find ) |
|
4284 |
('Goto...' gotoLine GotoLine ) |
|
4285 |
('-' ) |
|
4286 |
('Font...' changeFont ) |
|
4287 |
('Indent' indent ) |
|
4288 |
('AutoIndent \c' autoIndent: ) |
|
4289 |
('InsertMode \c' insertMode: ) |
|
4290 |
('-' ) |
|
2580 | 4291 |
('LearnMode \c' learnMode: LearnKeyboardMacro) |
4292 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4293 |
"/ ('Special Characters' specialCharacters ) |
2580 | 4294 |
('-' ) |
2540
56b92c7a787c
menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
4295 |
('Save As...' save SaveAs ) |
2460 | 4296 |
('Print' doPrint Print ) |
4297 |
). |
|
4298 |
||
4299 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
|
4300 |
sub checkToggleAt:#autoIndent: put:autoIndent. |
|
4301 |
sub checkToggleAt:#insertMode: put:insertMode. |
|
2580 | 4302 |
sub checkToggleAt:#learnMode: put:(learnMode ? false). |
2461 | 4303 |
sub receiver:self. |
2460 | 4304 |
|
1515 | 4305 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
2460 | 4306 |
m := sub |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4307 |
] ifFalse:[ |
2017 | 4308 |
items := #( |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4309 |
('Undo' undo ) |
2403 | 4310 |
('Again' again Again ) |
2017 | 4311 |
('-' ) |
2403 | 4312 |
('Copy' copySelection Copy ) |
4313 |
('Cut' cut Cut ) |
|
4314 |
('Paste' pasteOrReplace Paste ) |
|
2017 | 4315 |
('-' ) |
2403 | 4316 |
('Accept' accept Accept ) |
2017 | 4317 |
('=' ) |
2460 | 4318 |
('Others' others Ctrl ) |
2017 | 4319 |
). |
2460 | 4320 |
m := PopUpMenu itemList:items resources:resources. |
4321 |
||
4322 |
m subMenuAt:#others put:sub. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4323 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4324 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4325 |
self isReadOnly ifTrue:[ |
2017 | 4326 |
m disableAll:#(paste pasteOrReplace cut indent autoIndent: insertMode:) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4327 |
]. |
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2344
diff
changeset
|
4328 |
self hasSelectionForCopy not ifTrue:[ |
2017 | 4329 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4330 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4331 |
self hasSelection ifFalse:[ |
2017 | 4332 |
m disable:#cut. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4333 |
]. |
2569 | 4334 |
self hasUndoAction ifFalse:[ |
2017 | 4335 |
m disable:#undo. |
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4336 |
]. |
1108 | 4337 |
acceptEnabled == false ifTrue:[ |
2017 | 4338 |
m disable:#accept |
1108 | 4339 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4340 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4341 |
|
2461 | 4342 |
"Modified: / 13.11.2001 / 10:39:16 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4343 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4344 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4345 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4346 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4347 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4348 |
history := device getCopyBufferHistory copy. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4349 |
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
|
4350 |
box := ListSelectionBox |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4351 |
title:'CopyBuffer History' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4352 |
okText:'Paste' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4353 |
abortText:'Cancel' |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4354 |
list:list |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4355 |
action:[:idx | idx notNil ifTrue:[ sel := history at:idx]]. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4356 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4357 |
box show. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4358 |
^ sel. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4359 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4360 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4361 |
getTextSelectionOrTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4362 |
device shiftDown ifTrue:[ |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4363 |
^ self getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4364 |
]. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4365 |
^ self getTextSelection |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4366 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4367 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4368 |
paste |
1289 | 4369 |
"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
|
4370 |
Then paste at cursor position." |
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 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4373 |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4374 |
self checkModificationsAllowed ifFalse:[ |
2357 | 4375 |
self flash. |
4376 |
^ self |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4377 |
]. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4378 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4379 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4380 |
self unselect. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4381 |
sel notNil ifTrue:[ |
2357 | 4382 |
self paste:sel. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4383 |
] |
1289 | 4384 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4385 |
"Modified: / 5.4.1998 / 16:55:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4386 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4387 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4388 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4389 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4390 |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4391 |
|s nLines startLine startCol l1 l2 c1 c2| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4392 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4393 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4394 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4395 |
someText notNil ifTrue:[ |
2017 | 4396 |
s := someText. |
4397 |
s isString ifTrue:[ |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4398 |
s := s asStringCollection. |
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4399 |
(someText endsWith:Character cr) ifTrue:[ |
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4400 |
s := s copyWith:'' |
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4401 |
] |
2017 | 4402 |
] ifFalse:[ |
4403 |
(s isStringCollection) ifFalse:[ |
|
4404 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
4405 |
^ self |
|
4406 |
] |
|
4407 |
]. |
|
4408 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
4409 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
4410 |
||
2599
e577ba0b605e
typeOfSelection when pasting
Claus Gittinger <cg@exept.de>
parents:
2596
diff
changeset
|
4411 |
typeOfSelection := #paste. |
e577ba0b605e
typeOfSelection when pasting
Claus Gittinger <cg@exept.de>
parents:
2596
diff
changeset
|
4412 |
|
2017 | 4413 |
startLine := l1 := cursorLine. |
4414 |
startCol := c1 := cursorCol. |
|
4415 |
self insertLines:(s withTabsExpanded) withCR:false. |
|
4416 |
l2 := cursorLine. |
|
4417 |
c2 := (cursorCol - 1). |
|
4418 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
|
2599
e577ba0b605e
typeOfSelection when pasting
Claus Gittinger <cg@exept.de>
parents:
2596
diff
changeset
|
4419 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
e577ba0b605e
typeOfSelection when pasting
Claus Gittinger <cg@exept.de>
parents:
2596
diff
changeset
|
4420 |
|
2017 | 4421 |
undoAction := [ |
4422 |
self unselect. |
|
4423 |
self deleteFromLine:l1 col:c1 toLine:l2 col:c2. |
|
4424 |
self cursorLine:l1 col:c1. |
|
4425 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4426 |
] |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
4427 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4428 |
"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
|
4429 |
"Modified: / 30.1.2000 / 02:32:42 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4430 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4431 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4432 |
pasteOrReplace |
1289 | 4433 |
"paste the copybuffer; if there is a selection, replace it. |
2010 | 4434 |
otherwise paste at cursor position. |
4435 |
Replace is not done for selections which were created by a paste, |
|
4436 |
to allow multiple paste operations in a row." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4437 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4438 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4439 |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4440 |
self checkModificationsAllowed ifFalse:[ |
2357 | 4441 |
self flash. |
4442 |
^ self |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4443 |
]. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4444 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4445 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
2010 | 4446 |
sel notNil ifTrue:[ |
2357 | 4447 |
self pasteOrReplace:sel. |
2010 | 4448 |
]. |
1289 | 4449 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4450 |
"Modified: / 5.4.1998 / 16:55:16 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4451 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4452 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4453 |
pasteOrReplace:someText |
1289 | 4454 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4455 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4456 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4457 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4458 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4459 |
self checkModificationsAllowed ifFalse:[^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4460 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4461 |
^ self replace:someText |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4462 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4463 |
self paste:someText. |
1289 | 4464 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
4465 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4466 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4467 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4468 |
replace |
1289 | 4469 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4470 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4471 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4472 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4473 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4474 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4475 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4476 |
sel notNil ifTrue:[ |
2357 | 4477 |
self replace:sel |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4478 |
] |
1289 | 4479 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4480 |
"Modified: / 5.4.1998 / 16:55:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4481 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4482 |
|
121 | 4483 |
replace:someText |
1289 | 4484 |
"replace the selection by someText" |
121 | 4485 |
|
2017 | 4486 |
|selected selectedString |
4487 |
selStartLine selStartCol selEndLine selEndCol pasteUndoAction| |
|
121 | 4488 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4489 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4490 |
|
121 | 4491 |
selected := self selection. |
4492 |
selected isNil ifTrue:[ |
|
2017 | 4493 |
^ self paste:someText |
121 | 4494 |
]. |
2017 | 4495 |
|
121 | 4496 |
self deleteSelection. |
4497 |
||
4498 |
"take care, if we replace a selection without space by a word selected |
|
4499 |
with one - in this case we usually do not want the space. |
|
4500 |
But, if we replace a word-selected selection by something without a |
|
4501 |
space, we DO want the space added." |
|
4502 |
||
4503 |
selected size == 1 ifTrue:[ |
|
2017 | 4504 |
selectedString := selected at:1. |
7 | 4505 |
]. |
4506 |
||
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
4507 |
someText size == 1 ifTrue:[ |
2017 | 4508 |
|cutOffSpace addSpace replacement replacementString| |
4509 |
||
4510 |
cutOffSpace := false. |
|
4511 |
addSpace := false. |
|
2432
af5d3ff6204b
be careful if replacing a symbol (which cannot be changed)
Claus Gittinger <cg@exept.de>
parents:
2429
diff
changeset
|
4512 |
replacement := someText copyFrom:1. |
2017 | 4513 |
|
4514 |
selectedString notNil ifTrue:[ |
|
4515 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
4516 |
"selection has no space" |
|
4517 |
||
4518 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
4519 |
cutOffSpace := true |
|
4520 |
] |
|
4521 |
] ifTrue:[ |
|
4522 |
addSpace := true |
|
4523 |
] |
|
4524 |
]. |
|
4525 |
replacementString := replacement at:1. |
|
4526 |
cutOffSpace ifTrue:[ |
|
4527 |
(replacementString startsWith:' ') ifTrue:[ |
|
4528 |
replacementString := replacementString withoutSpaces |
|
4529 |
]. |
|
4530 |
] ifFalse:[ |
|
4531 |
selectStyle == #wordLeft ifTrue:[ |
|
4532 |
"want a space at left" |
|
4533 |
(replacementString startsWith:' ') ifFalse:[ |
|
4534 |
replacementString := replacementString withoutSpaces. |
|
4535 |
replacementString := ' ' , replacementString |
|
4536 |
] |
|
4537 |
]. |
|
4538 |
selectStyle == #wordRight ifTrue:[ |
|
4539 |
"want a space at right" |
|
4540 |
||
4541 |
(replacementString endsWith:' ') ifFalse:[ |
|
4542 |
replacementString := replacementString withoutSpaces. |
|
4543 |
replacementString := replacementString , ' ' |
|
4544 |
] |
|
4545 |
]. |
|
4546 |
]. |
|
4547 |
replacement at:1 put: replacementString. |
|
4548 |
self paste:replacement. |
|
121 | 4549 |
] ifFalse:[ |
2017 | 4550 |
self paste:someText |
7 | 4551 |
]. |
121 | 4552 |
lastString := selectedString. |
2017 | 4553 |
lastReplacement := someText. |
4554 |
||
4555 |
selStartLine := selectionStartLine. |
|
4556 |
selStartCol := self selectionStartCol. |
|
4557 |
selEndLine := selectionEndLine. |
|
4558 |
selEndCol := self selectionEndCol. |
|
4559 |
pasteUndoAction := undoAction. |
|
4560 |
||
4561 |
undoAction := [ |
|
4562 |
pasteUndoAction value. |
|
4563 |
self cursorLine:selStartLine col:selEndLine. |
|
4564 |
self paste:selected. |
|
4565 |
]. |
|
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
4566 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4567 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4568 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 4569 |
! |
4570 |
||
4571 |
showDeleted |
|
4572 |
"open a readonly editor on all deleted text" |
|
4573 |
||
4574 |
|v| |
|
4575 |
||
4576 |
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
|
4577 |
v readOnly:true. |
121 | 4578 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4579 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4580 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4581 |
specialCharacters |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4582 |
|v p m buttonExtent genButton insertCharacter| |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4583 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4584 |
insertCharacter := [:char | (WindowGroup scheduledWindowGroups |
2626
feb63169a8fa
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2625
diff
changeset
|
4585 |
select:[:g | g graphicsDevice == self device]) |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4586 |
doWithExit:[:g :exit | |v| |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4587 |
(v := g focusView) notNil ifTrue:[ |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4588 |
v isKeyboardConsumer ifTrue:[ |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4589 |
(char isString ifTrue:[char] ifFalse:[Array with:char]) |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4590 |
do:[:char | |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4591 |
v dispatchEvent:(WindowEvent keyPress:char x:0 y:0 view:v). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4592 |
v dispatchEvent:(WindowEvent keyRelease:char x:0 y:0 view:v). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4593 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4594 |
exit value:nil. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4595 |
] |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4596 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4597 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4598 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4599 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4600 |
genButton := [:char :fix | |b| |
2625
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4601 |
char == Character space ifTrue:[ |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4602 |
b := View new extent:10@5.. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4603 |
] ifFalse:[ |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4604 |
b := Button label:char asString. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4605 |
b action:[insertCharacter value:char]. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4606 |
b extent:buttonExtent. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4607 |
b sizeFixed:fix. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4608 |
]. |
6732633db7b5
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2624
diff
changeset
|
4609 |
b |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4610 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4611 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4612 |
v := View new. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4613 |
v addComponent:(p := VerticalPanelView new). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4614 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4615 |
buttonExtent := ((Button onDevice:Screen current) label:'W') preferredExtent. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4616 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4617 |
p addComponent:(m := HorizontalPanelView new). |
2627
da953ada26d6
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2626
diff
changeset
|
4618 |
m horizontalLayout:#left. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4619 |
'äâáà êéè îíì öôóò üûúù ß' do:[:char | |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4620 |
m addComponent:(genButton value:char value:true). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4621 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4622 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4623 |
p addComponent:(m := HorizontalPanelView new). |
2627
da953ada26d6
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2626
diff
changeset
|
4624 |
m horizontalLayout:#left. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4625 |
'ÄÂÁÀ ÊÉÈ ÎÍÌ ÖÔÓÒ ÜÛÚÙ ' do:[:char | |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4626 |
m addComponent:(genButton value:char value:true). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4627 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4628 |
|
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4629 |
p addComponent:(m := HorizontalPanelView new). |
2627
da953ada26d6
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2626
diff
changeset
|
4630 |
m horizontalLayout:#left. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4631 |
#('ifTrue:' 'ifFalse:' 'whileTrue:' 'whileFalse') do:[:char | |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4632 |
m addComponent:(genButton value:char value:false). |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4633 |
]. |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
4634 |
v open. |
105 | 4635 |
! ! |
4636 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4637 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4638 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
4639 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
4640 |
"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
|
4641 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
4642 |
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
|
4643 |
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
|
4644 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4645 |
self isReadOnly ifTrue: [ |
2357 | 4646 |
exceptionBlock isNil ifTrue:[ |
4647 |
^ false |
|
4648 |
]. |
|
4649 |
||
4650 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
4651 |
^ false |
|
4652 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
4653 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
4654 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
4655 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
4656 |
"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
|
4657 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
4658 |
|
2596 | 4659 |
currentSelectionBgColor |
4660 |
typeOfSelection == #paste ifTrue:[ |
|
4661 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
|
4662 |
]. |
|
4663 |
^ super currentSelectionBgColor |
|
4664 |
||
4665 |
" |
|
4666 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
4667 |
" |
|
4668 |
! |
|
4669 |
||
4670 |
currentSelectionFgColor |
|
4671 |
typeOfSelection == #paste ifTrue:[ |
|
4672 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
|
4673 |
]. |
|
4674 |
^ super currentSelectionFgColor |
|
4675 |
! |
|
4676 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4677 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4678 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4679 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
4680 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4681 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4682 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4683 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4684 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4685 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
4686 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4687 |
textChanged |
522 | 4688 |
"my text was modified (internally). |
4689 |
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
|
4690 |
contentsChanged, which is triggered when the size has changed, and |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4691 |
is used to notify scrollers, other views etc.)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4692 |
|
641 | 4693 |
self contentsChanged. |
1015 | 4694 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4695 |
contentsWasSaved := false |
641 | 4696 |
|
1015 | 4697 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 4698 |
! |
4699 |
||
2617 | 4700 |
textChangedButNoSizeChange |
2207 | 4701 |
"my text was modified (internally). |
4702 |
Sent whenever text has been edited (not to confuse with |
|
4703 |
contentsChanged, which is triggered when the size has changed, and |
|
4704 |
is used to notify scrollers, other views etc.)" |
|
4705 |
||
4706 |
self modified:true. |
|
4707 |
contentsWasSaved := false |
|
4708 |
||
4709 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4710 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4711 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4712 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4713 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4714 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4715 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4716 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4717 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4718 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4719 |
"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
|
4720 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
4721 |
|
2569 | 4722 |
hasUndoAction |
4723 |
^ undoAction notNil |
|
4724 |
! |
|
4725 |
||
1878 | 4726 |
isKeyboardConsumer |
4727 |
"return true, if the receiver is a keyboard consumer; |
|
4728 |
Return true here, redefined from SimpleView." |
|
4729 |
||
4730 |
^ true |
|
4731 |
||
4732 |
! |
|
4733 |
||
997 | 4734 |
specClass |
1390 | 4735 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
4736 |
||
997 | 4737 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 4738 |
^ super specClass |
4739 |
||
1390 | 4740 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 4741 |
! |
4742 |
||
324 | 4743 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4744 |
"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
|
4745 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
4746 |
"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
|
4747 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4748 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 4749 |
|
4750 |
"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
|
4751 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
4752 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4753 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4754 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4755 |
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
|
4756 |
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
|
4757 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4758 |
|
697 | 4759 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4760 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4761 |
w := super widthOfContents. |
697 | 4762 |
(dev := device) isNil ifTrue:[ |
2357 | 4763 |
"/ really dont know ... |
4764 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
4765 |
]. |
697 | 4766 |
^ w + (font widthOn:dev) |
4767 |
||
4768 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4769 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4770 |
|
1588 | 4771 |
!EditTextView methodsFor:'realization'! |
4772 |
||
4773 |
realize |
|
4774 |
"make the view visible - scroll to make the cursor visible." |
|
4775 |
||
4776 |
super realize. |
|
4777 |
||
4778 |
self makeCursorVisible. |
|
1993 | 4779 |
cursorFgColor := cursorFgColor onDevice:device. |
4780 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 4781 |
|
4782 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
4783 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
4784 |
! ! |
|
4785 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4786 |
!EditTextView methodsFor:'redrawing'! |
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 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4789 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4790 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4791 |
cursorShown ifTrue:[ |
2357 | 4792 |
cursorVisibleLine notNil ifTrue:[ |
4793 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
4794 |
self drawCursorCharacter |
|
4795 |
] |
|
4796 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4797 |
] |
105 | 4798 |
! |
4799 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4800 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4801 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4802 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4803 |
cursorShown ifTrue:[ |
2357 | 4804 |
(visLine == cursorVisibleLine) ifTrue:[ |
4805 |
self drawCursorCharacter |
|
4806 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4807 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4808 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4809 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4810 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4811 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4812 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4813 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4814 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4815 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4816 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4817 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4818 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4819 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4820 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4821 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4822 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4823 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4824 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4825 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4826 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4827 |
cursorShown ifTrue:[ |
2357 | 4828 |
(visLine == cursorVisibleLine) ifTrue:[ |
4829 |
(colNr == cursorCol) ifTrue:[ |
|
4830 |
self drawCursorCharacter. |
|
4831 |
^ self |
|
4832 |
] |
|
4833 |
] |
|
0 | 4834 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4835 |
super redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4836 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4837 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4838 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4839 |
"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
|
4840 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4841 |
super redrawVisibleLine:visLine from:startCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4842 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4843 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4844 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4845 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4846 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4847 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4848 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4849 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4850 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4851 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4852 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4853 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4854 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4855 |
"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
|
4856 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4857 |
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
|
4858 |
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
|
4859 |
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
|
4860 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4861 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4862 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
4863 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4864 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4865 |
"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
|
4866 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4867 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4868 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4870 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4871 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4872 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4873 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4874 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4875 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4876 |
"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
|
4877 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4878 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4879 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4880 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4881 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4882 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4883 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4884 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4886 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4887 |
"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
|
4888 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4889 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4890 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4891 |
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
|
4892 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4893 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4894 |
prevCursorState ifTrue:[ |
2357 | 4895 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4896 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
4897 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
4898 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4899 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4900 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4901 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4902 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4903 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4904 |
prevCursorState := cursorShown. |
1601 | 4905 |
"/ cursorShown := false. |
1591 | 4906 |
cursorShown ifTrue:[ |
2357 | 4907 |
self hideCursor |
1591 | 4908 |
] |
4909 |
||
1601 | 4910 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4911 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4912 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4913 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4914 |
"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
|
4915 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4916 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4917 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4918 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4919 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4920 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4921 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4922 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4923 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4924 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4925 |
"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
|
4926 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4927 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4928 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4929 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4930 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4931 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4932 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4933 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4934 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4935 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4937 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4938 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4939 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4940 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4941 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4942 |
cursorLine isNil ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4943 |
selectionStartLine notNil ifTrue:[ |
2357 | 4944 |
startLine := selectionStartLine. |
4945 |
startCol := selectionStartCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4946 |
] ifFalse:[ |
2357 | 4947 |
startLine := cursorLine min:list size. |
4948 |
startCol := cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4949 |
]. |
1339 | 4950 |
self |
2357 | 4951 |
searchBackwardFor:pattern |
4952 |
startingAtLine:startLine col:startCol |
|
4953 |
ifFound:[:line :col | |
|
4954 |
self cursorLine:line col:col. |
|
4955 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 4956 |
"/ self makeLineVisible:cursorLine |
2357 | 4957 |
typeOfSelection := #search] |
4958 |
ifAbsent:aBlock |
|
1339 | 4959 |
|
4960 |
"Modified: 9.10.1997 / 13:02:04 / cg" |
|
4961 |
! |
|
4962 |
||
4963 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
4964 |
"do a backward search" |
|
4965 |
||
4966 |
|startLine startCol| |
|
4967 |
||
4968 |
cursorLine isNil ifTrue:[^ self]. |
|
4969 |
selectionStartLine notNil ifTrue:[ |
|
2357 | 4970 |
startLine := selectionStartLine. |
4971 |
startCol := selectionStartCol |
|
1339 | 4972 |
] ifFalse:[ |
2357 | 4973 |
startLine := cursorLine min:list size. |
4974 |
startCol := cursorCol |
|
1339 | 4975 |
]. |
4976 |
self |
|
2357 | 4977 |
searchBackwardFor:pattern |
4978 |
ignoreCase:ign |
|
4979 |
startingAtLine:startLine col:startCol |
|
4980 |
ifFound:[:line :col | |
|
4981 |
self cursorLine:line col:col. |
|
4982 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 4983 |
"/ self makeLineVisible:cursorLine |
2357 | 4984 |
typeOfSelection := #search] |
4985 |
ifAbsent:aBlock |
|
1339 | 4986 |
|
4987 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4988 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4989 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4990 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4991 |
"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
|
4992 |
|
2554 | 4993 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4994 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4995 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4996 |
searchForMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4997 |
"search for a matching parenthesis starting at cursor position. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4998 |
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
|
4999 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5000 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5001 |
|
1339 | 5002 |
self |
2357 | 5003 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
5004 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
5005 |
ifNotFound:[self showNotFound] |
|
5006 |
onError:[self beep] |
|
1339 | 5007 |
|
5008 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5009 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5010 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5011 |
searchFwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5012 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5013 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5014 |
|startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5015 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5016 |
"/ if there is no selection and the cursor is at the origin, |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5017 |
"/ assume its the first search and do not skip the very first match |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5018 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5019 |
self hasSelection ifFalse:[ |
2357 | 5020 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
5021 |
startCol := 0 |
|
5022 |
] |
|
1339 | 5023 |
]. |
5024 |
||
5025 |
self |
|
2357 | 5026 |
searchFwd:pattern |
5027 |
startingAtLine:cursorLine col:startCol |
|
5028 |
ifAbsent:aBlock |
|
1339 | 5029 |
|
5030 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5031 |
! |
|
5032 |
||
5033 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
5034 |
"do a forward search" |
|
5035 |
||
5036 |
|startCol| |
|
5037 |
||
5038 |
"/ if there is no selection and the cursor is at the origin, |
|
5039 |
"/ assume its the first search and do not skip the very first match |
|
5040 |
startCol := cursorCol. |
|
5041 |
self hasSelection ifFalse:[ |
|
2357 | 5042 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
5043 |
startCol := 0 |
|
5044 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5045 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5046 |
|
1339 | 5047 |
self |
2357 | 5048 |
searchFwd:pattern |
5049 |
ignoreCase:ign |
|
5050 |
startingAtLine:cursorLine col:startCol |
|
5051 |
ifAbsent:aBlock |
|
1339 | 5052 |
|
5053 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5054 |
"Created: 9.10.1997 / 13:04:10 / cg" |
|
5055 |
! |
|
5056 |
||
5057 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
5058 |
"do a forward search" |
|
5059 |
||
5060 |
cursorLine isNil ifTrue:[^ self]. |
|
5061 |
self |
|
2357 | 5062 |
searchForwardFor:pattern |
5063 |
ignoreCase:ign |
|
5064 |
startingAtLine:startLine col:startCol |
|
5065 |
ifFound:[:line :col | |
|
5066 |
self cursorLine:line col:col. |
|
5067 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 5068 |
"/ self makeLineVisible:cursorLine |
2357 | 5069 |
typeOfSelection := #search] |
5070 |
ifAbsent:aBlock |
|
1339 | 5071 |
|
5072 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
5073 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5074 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5075 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5076 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5077 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5078 |
|
1339 | 5079 |
self |
2357 | 5080 |
searchForwardFor:pattern |
5081 |
startingAtLine:startLine col:startCol |
|
5082 |
ifFound:[:line :col | |
|
5083 |
self cursorLine:line col:col. |
|
5084 |
self showMatch:pattern atLine:line col:col. |
|
5085 |
typeOfSelection := #search] |
|
5086 |
ifAbsent:aBlock |
|
1339 | 5087 |
|
5088 |
"Modified: 9.10.1997 / 13:07:52 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5089 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5090 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5091 |
setSearchPattern |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5092 |
"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
|
5093 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5094 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5095 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5096 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5097 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5098 |
"/ 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
|
5099 |
"/ original string (for search after again) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5100 |
"/ |
565 | 5101 |
(lastString notNil |
5102 |
and:[lastReplacement notNil |
|
5103 |
and:[typeOfSelection ~~ #search]]) ifTrue:[ |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5104 |
lastSearchPattern := lastString asString withoutSeparators. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5105 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5106 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5107 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5108 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5109 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5110 |
"/ 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
|
5111 |
"/ 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
|
5112 |
"/ it did not result from a paste. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5113 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5114 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5115 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5116 |
sel notNil ifTrue:[ |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5117 |
(lastSearchPattern isNil |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5118 |
or:[typeOfSelection ~~ #paste]) ifTrue:[ |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5119 |
self cursorLine:selectionStartLine col:selectionStartCol. |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5120 |
lastSearchPattern := sel asString withoutSeparators withMatchEscapes |
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5121 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5123 |
|
565 | 5124 |
"Modified: 20.4.1996 / 12:50:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5125 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5126 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5127 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5128 |
|
1850 | 5129 |
autoMoveCursorToEndOfSelection |
5130 |
"return true, if the cursor should be automatically moved to the |
|
5131 |
end of a selection. |
|
5132 |
Redefined to return false in terminaViews, where the cursor should |
|
5133 |
not be affected by selecting" |
|
5134 |
||
5135 |
^ true |
|
5136 |
! |
|
5137 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5138 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5139 |
typeOfSelection ~~ newType ifTrue:[ |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5140 |
typeOfSelection := newType. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5141 |
selectionStartLine notNil ifTrue:[ |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5142 |
self |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5143 |
redrawFromLine:selectionStartLine col:selectionStartCol |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5144 |
toLine:selectionEndLine col:selectionEndCol |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5145 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5146 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5147 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5148 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5149 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5150 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5151 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5152 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5153 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5154 |
list isNil ifTrue:[ |
2357 | 5155 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5156 |
] ifFalse:[ |
2357 | 5157 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
5158 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5159 |
] |
1082 | 5160 |
|
5161 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5162 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5163 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5164 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5165 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5166 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5167 |
self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5168 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5169 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5170 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5171 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5172 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5173 |
cursorCol > 1 ifTrue:[ |
2357 | 5174 |
self selectFromLine:cursorLine col:1 |
5175 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5176 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5177 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5178 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5179 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5180 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5181 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5182 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5183 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5184 |
selectionStartLine isNil ifTrue:[ |
2357 | 5185 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5186 |
] ifFalse:[ |
2357 | 5187 |
self selectFromLine:selectionStartLine col:selectionStartCol |
5188 |
toLine:cursorLine+1 col:0. |
|
5189 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5190 |
] |
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 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5194 |
"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
|
5195 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5196 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5197 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5198 |
list isNil ifTrue:[ |
2357 | 5199 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5200 |
] ifFalse:[ |
2357 | 5201 |
cursorCol == 0 ifTrue:[ |
5202 |
col := 0 |
|
5203 |
] ifFalse:[ |
|
5204 |
col := cursorCol - 1 |
|
5205 |
]. |
|
5206 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
5207 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5208 |
] |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5211 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5212 |
"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
|
5213 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5214 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5215 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 5216 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
2357 | 5217 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 5218 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5219 |
typeOfSelection := nil |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5223 |
"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
|
5224 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5225 |
list isNil ifTrue:[ |
2357 | 5226 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5227 |
] ifFalse:[ |
2357 | 5228 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
5229 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5230 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5231 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5232 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5233 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5234 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5235 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5236 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5237 |
! |
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 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5240 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5241 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5242 |
|wasOn| |
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 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5245 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5246 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5247 |
wasOn ifTrue:[self showCursor] |
105 | 5248 |
! ! |
5249 |
||
5250 |
!EditTextView methodsFor:'undo & again'! |
|
5251 |
||
5252 |
again |
|
5253 |
"repeat the last action (which was a cut or replace). |
|
5254 |
If current selection is not last string, search forward to |
|
5255 |
next occurence of it before repeating the last operation." |
|
5256 |
||
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
5257 |
|s l c sel savedSelectStyle startColForSearch| |
105 | 5258 |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5259 |
lastString isNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5260 |
^ false |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5261 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5262 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5263 |
s := lastString asString. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5264 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5265 |
"remove final cr" |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5266 |
(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
|
5267 |
"/ 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
|
5268 |
savedSelectStyle := selectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5269 |
selectStyle := nil. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5270 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5271 |
sel := self selection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5272 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5273 |
"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
|
5274 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5275 |
(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
|
5276 |
undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5277 |
l := selectionStartLine "cursorLine". |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5278 |
c := selectionStartCol "cursorCol". |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5279 |
self deleteSelection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5280 |
lastReplacement notNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5281 |
self insertLines:lastReplacement asStringCollection withCR:false. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5282 |
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
|
5283 |
]. |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5284 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5285 |
^ true |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5286 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5287 |
startColForSearch := cursorCol. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5288 |
sel isNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5289 |
startColForSearch := startColForSearch - 1 |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5290 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5291 |
self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5292 |
ifFound: |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5293 |
[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5294 |
:line :col | |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5295 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5296 |
|repl| |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5297 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5298 |
self selectFromLine:line col:col |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5299 |
toLine:line col:(col + s size - 1). |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5300 |
self makeLineVisible:line. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5301 |
undoAction := [self insertLines:lastString atLine:line col:col]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5302 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5303 |
self deleteSelection. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5304 |
lastReplacement notNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5305 |
lastReplacement isString ifFalse:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5306 |
repl := lastReplacement asString "withoutSpaces" |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5307 |
] ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5308 |
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
|
5309 |
]. |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5310 |
self insertLines:repl asStringCollection withCR:false. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5311 |
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
|
5312 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5313 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5314 |
^ true |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5315 |
] |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5316 |
ifAbsent: |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5317 |
[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5318 |
|sensor| |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5319 |
|
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5320 |
(sensor := self sensor) notNil ifTrue:[ |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5321 |
sensor compressKeyPressEventsWithKey:#Again. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5322 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5323 |
self showNotFound. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5324 |
selectStyle := savedSelectStyle. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5325 |
^ false |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
5326 |
] |
501 | 5327 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
5328 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 5329 |
! |
5330 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5331 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5332 |
"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
|
5333 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5334 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5335 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5336 |
|
121 | 5337 |
undo |
5338 |
"currently not implemented" |
|
5339 |
||
5340 |
undoAction notNil ifTrue:[ |
|
2357 | 5341 |
undoAction value. |
5342 |
undoAction := nil. |
|
121 | 5343 |
] |
105 | 5344 |
! ! |
5345 |
||
865 | 5346 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5347 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5348 |
version |
2660
1352e7b3ac67
always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
5349 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.287 2002-11-06 11:08:23 cg Exp $' |
0 | 5350 |
! ! |