author | Claus Gittinger <cg@exept.de> |
Mon, 31 Jan 2000 19:58:49 +0100 | |
changeset 2109 | ccad6daad477 |
parent 2100 | 69c10efca8f4 |
child 2118 | f9d8bfb35b03 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 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 |
||
13 |
ListView subclass:#TextView |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
14 |
instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine |
1841 | 15 |
selectionEndCol clickPos clickStartLine clickStartCol clickLine |
16 |
clickCol clickCount expandingTop wordStartCol wordStartLine |
|
17 |
wordEndCol wordEndLine selectionFgColor selectionBgColor |
|
18 |
selectStyle directoryForFileDialog defaultFileNameForFileDialog |
|
1729 | 19 |
externalEncoding contentsWasSaved lastSearchPattern |
20 |
lastSearchIgnoredCase lastSearchDirection' |
|
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
21 |
classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor |
504 | 22 |
DefaultSelectionBackgroundColor MatchDelayTime |
1677
2590c4349062
remember last searchString(s)
Claus Gittinger <cg@exept.de>
parents:
1661
diff
changeset
|
23 |
WordSelectCatchesBlanks ST80Selections LastSearchPatterns' |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
24 |
poolDictionaries:'' |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
25 |
category:'Views-Text' |
0 | 26 |
! |
27 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
28 |
!TextView class methodsFor:'documentation'! |
0 | 29 |
|
38 | 30 |
copyright |
31 |
" |
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 33 |
All Rights Reserved |
38 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
22 | 44 |
documentation |
0 | 45 |
" |
120 | 46 |
a view for readOnly text - this class adds selections to a simple list. |
38 | 47 |
The text is not editable and there is no cursor. |
120 | 48 |
Use TextViews for readonly text, EditTextView for editable text. |
0 | 49 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
50 |
Please read the historic notice in the ListView class. |
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
51 |
|
586 | 52 |
[Instance variables:] |
0 | 53 |
|
120 | 54 |
selectionStartLine <Number> the line of the selection start (or nil) |
55 |
selectionStartCol <Number> the col of the selection start |
|
56 |
selectionEndLine <Number> the line of the selection end |
|
57 |
selectionEndCol <Number> the col of the selection end |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
58 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
59 |
clickStartLine <Number> temporary - remember where select operation started |
120 | 60 |
clickStartCol <Number> temporary |
61 |
clickLine <Number> temporary |
|
62 |
clickCol <Number> temporary |
|
63 |
clickCount <Number> temporary |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
64 |
expandingTop <Boolean> temporary - for expandSelection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
65 |
|
120 | 66 |
selectionFgColor <Color> color used to draw selections |
67 |
selectionBgColor <Color> color used to draw selections |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
68 |
|
120 | 69 |
selectStyle <Symbol> how words are selected |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
70 |
|
120 | 71 |
directoryForFileDialog <nil|pathName> directory where save dialog should start |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
72 |
|
120 | 73 |
contentsWasSaved <Boolean> set to true, whenever saved in a file |
77 | 74 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
75 |
externalEncoding <Symbol|nil> external encoding, used when text is saved to |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
76 |
a file. Usually something like |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
77 |
#jis7, #euc, #sjis etc. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
78 |
(currently only passed down from the |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
79 |
fileBrowser) |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
80 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
81 |
[class variables:] |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
82 |
ST80Selections <Boolean> enables ST80 style doubleclick behavior |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
83 |
(right after opening parenthesis, right before |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
84 |
closing parenthesis, at begin of a line |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
85 |
at begin of text) |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
86 |
|
586 | 87 |
[StyleSheet parameters:] |
77 | 88 |
|
120 | 89 |
textViewBackground defaults to viewBackground |
90 |
textSelectionForegroundColor defaults to textBackgroundColor |
|
91 |
textSelectionBackgroundColor defaults to textForegroundColor |
|
92 |
textViewFont defaults to textFont |
|
586 | 93 |
|
94 |
||
95 |
[author:] |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
96 |
Claus Gittinger |
586 | 97 |
|
98 |
[see also:] |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
99 |
EditTextView CodeView Workspace |
0 | 100 |
" |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
101 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
102 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
103 |
examples |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
104 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
105 |
although textViews (and instances of subclasses) are mostly used |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
106 |
as components (in the fileBrowser, the browser, the launcher etc.), |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
107 |
they may also be opened as a textEditor; |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
108 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
109 |
open a (readonly) textView on some information text: |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
110 |
[exBegin] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
111 |
TextView |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
112 |
openWith:'read this' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
113 |
title:'demonstration' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
114 |
[exEnd] |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
115 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
116 |
the same, but open it modal: |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
117 |
[exBegin] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
118 |
TextView |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
119 |
openModalWith:'read this first' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
120 |
title:'demonstration' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
121 |
[exEnd] |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
122 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
123 |
|
1016 | 124 |
open it modal (but editable) on some text: |
125 |
(must accept before closing) |
|
126 |
This is somewhat kludgy - when closed, the view has already |
|
127 |
nilled its link to the model. Therefore, the accept must be |
|
128 |
done 'manually' below. |
|
129 |
However, usually an applicationModel is installed as the |
|
130 |
editor-topViews application. This would get a closeRequest, |
|
131 |
where it could handle things. |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
132 |
[exBegin] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
133 |
|m textView| |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
134 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
135 |
m := 'read this first' asValue. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
136 |
textView := EditTextView openModalOnModel:m. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
137 |
textView modified ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
138 |
(self confirm:'text was not accepted - do it now ?') |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
139 |
ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
140 |
m value:textView contents |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
141 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
142 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
143 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
144 |
Transcript showCR:m value. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
145 |
[exEnd] |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
146 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
147 |
|
1016 | 148 |
open a textEditor on some file: |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
149 |
[exBegin] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
150 |
EditTextView openOn:'Makefile' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
151 |
[exEnd] |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
152 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
153 |
" |
1016 | 154 |
|
0 | 155 |
! ! |
156 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
157 |
!TextView class methodsFor:'instance creation'! |
119 | 158 |
|
159 |
on:aModel aspect:aspect change:change menu:menu initialSelection:initial |
|
160 |
"for ST-80 compatibility" |
|
161 |
||
120 | 162 |
^ (self new) |
163 |
on:aModel |
|
164 |
aspect:aspect |
|
165 |
list:aspect |
|
166 |
change:change |
|
167 |
menu:menu |
|
168 |
initialSelection:initial |
|
119 | 169 |
! ! |
170 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
171 |
!TextView class methodsFor:'defaults'! |
38 | 172 |
|
896 | 173 |
defaultIcon |
1195 | 174 |
"return the default icon if started as a topView" |
175 |
||
176 |
<resource: #style (#ICON #ICON_FILE)> |
|
177 |
||
178 |
|nm i| |
|
1143 | 179 |
|
1146 | 180 |
i := self classResources at:'ICON' default:nil. |
1143 | 181 |
i isNil ifTrue:[ |
1987 | 182 |
nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'. |
2074 | 183 |
i := Smalltalk imageFromFileNamed:nm forClass:self. |
1195 | 184 |
]. |
185 |
i notNil ifTrue:[ |
|
1987 | 186 |
i := i onDevice:Display |
1143 | 187 |
]. |
188 |
^ i |
|
189 |
||
1195 | 190 |
"Modified: 18.4.1997 / 15:18:06 / cg" |
896 | 191 |
! |
192 |
||
910
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
193 |
defaultMenuMessage |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
194 |
"This message is the default yo be sent to the menuHolder to get a menu" |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
195 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
196 |
^ #editMenu |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
197 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
198 |
"Created: 3.1.1997 / 01:52:21 / stefan" |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
199 |
! |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
200 |
|
1477
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
201 |
defaultViewBackgroundColor |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
202 |
"return the default view background" |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
203 |
|
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
204 |
^DefaultViewBackground |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
205 |
! |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
206 |
|
1729 | 207 |
st80SelectMode |
208 |
^ ST80Selections |
|
209 |
||
210 |
"Modified: / 6.1.1999 / 14:19:26 / cg" |
|
211 |
! |
|
212 |
||
213 |
st80SelectMode:aBoolean |
|
214 |
ST80Selections := aBoolean |
|
215 |
||
216 |
"Created: / 7.1.1999 / 13:35:24 / cg" |
|
217 |
! |
|
218 |
||
59 | 219 |
updateStyleCache |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
220 |
"extract values from the styleSheet and cache them in class variables" |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
221 |
|
1353 | 222 |
<resource: #style (#'textView.background' |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
223 |
#'text.selectionForegroundColor' #'text.selectionBackgroundColor' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
224 |
#'textView.font' #'text.wordSelectCatchesBlanks' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
225 |
#'text.st80Selections')> |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
226 |
|
1353 | 227 |
DefaultViewBackground := StyleSheet colorAt:'textView.background' default:White. |
1380 | 228 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'text.selectionForegroundColor'. |
229 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'text.selectionBackgroundColor'. |
|
1353 | 230 |
DefaultFont := StyleSheet fontAt:'textView.font'. |
504 | 231 |
MatchDelayTime := 0.6. |
1380 | 232 |
WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false. |
233 |
ST80Selections := StyleSheet at:'text.st80Selections' default:false. |
|
234 |
||
235 |
"Modified: / 31.10.1997 / 13:17:16 / cg" |
|
0 | 236 |
! ! |
237 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
238 |
!TextView class methodsFor:'startup'! |
121 | 239 |
|
248 | 240 |
open |
241 |
"start an empty TextView" |
|
242 |
||
243 |
^ self openWith:nil |
|
0 | 244 |
! |
245 |
||
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
246 |
openModalOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
247 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
248 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
249 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
250 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
251 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
252 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
253 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
254 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
255 |
"Created: 14.2.1997 / 15:24:12 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
256 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
257 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
258 |
openModalWith:aString |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
259 |
"start a textView with aString as initial contents" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
260 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
261 |
^ self openModalWith:aString title:nil |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
262 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
263 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
264 |
TextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
265 |
EditTextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
266 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
267 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
268 |
"Created: 14.2.1997 / 15:19:04 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
269 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
270 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
271 |
openModalWith:aString title:aTitle |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
272 |
"start a textView with aString as initial contents. Return the textView." |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
273 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
274 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
275 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
276 |
textView := self setupWith:aString title:aTitle. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
277 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
278 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
279 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
280 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
281 |
TextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
282 |
EditTextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
283 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
284 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
285 |
"Modified: 9.9.1996 / 19:32:29 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
286 |
"Created: 14.2.1997 / 15:19:18 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
287 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
288 |
|
248 | 289 |
openOn:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
290 |
"start a textView on a file; return the textView" |
0 | 291 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
292 |
|textView| |
248 | 293 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
294 |
textView := self setupForFile:aFileName. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
295 |
textView topView open. |
248 | 296 |
^ textView |
297 |
||
298 |
" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
299 |
TextView openOn:'../../doc/overview.doc' |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
300 |
EditTextView openOn:'../../doc/overview.doc' |
248 | 301 |
" |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
302 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
303 |
"Modified: 14.2.1997 / 15:21:51 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
304 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
305 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
306 |
openOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
307 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
308 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
309 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
310 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
311 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
312 |
textView topView open. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
313 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
314 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
315 |
"Created: 14.2.1997 / 15:23:36 / cg" |
0 | 316 |
! |
317 |
||
1100 | 318 |
openWith:aStringOrStringCollection |
319 |
"start a textView with aStringOrStringCollection as initial contents" |
|
320 |
||
321 |
^ self openWith:aStringOrStringCollection title:nil |
|
0 | 322 |
|
248 | 323 |
" |
324 |
TextView openWith:'some text' |
|
325 |
EditTextView openWith:'some text' |
|
326 |
" |
|
119 | 327 |
|
248 | 328 |
"Created: 10.12.1995 / 17:41:32 / cg" |
1100 | 329 |
"Modified: 5.3.1997 / 15:37:19 / cg" |
126 | 330 |
! |
331 |
||
1100 | 332 |
openWith:aStringOrStringCollection title:aTitle |
333 |
"start a textView with aStringOrStringCollection as initial contents. Return the textView." |
|
248 | 334 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
335 |
|textView| |
248 | 336 |
|
1100 | 337 |
textView := self setupWith:aStringOrStringCollection title:aTitle. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
338 |
textView topView open. |
248 | 339 |
^ textView |
340 |
||
341 |
" |
|
342 |
TextView openWith:'some text' title:'testing' |
|
343 |
EditTextView openWith:'some text' title:'testing' |
|
344 |
" |
|
126 | 345 |
|
248 | 346 |
"Created: 10.12.1995 / 17:40:02 / cg" |
1100 | 347 |
"Modified: 5.3.1997 / 15:37:26 / cg" |
248 | 348 |
! |
349 |
||
350 |
setupEmpty |
|
351 |
"create a textview in a topview, with horizontal and |
|
352 |
vertical scrollbars - a helper for #startWith: and #startOn:" |
|
353 |
||
354 |
|top frame label| |
|
355 |
||
356 |
label := 'unnamed'. |
|
896 | 357 |
top := StandardSystemView label:label icon:self defaultIcon. |
248 | 358 |
|
359 |
frame := HVScrollableView |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
360 |
for:self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
361 |
miniScrollerH:true miniScrollerV:false |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
362 |
in:top. |
248 | 363 |
frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
364 |
^ frame scrolledView |
|
896 | 365 |
|
366 |
"Modified: 23.5.1965 / 14:12:32 / cg" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
367 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
368 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
369 |
setupForFile:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
370 |
"setup a textView on a file; return the textView" |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
371 |
|
1326 | 372 |
|top textView f| |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
373 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
374 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
375 |
top := textView topView. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
376 |
aFileName notNil ifTrue:[ |
1326 | 377 |
f := aFileName asFilename. |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
378 |
top label:(f baseName). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
379 |
textView contents:(f contents). |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
380 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
381 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
382 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
383 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
384 |
"Created: 14.2.1997 / 15:21:43 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
385 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
386 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
387 |
setupForModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
388 |
"setup a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
389 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
390 |
|top textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
391 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
392 |
textView := self setupEmpty. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
393 |
textView model:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
394 |
top := textView topView. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
395 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
396 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
397 |
"Created: 14.2.1997 / 15:22:42 / cg" |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
398 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
399 |
|
1100 | 400 |
setupWith:aStringOrStringCollection title:aTitle |
401 |
"setup a textView with aStringOrStringCollection as initial contents in a topView" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
402 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
403 |
|top textView| |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
404 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
405 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
406 |
top := textView topView. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
407 |
aTitle notNil ifTrue:[top label:aTitle]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
408 |
|
1100 | 409 |
aStringOrStringCollection notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
410 |
textView contents:aStringOrStringCollection |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
411 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
412 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
413 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
414 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
415 |
"Created: 9.9.1996 / 19:31:22 / cg" |
1100 | 416 |
"Modified: 5.3.1997 / 15:37:37 / cg" |
119 | 417 |
! ! |
418 |
||
2100 | 419 |
!TextView methodsFor:'Compatibility - ST80'! |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
420 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
421 |
selectionStartIndex |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
422 |
"ST-80 compatibility: return the selections start character position." |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
423 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
424 |
^ self characterPositionOfSelection |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
425 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
426 |
"Created: / 19.6.1998 / 00:21:44 / cg" |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
427 |
! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
428 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
429 |
selectionStopIndex |
2052 | 430 |
"ST-80 compatibility: return the character position of |
431 |
the character right after the selection." |
|
432 |
||
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
433 |
|idx| |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
434 |
|
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
435 |
idx := self characterPositionOfSelectionEnd. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
436 |
idx == 0 ifTrue:[^ 0]. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
437 |
^ idx + 1 |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
438 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
439 |
"Created: / 19.6.1998 / 00:22:08 / cg" |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
440 |
! ! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
441 |
|
0 | 442 |
!TextView methodsFor:'accessing'! |
443 |
||
444 |
characterPositionOfSelection |
|
1303 | 445 |
"return the character index of the first character in the selection. |
446 |
Returns 0 if there is no selection." |
|
447 |
||
448 |
selectionStartLine isNil ifTrue:[^ 0]. |
|
0 | 449 |
^ self characterPositionOfLine:selectionStartLine |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
450 |
col:selectionStartCol |
1303 | 451 |
|
452 |
"Modified: 14.8.1997 / 16:35:37 / cg" |
|
453 |
! |
|
454 |
||
455 |
characterPositionOfSelectionEnd |
|
456 |
"return the character index of the last character in the selection. |
|
457 |
Returns 0 if there is no selection." |
|
458 |
||
459 |
selectionStartLine isNil ifTrue:[^ 0]. |
|
460 |
^ self characterPositionOfLine:selectionEndLine |
|
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
461 |
col:selectionEndCol |
1303 | 462 |
|
463 |
"Created: 14.8.1997 / 16:35:24 / cg" |
|
464 |
"Modified: 14.8.1997 / 16:35:45 / cg" |
|
0 | 465 |
! |
466 |
||
467 |
contentsWasSaved |
|
468 |
"return true, if the contents was saved (by a save action), |
|
469 |
false if not (or was modified again after the last save)." |
|
470 |
||
471 |
^ contentsWasSaved |
|
472 |
! |
|
473 |
||
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
474 |
defaultFileNameForFileDialog:aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
475 |
"define the default fileName to use for the save-box" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
476 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
477 |
defaultFileNameForFileDialog := aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
478 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
479 |
"Created: 13.2.1997 / 18:29:53 / cg" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
480 |
! |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
481 |
|
248 | 482 |
directoryForFileDialog:aDirectory |
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
483 |
"define the default directory to use for save-box" |
248 | 484 |
|
485 |
directoryForFileDialog := aDirectory |
|
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
486 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
487 |
"Modified: 13.2.1997 / 18:30:01 / cg" |
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
488 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
489 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
490 |
externalEncoding:encodingSymOrNil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
491 |
"define how the contents should be encoded when saved |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
492 |
via the 'save / save as' dialog. |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
493 |
This is (currently) only passed down from the fileBrowser, |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
494 |
and required when japanese/chines/korean text is edited. |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
495 |
(encoding is one of #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
496 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
497 |
externalEncoding := encodingSymOrNil |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
498 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
499 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
500 |
!TextView methodsFor:'accessing-contents'! |
248 | 501 |
|
0 | 502 |
fromFile:aFileName |
503 |
"take contents from a named file" |
|
504 |
||
1326 | 505 |
|f| |
506 |
||
507 |
f := aFileName asFilename. |
|
508 |
self directoryForFileDialog:(f directoryName). |
|
509 |
self contents:(f contents) |
|
0 | 510 |
! |
511 |
||
248 | 512 |
list:something |
513 |
"set the displayed contents (a collection of strings) |
|
514 |
with redraw. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
515 |
Redefined since changing the contents implies deselect" |
0 | 516 |
|
517 |
self unselect. |
|
248 | 518 |
super list:something |
0 | 519 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
520 |
"Modified: 29.4.1996 / 12:13:24 / cg" |
0 | 521 |
! |
522 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
523 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
524 |
"set the contents (either a string or a Collection of strings) |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
525 |
dont change the position (i.e. do not scroll) or the selection." |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
526 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
527 |
|selStartLine selStartCol selEndLine selEndCol selStyle| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
528 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
529 |
selStartLine := selectionStartLine. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
530 |
selStartCol := selectionStartCol. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
531 |
selEndLine := selectionEndLine. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
532 |
selEndCol := selectionEndCol. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
533 |
selStyle := selectStyle. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
534 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
535 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
536 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
537 |
selStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
538 |
self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
539 |
selectFromLine:selStartLine col:selStartCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
540 |
toLine:selEndLine col:selEndCol. |
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
541 |
]. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
542 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
543 |
selectStyle := selStyle |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
544 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
545 |
"Modified: / 31.3.1998 / 23:33:21 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
546 |
! |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
547 |
|
248 | 548 |
setList:something |
549 |
"set the displayed contents (a collection of strings) |
|
550 |
without redraw. |
|
551 |
Redefined since changing contents implies deselect" |
|
0 | 552 |
|
248 | 553 |
self unselect. |
554 |
super setList:something |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
555 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
556 |
|
1487
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
557 |
text |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
558 |
"for ST80 compatibility" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
559 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
560 |
^ self contents |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
561 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
562 |
"Created: / 19.4.1998 / 12:53:10 / cg" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
563 |
! |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
564 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
565 |
wordAtLine:selectLine col:selectCol do:aFiveArgBlock |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
566 |
"find word boundaries, evaluate the block argument with those. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
567 |
A helper for nextWord and selectWord functions." |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
568 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
569 |
|beginCol endCol endLine thisCharacter flag| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
570 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
571 |
flag := #word. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
572 |
beginCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
573 |
endCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
574 |
endLine := selectLine. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
575 |
thisCharacter := self characterAtLine:selectLine col:beginCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
576 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
577 |
beginCol := self findBeginOfWordAtLine:selectLine col:selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
578 |
endCol := self findEndOfWordAtLine:selectLine col:selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
579 |
endCol == 0 ifTrue:[ |
1784
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
580 |
endLine := selectLine + 1 |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
581 |
]. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
582 |
|
1750 | 583 |
"is the initial character within a word ?" |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
584 |
(wordCheck value:thisCharacter) ifTrue:[ |
1784
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
585 |
" |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
586 |
try to catch a blank ... |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
587 |
" |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
588 |
|
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
589 |
WordSelectCatchesBlanks ifTrue:[ |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
590 |
((beginCol == 1) |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
591 |
or:[(self characterAtLine:selectLine col:(beginCol - 1)) |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
592 |
~~ Character space]) ifTrue:[ |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
593 |
((self characterAtLine:selectLine col:(endCol + 1)) |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
594 |
== Character space) ifTrue:[ |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
595 |
endCol := endCol + 1. |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
596 |
flag := #wordRight |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
597 |
] |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
598 |
] ifFalse:[ |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
599 |
beginCol := beginCol - 1. |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
600 |
flag := #wordLeft |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
601 |
]. |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
602 |
]. |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
603 |
]. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
604 |
aFiveArgBlock value:selectLine |
1784
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
605 |
value:beginCol |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
606 |
value:endLine |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
607 |
value:endCol |
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
608 |
value:flag |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
609 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
610 |
"Modified: 18.3.1996 / 17:31:04 / cg" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
611 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
612 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
613 |
!TextView methodsFor:'accessing-look'! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
614 |
|
2027
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
615 |
selectionBackgroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
616 |
"return the selection-background color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
617 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
618 |
^ selectionBgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
619 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
620 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
621 |
selectionForegroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
622 |
"return the selection-foreground color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
623 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
624 |
^ selectionFgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
625 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
626 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
627 |
selectionForegroundColor:color1 backgroundColor:color2 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
628 |
"set both the selection-foreground and cursor background colors. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
629 |
The default is defined by the styleSheet; |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
630 |
typically black-on-green for color displays and white-on-black for b&w displays." |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
631 |
|
1987 | 632 |
selectionFgColor := color1 onDevice:device. |
633 |
selectionBgColor := color2 onDevice:device. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
634 |
shown ifTrue:[ |
1987 | 635 |
self hasSelection ifTrue:[ |
636 |
self invalidate |
|
637 |
] |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
638 |
] |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
639 |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
715
diff
changeset
|
640 |
"Modified: 29.5.1996 / 16:22:15 / cg" |
0 | 641 |
! ! |
642 |
||
248 | 643 |
!TextView methodsFor:'accessing-mvc'! |
0 | 644 |
|
248 | 645 |
on:aModel aspect:aspectSym list:listSym change:changeSym menu:menuSym initialSelection:initial |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
646 |
"set all of model, aspect, listMessage, changeSymbol, menySymbol |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
647 |
and selection. Added for ST-80 compatibility" |
0 | 648 |
|
906 | 649 |
aspectSym notNil ifTrue:[aspectMsg := aspectSym. |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
650 |
listMsg isNil ifTrue:[listMsg := aspectSym]]. |
248 | 651 |
changeSym notNil ifTrue:[changeMsg := changeSym]. |
652 |
listSym notNil ifTrue:[listMsg := listSym]. |
|
653 |
menuSym notNil ifTrue:[menuMsg := menuSym]. |
|
654 |
"/ initial notNil ifTrue:[initialSelectionMsg := initial]. |
|
655 |
self model:aModel. |
|
0 | 656 |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
657 |
"Modified: 15.8.1996 / 12:52:54 / stefan" |
906 | 658 |
"Modified: 2.1.1997 / 16:11:28 / cg" |
0 | 659 |
! ! |
660 |
||
661 |
!TextView methodsFor:'event processing'! |
|
662 |
||
53 | 663 |
buttonMotion:buttonMask x:x y:y |
0 | 664 |
"mouse-move while button was pressed - handle selection changes" |
665 |
||
666 |
|movedVisibleLine movedLine movedCol |
|
667 |
movedUp |
|
668 |
oldStartLine oldEndLine oldStartCol oldEndCol| |
|
669 |
||
670 |
clickLine isNil ifTrue:[^ self]. |
|
671 |
||
63 | 672 |
"is it the select or 1-button ?" |
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
673 |
self sensor leftButtonPressed ifFalse:[^ self]. |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
674 |
"/ (device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[ |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
675 |
"/ (device buttonMotionMask:buttonMask includesButton:1) ifFalse:[ |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
676 |
"/ ^ self |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
677 |
"/ ]. |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
678 |
"/ ]. |
53 | 679 |
|
0 | 680 |
"if moved outside of view, start autoscroll" |
681 |
(y < 0) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
682 |
self compressMotionEvents:false. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
683 |
self startAutoScrollUp:y. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
684 |
^ self |
0 | 685 |
]. |
686 |
(y > height) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
687 |
self compressMotionEvents:false. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
688 |
self startAutoScrollDown:(y - height). |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
689 |
^ self |
59 | 690 |
]. |
691 |
((x < 0) and:[leftOffset ~~ 0]) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
692 |
self compressMotionEvents:false. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
693 |
self startAutoScrollLeft:x. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
694 |
^ self |
59 | 695 |
]. |
696 |
(x > width) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
697 |
self compressMotionEvents:false. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
698 |
self startAutoScrollRight:(x - width). |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
699 |
^ self |
0 | 700 |
]. |
701 |
||
702 |
"move inside - stop autoscroll if any" |
|
703 |
autoScrollBlock notNil ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
704 |
self stopScrollSelect |
0 | 705 |
]. |
706 |
||
707 |
movedVisibleLine := self visibleLineOfY:y. |
|
708 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
|
709 |
(x < leftMargin) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
710 |
movedCol := 0 |
0 | 711 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
712 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
0 | 713 |
]. |
1755
ab3c4ee45498
allow selection of a single character
Claus Gittinger <cg@exept.de>
parents:
1750
diff
changeset
|
714 |
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
715 |
selectionStartLine notNil ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
716 |
^ self |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
717 |
]. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
718 |
(clickPos isNil |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
719 |
or:[(clickPos x - x) abs < 3 |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
720 |
and:[(clickPos y - y) abs < 3]]) ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
721 |
^ self |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
722 |
]. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
723 |
selectionStartLine := clickLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
724 |
selectionStartCol := clickCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
725 |
selectionEndLine := selectionStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
726 |
selectionEndCol := selectionStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
727 |
|
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
728 |
oldStartLine := selectionStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
729 |
oldEndLine := selectionEndLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
730 |
oldStartCol := selectionStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
731 |
oldEndCol := selectionEndCol-1. |
1755
ab3c4ee45498
allow selection of a single character
Claus Gittinger <cg@exept.de>
parents:
1750
diff
changeset
|
732 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
733 |
selectionStartLine isNil ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
734 |
selectionStartLine := clickLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
735 |
selectionStartCol := clickCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
736 |
selectionEndLine := selectionStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
737 |
selectionEndCol := selectionStartCol |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
738 |
]. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
739 |
oldStartLine := selectionStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
740 |
oldEndLine := selectionEndLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
741 |
oldStartCol := selectionStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
742 |
oldEndCol := selectionEndCol. |
0 | 743 |
]. |
744 |
||
745 |
"find out if we are before or after initial click" |
|
746 |
movedUp := false. |
|
747 |
(movedLine < clickStartLine) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
748 |
movedUp := true |
0 | 749 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
750 |
(movedLine == clickStartLine) ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
751 |
(movedCol < clickStartCol) ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
752 |
movedUp := true |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
753 |
] |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
754 |
] |
0 | 755 |
]. |
756 |
||
757 |
movedUp ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
758 |
"change selectionStart" |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
759 |
selectionStartCol := movedCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
760 |
selectionStartLine := movedLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
761 |
selectionEndCol := clickStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
762 |
selectionEndLine := clickStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
763 |
selectStyle notNil ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
764 |
selectionEndCol := wordEndCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
765 |
selectionEndLine := wordEndLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
766 |
] |
0 | 767 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
768 |
"change selectionEnd" |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
769 |
selectionEndCol := movedCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
770 |
selectionEndLine := movedLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
771 |
selectionStartCol := clickStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
772 |
selectionStartLine := clickStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
773 |
selectStyle notNil ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
774 |
selectionStartCol := wordStartCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
775 |
selectionStartLine := wordStartLine. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
776 |
] |
0 | 777 |
]. |
778 |
||
164 | 779 |
selectionStartLine isNil ifTrue:[^ self]. |
780 |
||
0 | 781 |
(selectionStartCol == 0) ifTrue:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
782 |
selectionStartCol := 1 |
0 | 783 |
]. |
784 |
||
38 | 785 |
" |
786 |
if in word-select, just catch the rest of the word |
|
787 |
" |
|
788 |
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
789 |
movedUp ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
790 |
selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
791 |
] ifFalse:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
792 |
selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
793 |
selectionEndCol == 0 ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
794 |
selectionEndLine := selectionEndLine + 1 |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
795 |
] |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
796 |
]. |
38 | 797 |
]. |
798 |
||
799 |
selectStyle == #line ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
800 |
movedUp ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
801 |
selectionStartCol := 1. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
802 |
] ifFalse:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
803 |
selectionEndCol := 0. |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
804 |
selectionEndLine := selectionEndLine + 1 |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
805 |
] |
38 | 806 |
]. |
807 |
||
209
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
186
diff
changeset
|
808 |
self validateNewSelection. |
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
186
diff
changeset
|
809 |
|
0 | 810 |
(oldStartLine == selectionStartLine) ifTrue:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
811 |
(oldStartCol ~~ selectionStartCol) ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
812 |
self redrawLine:oldStartLine |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
813 |
from:((selectionStartCol min:oldStartCol) max:1) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
814 |
to:((selectionStartCol max:oldStartCol) max:1) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
815 |
] |
0 | 816 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
817 |
self redrawFromLine:(oldStartLine min:selectionStartLine) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
818 |
to:(oldStartLine max:selectionStartLine) |
0 | 819 |
]. |
820 |
||
821 |
(oldEndLine == selectionEndLine) ifTrue:[ |
|
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
822 |
(oldEndCol ~~ selectionEndCol) ifTrue:[ |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
823 |
self redrawLine:oldEndLine |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
824 |
from:((selectionEndCol min:oldEndCol) max:1) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
825 |
to:((selectionEndCol max:oldEndCol) max:1) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
826 |
] |
0 | 827 |
] ifFalse:[ |
1922
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
828 |
self redrawFromLine:(oldEndLine min:selectionEndLine) |
87222b5b9e32
oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents:
1909
diff
changeset
|
829 |
to:(oldEndLine max:selectionEndLine) |
0 | 830 |
]. |
831 |
clickLine := movedLine. |
|
832 |
clickCol := movedCol |
|
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
833 |
|
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
834 |
"Modified: / 28.7.1998 / 16:02:18 / cg" |
0 | 835 |
! |
836 |
||
248 | 837 |
buttonMultiPress:button x:x y:y |
838 |
"multi-mouse-click - select word under pointer" |
|
839 |
||
840 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
841 |
clickCount notNil ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
842 |
clickCount := clickCount + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
843 |
(clickCount == 2) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
844 |
self doubleClickX:x y:y |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
845 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
846 |
(clickCount == 3) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
847 |
self tripleClickX:x y:y |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
848 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
849 |
(clickCount == 4) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
850 |
self quadClickX:x y:y |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
851 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
852 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
853 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
854 |
] |
248 | 855 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
856 |
super buttonMultiPress:button x:x y:y |
248 | 857 |
] |
858 |
||
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
859 |
"Modified: 11.9.1997 / 04:15:35 / cg" |
248 | 860 |
! |
861 |
||
862 |
buttonPress:button x:x y:y |
|
863 |
"mouse-click - prepare for selection change" |
|
864 |
||
1308 | 865 |
|sensor clickVisibleLine| |
866 |
||
867 |
sensor := self sensor. |
|
1909 | 868 |
(sensor notNil and:[sensor shiftDown]) ifTrue:[ |
869 |
"mouse-click with shift - adding to selection" |
|
870 |
||
871 |
"very simple - just simulate a move" |
|
872 |
^ self buttonMotion:(device button1MotionMask) x:x y:y |
|
813
7168eda47e3b
Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents:
770
diff
changeset
|
873 |
]. |
7168eda47e3b
Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents:
770
diff
changeset
|
874 |
|
248 | 875 |
((button == 1) or:[button == #select]) ifTrue:[ |
1909 | 876 |
clickVisibleLine := self visibleLineOfY:y. |
877 |
clickPos := x @ y. |
|
878 |
clickCol := self colOfX:x inVisibleLine:clickVisibleLine. |
|
879 |
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine. |
|
880 |
clickStartLine := clickLine. |
|
881 |
clickStartCol := clickCol. |
|
882 |
self unselect. |
|
883 |
clickCount := 1 |
|
248 | 884 |
] ifFalse:[ |
1909 | 885 |
super buttonPress:button x:x y:y |
248 | 886 |
] |
813
7168eda47e3b
Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents:
770
diff
changeset
|
887 |
|
1909 | 888 |
"Modified: / 20.5.1999 / 17:02:45 / cg" |
248 | 889 |
! |
890 |
||
0 | 891 |
buttonRelease:button x:x y:y |
892 |
"mouse- button release - turn off autoScroll if any" |
|
893 |
||
38 | 894 |
((button == 1) or:[button == #select]) ifTrue:[ |
1909 | 895 |
autoScrollBlock notNil ifTrue:[ |
896 |
self stopScrollSelect |
|
897 |
]. |
|
898 |
clickPos := nil. |
|
0 | 899 |
] ifFalse:[ |
1909 | 900 |
super buttonRelease:button x:x y:y |
901 |
]. |
|
902 |
"/ clickPos := clickLine := clickCol := nil. |
|
903 |
||
904 |
"Modified: / 20.5.1999 / 17:14:23 / cg" |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
905 |
! |
248 | 906 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
907 |
doubleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
908 |
"double-click - select word under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
909 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
910 |
|sel ch matchCol scanCol fwdScan| |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
911 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
912 |
ST80Selections == true ifTrue:[ |
1851 | 913 |
"/ st80 selects: |
914 |
"/ if clicked right after a parenthesis -> select to matching parenthesis |
|
915 |
"/ if clicked at beginning of the line -> select that line |
|
916 |
"/ if clicked at the top of the text -> select all |
|
917 |
"/ |
|
918 |
clickCol == 1 ifTrue:[ |
|
919 |
clickLine == 1 ifTrue:[ |
|
920 |
self selectAll. |
|
921 |
^ self. |
|
922 |
]. |
|
923 |
self selectLineAtY:y. |
|
924 |
selectStyle := #line. |
|
925 |
^ self |
|
926 |
]. |
|
927 |
||
928 |
matchCol := nil. |
|
929 |
"/ see what is to the left of that character ... |
|
930 |
clickCol > 1 ifTrue:[ |
|
931 |
ch := self characterAtLine:clickLine col:clickCol-1. |
|
932 |
('([{<' includes:ch) ifTrue:[ |
|
933 |
matchCol := clickCol - 1 |
|
934 |
] ifFalse:[ |
|
935 |
('"' includes:ch) ifTrue:[ |
|
936 |
scanCol := clickCol - 1. |
|
937 |
fwdScan := true |
|
938 |
] |
|
939 |
] |
|
940 |
]. |
|
941 |
clickCol < (self listAt:clickLine) size ifTrue:[ |
|
942 |
ch := self characterAtLine:clickLine col:clickCol+1. |
|
943 |
(')]}>' includes:ch) ifTrue:[ |
|
944 |
matchCol := clickCol + 1. |
|
945 |
] ifFalse:[ |
|
946 |
('"' includes:ch) ifTrue:[ |
|
947 |
scanCol := clickCol + 1. |
|
948 |
fwdScan := false |
|
949 |
] |
|
950 |
] |
|
951 |
]. |
|
952 |
matchCol notNil ifTrue:[ |
|
953 |
self searchForMatchingParenthesisFromLine:clickLine col:matchCol |
|
954 |
ifFound:[:line :col | |
|
955 |
self selectFromLine:clickLine col:matchCol |
|
956 |
toLine:line col:col. |
|
957 |
^ self |
|
958 |
] |
|
959 |
ifNotFound:[self showNotFound] |
|
960 |
onError:[self beep]. |
|
961 |
^ self |
|
962 |
]. |
|
963 |
scanCol notNil ifTrue:[ |
|
964 |
"/ if its an EOL comment, do it differently |
|
965 |
ch := self characterAtLine:clickLine col:clickCol. |
|
966 |
ch == $/ ifTrue:[ |
|
967 |
self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0. |
|
968 |
^ self |
|
969 |
]. |
|
970 |
||
971 |
self scanFor:$" fromLine:clickLine col:scanCol forward:fwdScan |
|
972 |
ifFound:[:line :col | |
|
973 |
|selStart selEnd| |
|
974 |
||
975 |
fwdScan ifTrue:[ |
|
976 |
selStart := scanCol+1. |
|
977 |
selEnd := col-1. |
|
978 |
] ifFalse:[ |
|
979 |
selStart := scanCol-1. |
|
980 |
selEnd := col+1. |
|
981 |
]. |
|
982 |
self selectFromLine:clickLine col:selStart |
|
983 |
toLine:line col:selEnd. |
|
984 |
^ self |
|
985 |
] |
|
986 |
ifNotFound:[self showNotFound]. |
|
987 |
^ self |
|
988 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
989 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
990 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
991 |
self selectWordAtX:x y:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
992 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
993 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
994 |
special - if clicked on a parenthesis, select to matching |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
995 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
996 |
((sel := self selection) size == 1 |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
997 |
and:[(sel := sel at:1) size == 1]) ifTrue:[ |
1851 | 998 |
ch := sel at:1. |
999 |
('()[]{}<>' includes:ch) ifTrue:[ |
|
1000 |
self searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol |
|
1001 |
ifFound:[:line :col | |
|
1002 |
|prevLine prevCol moveBack pos1| |
|
1003 |
||
1004 |
prevLine := firstLineShown. |
|
1005 |
prevCol := leftOffset. |
|
1006 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1007 |
toLine:line col:col. |
|
1008 |
||
1009 |
self sensor ctrlDown ifFalse:[ |
|
1010 |
"/ undo scroll operation ... |
|
1011 |
self withCursor:Cursor eye do:[ |
|
1012 |
moveBack := false. |
|
1013 |
(')]}>' includes:ch) ifTrue:[ |
|
1014 |
(firstLineShown ~~ prevLine or:[prevCol ~~ leftOffset]) ifTrue:[ |
|
1015 |
moveBack := true |
|
1016 |
] |
|
1017 |
] ifFalse:[ |
|
1018 |
selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[ |
|
1019 |
self makeLineVisible:selectionEndLine. |
|
1020 |
moveBack := true |
|
1021 |
] |
|
1022 |
]. |
|
1023 |
moveBack ifTrue:[ |
|
1024 |
pos1 := x@y. |
|
1025 |
self invalidateRepairNow:true. |
|
1026 |
Delay waitForSeconds:MatchDelayTime. |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1027 |
|
1851 | 1028 |
[self sensor hasUserEventFor:self] whileFalse:[ |
1029 |
Delay waitForSeconds:MatchDelayTime / 2. |
|
1030 |
]. |
|
1031 |
self scrollToLine:prevLine; scrollToCol:prevCol. |
|
1032 |
]. |
|
1033 |
] |
|
1034 |
] |
|
1035 |
] |
|
1036 |
ifNotFound:[self showNotFound] |
|
1037 |
onError:[self beep]. |
|
1038 |
selectStyle := nil |
|
1039 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1040 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1041 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1042 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1043 |
remember words position in case of a drag following |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1044 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1045 |
wordStartLine := selectionStartLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1046 |
wordEndLine := selectionEndLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1047 |
selectStyle == #wordLeft ifTrue:[ |
1851 | 1048 |
wordStartCol := selectionStartCol + 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1049 |
] ifFalse:[ |
1851 | 1050 |
wordStartCol := selectionStartCol. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1051 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1052 |
selectStyle == #wordRight ifTrue:[ |
1851 | 1053 |
wordEndCol := selectionEndCol - 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1054 |
] ifFalse:[ |
1851 | 1055 |
wordEndCol := selectionEndCol |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1056 |
] |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1057 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1058 |
"Created: 11.9.1997 / 04:12:55 / cg" |
1332 | 1059 |
"Modified: 19.9.1997 / 06:43:10 / cg" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1060 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1061 |
|
248 | 1062 |
keyPress:key x:x y:y |
1063 |
"handle some keyboard input (there is not much to be done here)" |
|
1064 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1065 |
<resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1066 |
#GotoLine #SelectAll #SaveAs #Print |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1067 |
#'F*' #'f*' )> |
248 | 1068 |
|
1069 |
(key == #Find) ifTrue:[self search. ^self]. |
|
1070 |
(key == #Copy) ifTrue:[self copySelection. ^self]. |
|
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1071 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
248 | 1072 |
|
1073 |
(key == #FindNext) ifTrue:[self searchFwd. ^self]. |
|
1074 |
(key == #FindPrev) ifTrue:[self searchBwd. ^self]. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1075 |
(key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self]. |
248 | 1076 |
|
1077 |
(key == #SelectAll) ifTrue:[self selectAll. ^self]. |
|
1078 |
||
614 | 1079 |
(key == #SaveAs) ifTrue:[self save. ^self]. |
1080 |
(key == #Print) ifTrue:[self doPrint. ^self]. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
1081 |
|
248 | 1082 |
" |
1083 |
shift-Fn defines a key-sequence |
|
1084 |
Fn pastes that sequence |
|
1085 |
cmd-Fn performs a 'doIt' on the sequence (Workspaces only) |
|
1086 |
||
1087 |
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y) |
|
1088 |
" |
|
1193
811135bbd017
Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents:
1188
diff
changeset
|
1089 |
(key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[ |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1090 |
(('[fF][0-9]' match:key) |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1091 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1092 |
self sensor shiftDown ifTrue:[ |
1967
273caf76b2ea
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
1093 |
UserPreferences current functionKeySequences |
273caf76b2ea
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
1094 |
at:key put:(self selection) |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1095 |
]. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1096 |
^ self |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1097 |
]. |
248 | 1098 |
]. |
1099 |
||
1100 |
super keyPress:key x:x y:y |
|
326
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1101 |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1102 |
"Modified: / 18.4.1997 / 12:12:27 / stefan" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1103 |
"Modified: / 3.5.1999 / 15:03:16 / cg" |
248 | 1104 |
! |
1105 |
||
1106 |
mapped |
|
1107 |
super mapped. |
|
1987 | 1108 |
selectionFgColor := selectionFgColor onDevice:device. |
1109 |
selectionBgColor := selectionBgColor onDevice:device. |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1110 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1111 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1112 |
quadClickX:x y:y |
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1113 |
"quadrupleClick-click - select all" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1114 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1115 |
self selectAll |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1116 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1117 |
"Created: / 11.9.1997 / 04:15:24 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1118 |
"Modified: / 31.3.1998 / 14:21:13 / cg" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1119 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1120 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1121 |
tripleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1122 |
"triple-click - select line under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1123 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1124 |
self selectLineAtY:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1125 |
selectStyle := #line |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1126 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1127 |
"Created: 11.9.1997 / 04:13:37 / cg" |
0 | 1128 |
! ! |
248 | 1129 |
|
1130 |
!TextView methodsFor:'initialize & release'! |
|
1131 |
||
941 | 1132 |
fetchDeviceResources |
1133 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1134 |
||
1135 |
super fetchDeviceResources. |
|
1136 |
||
1987 | 1137 |
selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor onDevice:device]. |
1138 |
selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor onDevice:device]. |
|
941 | 1139 |
|
1140 |
"Created: 14.1.1997 / 00:14:33 / cg" |
|
1141 |
! |
|
1142 |
||
248 | 1143 |
initStyle |
966 | 1144 |
"setup viewStyle specifics" |
1145 |
||
248 | 1146 |
super initStyle. |
1147 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
1148 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
1149 |
|
248 | 1150 |
viewBackground := DefaultViewBackground. |
1151 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
1152 |
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor]. |
|
1153 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
1154 |
selectionBgColor isNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1155 |
device hasColors ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1156 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1157 |
selectionFgColor := fgColor |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1158 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1159 |
selectionBgColor := Color green |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1160 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1161 |
device hasGrayscales ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1162 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1163 |
selectionFgColor := fgColor |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1164 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1165 |
selectionBgColor := Color grey |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1166 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1167 |
selectionBgColor := fgColor |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1168 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1169 |
] |
248 | 1170 |
]. |
708 | 1171 |
|
966 | 1172 |
"Modified: 22.1.1997 / 11:57:53 / cg" |
248 | 1173 |
! |
1174 |
||
1175 |
initialize |
|
1176 |
super initialize. |
|
1177 |
contentsWasSaved := false. |
|
1178 |
||
911 | 1179 |
"I handle menus myself" |
1180 |
menuHolder := menuPerformer := self. |
|
1181 |
||
1182 |
"Modified: 3.1.1997 / 02:14:01 / stefan" |
|
248 | 1183 |
! ! |
1184 |
||
1185 |
!TextView methodsFor:'menu actions'! |
|
1186 |
||
1187 |
appendTo:fileName |
|
1188 |
"append contents to a file named fileName" |
|
1189 |
||
1190 |
|aStream msg| |
|
1191 |
||
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1192 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:fileName asFilename) ifFalse:[ |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1193 |
msg := resources string:'Refused to append to file ''%1'' !!' with:fileName. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1194 |
self warn:(msg , '\\(ST/X internal permission check)' ) withCRs. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1195 |
^ self |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1196 |
]. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1197 |
|
248 | 1198 |
aStream := FileStream appendingOldFileNamed:fileName. |
1199 |
aStream isNil ifTrue:[ |
|
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1200 |
msg := resources string:'cannot append to file %1 !!' with:fileName. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1201 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
248 | 1202 |
] ifFalse:[ |
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1203 |
self |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1204 |
fileOutContentsOn:aStream |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1205 |
compressTabs:true |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1206 |
encoding:externalEncoding. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1207 |
aStream close. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1208 |
contentsWasSaved := true |
248 | 1209 |
] |
1210 |
! |
|
1211 |
||
1212 |
changeFont |
|
1213 |
"pop up a fontPanel to change font" |
|
1214 |
||
411 | 1215 |
|newFont| |
248 | 1216 |
|
411 | 1217 |
newFont := FontPanel fontFromUserInitial:font. |
1218 |
newFont notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1219 |
self font:newFont. |
411 | 1220 |
] |
1221 |
||
1222 |
"Modified: 27.2.1996 / 00:53:51 / cg" |
|
248 | 1223 |
! |
1224 |
||
1225 |
copySelection |
|
1226 |
"copy contents into smalltalk copybuffer" |
|
1227 |
||
863 | 1228 |
|text| |
248 | 1229 |
|
1230 |
text := self selection. |
|
1231 |
text notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1232 |
self unselect. |
649
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
1233 |
|
863 | 1234 |
"/ forget any emphasis ... |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1235 |
text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1236 |
self setTextSelection:text. |
248 | 1237 |
] |
649
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
1238 |
|
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
1239 |
"Modified: 17.5.1996 / 08:57:54 / cg" |
248 | 1240 |
! |
1241 |
||
1242 |
defaultForGotoLine |
|
1243 |
"return a default value to show in the gotoLine box" |
|
1244 |
||
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1245 |
^ selectionStartLine |
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1246 |
|
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1247 |
"Modified: 1.3.1996 / 18:44:36 / cg" |
248 | 1248 |
! |
1249 |
||
614 | 1250 |
doPrint |
1251 |
"print the contents on the printer" |
|
1252 |
||
1253 |
|printStream| |
|
1254 |
||
1255 |
list isNil ifTrue:[^ self]. |
|
1256 |
||
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
1257 |
self withWaitCursorDo:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1258 |
printStream := Printer new. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1259 |
printStream notNil ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1260 |
Printer writeErrorSignal handle:[:ex | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1261 |
self warn:('error while printing:\\' |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1262 |
, ex errorString |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1263 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1264 |
] do:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1265 |
self fileOutContentsOn:printStream. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1266 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1267 |
printStream close |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1268 |
] |
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
1269 |
]. |
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
1270 |
|
614 | 1271 |
"Created: 6.5.1996 / 16:11:26 / cg" |
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
1272 |
"Modified: 5.9.1996 / 19:18:30 / cg" |
614 | 1273 |
! |
1274 |
||
248 | 1275 |
editMenu |
1109 | 1276 |
"return my popUpMenu" |
1277 |
||
489 | 1278 |
<resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1255
diff
changeset
|
1279 |
<resource: #programMenu> |
489 | 1280 |
|
1545 | 1281 |
|items m| |
1282 |
||
1283 |
items := #( |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1284 |
('copy' copySelection Copy) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1285 |
('-' nil ) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1286 |
('font ...' changeFont ) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1287 |
('-' nil ) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1288 |
('search ...' search Find) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1289 |
('goto ...' gotoLine GotoLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1290 |
('-' nil ) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1291 |
('save as ...' save SaveAs) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1292 |
('print' doPrint Print) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1293 |
). |
248 | 1294 |
|
1545 | 1295 |
m := PopUpMenu itemList:items resources:resources. |
248 | 1296 |
|
1297 |
self hasSelection ifFalse:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1298 |
m disable:#copySelection. |
248 | 1299 |
]. |
1300 |
^ m |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
1301 |
|
1545 | 1302 |
"Modified: / 21.5.1998 / 15:44:37 / cg" |
248 | 1303 |
! |
1304 |
||
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1305 |
find |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1306 |
"same as search - for VW compatibility" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1307 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1308 |
self search |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1309 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1310 |
"Created: 31.7.1997 / 19:13:58 / cg" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1311 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1312 |
|
248 | 1313 |
gotoLine |
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
1314 |
"show a box to enter lineNumber for positioning; |
1926 | 1315 |
The entered number may be prefixed by a + or -; |
1316 |
in this case, the linenumber is taken relative to the current position." |
|
1317 |
||
1318 |
|l lineNumberBox input lineToGo relative| |
|
248 | 1319 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1320 |
lineNumberBox := |
1926 | 1321 |
EnterBox |
1322 |
title:(resources string:'line number (or +/- relativeNr):') |
|
1323 |
okText:(resources string:'goto') |
|
1324 |
abortText:(resources string:'cancel') |
|
1325 |
action:[:l | input := l]. |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1326 |
|
248 | 1327 |
l := self defaultForGotoLine. |
1328 |
l notNil ifTrue:[ |
|
1926 | 1329 |
l := l printString |
248 | 1330 |
]. |
1331 |
lineNumberBox initialText:l . |
|
1380 | 1332 |
lineNumberBox showAtPointer. |
1333 |
||
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
1334 |
input size > 0 ifTrue:[ |
1926 | 1335 |
input := input withoutSpaces. |
1336 |
input size > 0 ifTrue:[ |
|
1337 |
(input startsWith:$+) ifTrue:[ |
|
1338 |
relative := 1. |
|
1339 |
] ifFalse:[ |
|
1340 |
(input startsWith:$-) ifTrue:[ |
|
1341 |
relative := -1. |
|
1342 |
]. |
|
1343 |
]. |
|
1344 |
relative notNil ifTrue:[ |
|
1345 |
input := input copyFrom:2. |
|
1346 |
]. |
|
1347 |
lineToGo := Integer readFromString:input onError:nil. |
|
1348 |
lineToGo notNil ifTrue:[ |
|
1349 |
relative notNil ifTrue:[ |
|
1350 |
lineToGo := self currentLine + (lineToGo * relative) |
|
1351 |
]. |
|
1352 |
self gotoLine:lineToGo |
|
1353 |
] |
|
1354 |
] |
|
1380 | 1355 |
]. |
1356 |
||
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
1357 |
"Modified: / 17.5.1998 / 20:07:59 / cg" |
248 | 1358 |
! |
1359 |
||
1360 |
save |
|
1361 |
"save contents into a file |
|
1362 |
- ask user for filename using a fileSelectionBox." |
|
1363 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1364 |
|fileBox| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1365 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1366 |
fileBox := FileSaveBox |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1367 |
title:(resources string:'save contents in:') |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1368 |
okText:(resources string:'save') |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1369 |
abortText:(resources string:'cancel') |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1370 |
action:[:fileName | self saveAs:fileName]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1371 |
fileBox appendAction:[:fileName | self appendTo:fileName]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1372 |
directoryForFileDialog notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1373 |
fileBox directory:directoryForFileDialog |
248 | 1374 |
]. |
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1375 |
defaultFileNameForFileDialog notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1376 |
fileBox initialText:defaultFileNameForFileDialog asString |
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1377 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1378 |
fileBox showAtPointer. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1379 |
|
1188 | 1380 |
directoryForFileDialog := fileBox directory. "/ remember for next time |
1381 |
||
1382 |
fileBox destroy. |
|
1383 |
||
1384 |
"Modified: 16.4.1997 / 20:49:26 / cg" |
|
248 | 1385 |
! |
1386 |
||
1387 |
saveAs:fileName |
|
916
4201c9c2a4f0
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
1388 |
"save the contents into a file named fileName" |
248 | 1389 |
|
916
4201c9c2a4f0
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
1390 |
self withCursor:Cursor write do:[ |
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1391 |
|aStream msg| |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1392 |
|
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1393 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:fileName asFilename) ifFalse:[ |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1394 |
msg := resources string:'Refused to write file ''%1'' !!' with:fileName. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1395 |
self warn:(msg , '\\(ST/X internal permission check)' ) withCRs. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1396 |
^ self |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1397 |
]. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1398 |
|
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1399 |
FileStream openErrorSignal catch:[ |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1400 |
aStream := FileStream newFileNamed:fileName. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1401 |
]. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1402 |
aStream isNil ifTrue:[ |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1403 |
msg := resources string:'cannot write file ''%1'' !!' with:fileName. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1404 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1405 |
] ifFalse:[ |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1406 |
self |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1407 |
fileOutContentsOn:aStream |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1408 |
compressTabs:true |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1409 |
encoding:externalEncoding. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1410 |
aStream close. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1411 |
contentsWasSaved := true |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1412 |
] |
248 | 1413 |
] |
916
4201c9c2a4f0
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
1414 |
|
1359 | 1415 |
"Modified: 22.10.1997 / 12:32:51 / cg" |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1416 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1417 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1418 |
search |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1419 |
"search for a string - show a box to enter searchpattern |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1420 |
- currently no regular expressions are handled." |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1421 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1422 |
" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1423 |
Q: should we preserve the last searchstring between views ? |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1424 |
" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1425 |
|
1475
fe86beb9eb07
ok-cursor in search-prev button
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1426 |
|searchBox patternField stringHolder caseHolder |
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1427 |
b bPrev bNext pattern fwd ign initialString| |
1326 | 1428 |
|
1429 |
ign := lastSearchIgnoredCase ? false. |
|
1430 |
||
1431 |
searchBox := Dialog new. |
|
1334 | 1432 |
searchBox label:'string search'. |
1329 | 1433 |
(searchBox addTextLabel:(resources at:'searchPattern:')) adjust:#left. |
1326 | 1434 |
searchBox addVerticalSpace. |
1435 |
searchBox leftIndent:ViewSpacing; rightIndent:ViewSpacing. |
|
1677
2590c4349062
remember last searchString(s)
Claus Gittinger <cg@exept.de>
parents:
1661
diff
changeset
|
1436 |
"/ patternField := searchBox addInputFieldOn:(stringHolder := '' asValue). |
2590c4349062
remember last searchString(s)
Claus Gittinger <cg@exept.de>
parents:
1661
diff
changeset
|
1437 |
patternField := searchBox addComboBoxOn:(stringHolder := '' asValue) tabable:true. |
2590c4349062
remember last searchString(s)
Claus Gittinger <cg@exept.de>
parents:
1661
diff
changeset
|
1438 |
patternField list:LastSearchPatterns. |
1326 | 1439 |
searchBox addVerticalSpace. |
1440 |
searchBox addCheckBox:(resources string:'ignore case') on:(caseHolder := ign asValue). |
|
1441 |
searchBox addVerticalSpace. |
|
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1442 |
"/ |
1326 | 1443 |
"/ "soon to come: search & replace box ... |
1444 |
"/ |
|
1445 |
"/ searchBox addLabel:((resources string:'replace with:'). |
|
1446 |
"/ searchBox addInputFieldOn:(replacementHolder := '' asValue). |
|
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1447 |
"/ searchBox addVerticalSpace. |
1326 | 1448 |
"/ |
1449 |
searchBox addAbortButtonLabelled:(resources at:'cancel'). |
|
1475
fe86beb9eb07
ok-cursor in search-prev button
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1450 |
|
1761
e35b524d6d64
care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents:
1755
diff
changeset
|
1451 |
bPrev := searchBox addOkButton:(Button label:(resources at:'prev')). |
1766 | 1452 |
bPrev action:[fwd := false. searchBox okPressed]. |
1475
fe86beb9eb07
ok-cursor in search-prev button
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1453 |
bNext := searchBox addOkButtonLabelled:(resources at:'next'). |
1766 | 1454 |
bNext action:[fwd := true. "searchBox okPressed"]. |
1475
fe86beb9eb07
ok-cursor in search-prev button
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1455 |
bPrev cursor:(bNext cursor). |
fe86beb9eb07
ok-cursor in search-prev button
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1456 |
|
1326 | 1457 |
"/ searchBox addButton:(Button label:(resources at:'all')); |
1458 |
||
1459 |
lastSearchPattern notNil ifTrue:[ |
|
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1460 |
initialString := lastSearchPattern |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1461 |
]. |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1462 |
self hasSelection ifTrue:[ |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1463 |
selectionStartLine == selectionEndLine ifTrue:[ |
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1464 |
initialString := self selection |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1465 |
] |
1326 | 1466 |
]. |
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1467 |
initialString isNil ifTrue:[ |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1468 |
LastSearchPatterns size > 0 ifTrue:[ |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1469 |
initialString := LastSearchPatterns first |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1470 |
] |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1471 |
]. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1472 |
|
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1473 |
initialString notNil ifTrue:[ |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1474 |
stringHolder value:initialString. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
1475 |
]. |
1380 | 1476 |
patternField selectAll. |
1326 | 1477 |
|
1765 | 1478 |
fwd := true. |
1326 | 1479 |
searchBox open. |
1480 |
||
1481 |
searchBox accepted ifTrue:[ |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1482 |
pattern := stringHolder value. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1483 |
pattern := pattern string withoutSeparators. "/ is that a good idea ? |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1484 |
pattern notEmpty ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1485 |
LastSearchPatterns isNil ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1486 |
LastSearchPatterns := OrderedCollection new. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1487 |
]. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1488 |
(LastSearchPatterns includes:pattern) ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1489 |
LastSearchPatterns remove:pattern. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1490 |
] ifFalse:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1491 |
LastSearchPatterns size > 10 ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1492 |
LastSearchPatterns removeFirst |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1493 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1494 |
]. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1495 |
LastSearchPatterns addFirst:pattern. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1496 |
|
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1497 |
ign := caseHolder value. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1498 |
fwd ifFalse:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1499 |
lastSearchDirection := #backward. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1500 |
self searchBwd:pattern ignoreCase:ign. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1501 |
] ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1502 |
lastSearchDirection := #forward. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1503 |
self searchFwd:pattern ignoreCase:ign. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1504 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1505 |
] |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1506 |
]. |
1326 | 1507 |
|
1508 |
"/ searchBox := |
|
1509 |
"/ EnterBox2 |
|
1510 |
"/ title:(resources at:'searchPattern:') |
|
1511 |
"/ okText1:(resources at:'prev') |
|
1512 |
"/ okText2:(resources at:'next') |
|
1513 |
"/ abortText:(resources at:'cancel') |
|
1514 |
"/ action1:[:pattern | pattern notEmpty ifTrue:[self searchBwd:(pattern withoutSeparators)]] |
|
1515 |
"/ action2:[:pattern | pattern notEmpty ifTrue:[self searchFwd:(pattern withoutSeparators)]]. |
|
1516 |
"/ |
|
1517 |
"/ searchPattern notNil ifTrue:[ |
|
1518 |
"/ searchBox initialText:searchPattern |
|
1519 |
"/ ]. |
|
1520 |
"/ self hasSelection ifTrue:[ |
|
1521 |
"/ selectionStartLine == selectionEndLine ifTrue:[ |
|
1522 |
"/ searchBox initialText:self selection |
|
1523 |
"/ ] |
|
1524 |
"/ ]. |
|
1525 |
"/ searchBox showAtPointer |
|
1526 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1527 |
"Modified: / 3.5.1999 / 15:01:09 / cg" |
248 | 1528 |
! ! |
1529 |
||
1530 |
!TextView methodsFor:'private'! |
|
1531 |
||
1532 |
fileOutContentsOn:aStream |
|
1533 |
"save contents on a stream, replacing leading spaces by tab-characters." |
|
1534 |
||
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1535 |
self |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1536 |
fileOutContentsOn:aStream |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1537 |
compressTabs:true |
248 | 1538 |
! |
1539 |
||
1540 |
fileOutContentsOn:aStream compressTabs:compressTabs |
|
1541 |
"save contents on a stream. If compressTabs is true, |
|
1542 |
leading spaces will be replaced by tab-characters in the output." |
|
1543 |
||
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1544 |
self |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1545 |
fileOutContentsOn:aStream |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1546 |
compressTabs:compressTabs |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1547 |
encoding:nil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1548 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1549 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1550 |
fileOutContentsOn:aStream compressTabs:compressTabs encoding:encodingSymOrNil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1551 |
"save contents on a stream. If compressTabs is true, |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1552 |
leading spaces will be replaced by tab-characters in the output." |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1553 |
|
248 | 1554 |
|startNr nLines string| |
1555 |
||
758 | 1556 |
aStream isFileStream ifTrue:[ |
2000 | 1557 |
"on some systems, writing linewise is very slow (via NFS) |
1558 |
therefore we convert to a string and write it in big chunks. |
|
1559 |
To avoid creating huge strings, we do it in blocks of 1000 lines, |
|
1560 |
limiting temporary string creation to about 50-80k. |
|
1561 |
" |
|
1562 |
startNr := 1. |
|
1563 |
nLines := list size. |
|
1564 |
[startNr <= nLines] whileTrue:[ |
|
1565 |
string := list asStringWithCRsFrom:startNr |
|
1566 |
to:((startNr + 1000) min:nLines) |
|
1567 |
compressTabs:compressTabs. |
|
1568 |
encodingSymOrNil notNil ifTrue:[ |
|
1569 |
string := string encodeInto:encodingSymOrNil |
|
1570 |
]. |
|
1571 |
aStream nextPutAll:string. |
|
1572 |
startNr := startNr + 1000 + 1. |
|
1573 |
]. |
|
758 | 1574 |
] ifFalse:[ |
2000 | 1575 |
list do:[:aLine | |
1576 |
aLine notNil ifTrue:[ |
|
1577 |
encodingSymOrNil notNil ifTrue:[ |
|
1578 |
aStream nextPutLine:(aLine encodeInto:encodingSymOrNil) |
|
1579 |
] ifFalse:[ |
|
1580 |
aStream nextPutLine:aLine. |
|
1581 |
] |
|
1582 |
] ifFalse:[ |
|
1583 |
aStream cr. |
|
1584 |
] |
|
1585 |
] |
|
758 | 1586 |
] |
248 | 1587 |
|
758 | 1588 |
"Modified: 8.6.1996 / 11:50:46 / cg" |
248 | 1589 |
! |
1590 |
||
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1591 |
getFontParameters |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1592 |
"get some info of the used font. They are cached since we use them often .. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1593 |
This is redefined here, to use the fonts maxHeight/maxAscent for |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1594 |
line separation. This is required, to allow for proper handling of |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1595 |
national characters, such as A-dieresis ..." |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1596 |
|
1987 | 1597 |
font := font onDevice:device. |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1598 |
includesNonStrings == true ifTrue:[ |
1987 | 1599 |
"/ for now, we do not support variable height entries ... |
1600 |
fontHeight := list first heightOn:self |
|
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1601 |
] ifFalse:[ |
1987 | 1602 |
fontHeight := font maxHeight. |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1603 |
]. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1604 |
fontHeight := fontHeight + lineSpacing. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1605 |
fontAscent := font maxAscent. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1606 |
fontWidth := font width. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1607 |
fontIsFixedWidth := font isFixedWidth. |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1608 |
|
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1609 |
"Modified: 22.5.1996 / 12:02:47 / cg" |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1610 |
"Created: 22.5.1996 / 12:18:34 / cg" |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1611 |
! |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
1612 |
|
248 | 1613 |
scrollSelectDown |
1614 |
"auto scroll action; scroll and reinstall timed-block" |
|
1615 |
||
1616 |
|prevEndLine| |
|
1617 |
||
1618 |
"just to make certain ..." |
|
1619 |
selectionEndLine isNil ifTrue:[^ self]. |
|
1620 |
||
1621 |
self scrollDown. |
|
1622 |
||
1623 |
"make new selection immediately visible" |
|
1624 |
prevEndLine := selectionEndLine. |
|
1625 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
1626 |
selectionEndCol := 0. |
|
1627 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
1628 |
self redrawLine:lineNr |
|
1629 |
]. |
|
1630 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
1631 |
! |
|
1632 |
||
1633 |
scrollSelectLeft |
|
1634 |
"auto scroll action; scroll and reinstall timed-block" |
|
1635 |
||
1636 |
|prevStartLine| |
|
1637 |
||
1638 |
"just to make certain ..." |
|
1639 |
selectionStartLine isNil ifTrue:[^ self]. |
|
1640 |
selectionStartCol isNil ifTrue:[^ self]. |
|
1641 |
||
1642 |
"make new selection immediately visible" |
|
1643 |
prevStartLine := selectionStartLine. |
|
1644 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
1645 |
self scrollLeft. |
|
1646 |
||
1647 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
1648 |
! |
|
1649 |
||
1650 |
scrollSelectRight |
|
1651 |
"auto scroll action; scroll and reinstall timed-block" |
|
1652 |
||
1653 |
|prevEndCol| |
|
1654 |
||
1655 |
"just to make certain ..." |
|
1656 |
selectionEndCol isNil ifTrue:[^ self]. |
|
1657 |
||
1658 |
prevEndCol := selectionEndCol. |
|
1659 |
selectionEndCol := selectionEndCol + 1. |
|
1660 |
self scrollRight. |
|
1661 |
||
1662 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
1663 |
! |
|
1664 |
||
1665 |
scrollSelectUp |
|
1666 |
"auto scroll action; scroll and reinstall timed-block" |
|
1667 |
||
1668 |
|prevStartLine| |
|
1669 |
||
1670 |
"just to make certain ..." |
|
1671 |
selectionStartLine isNil ifTrue:[^ self]. |
|
1672 |
||
1673 |
self scrollUp. |
|
1674 |
||
1675 |
"make new selection immediately visible" |
|
1676 |
prevStartLine := selectionStartLine. |
|
1677 |
selectionStartLine := firstLineShown. |
|
1678 |
selectionStartCol := 1. |
|
1679 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
1680 |
self redrawLine:lineNr |
|
1681 |
]. |
|
1682 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
1683 |
! |
|
1684 |
||
1685 |
stopScrollSelect |
|
1686 |
"stop auto scroll; deinstall timed-block" |
|
1687 |
||
1688 |
autoScrollBlock notNil ifTrue:[ |
|
1689 |
Processor removeTimedBlock:autoScrollBlock. |
|
1690 |
self compressMotionEvents:true. |
|
1691 |
autoScrollBlock := nil. |
|
1692 |
autoScrollDeltaT := nil |
|
1693 |
] |
|
1694 |
! |
|
1695 |
||
1696 |
widthForScrollBetween:firstLine and:lastLine |
|
1697 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
1698 |
||
1699 |
selectionStartLine notNil ifTrue:[ |
|
1700 |
(lastLine < selectionStartLine) ifFalse:[ |
|
1701 |
(firstLine > selectionEndLine) ifFalse:[ |
|
1702 |
^ width |
|
1703 |
] |
|
1704 |
] |
|
1705 |
]. |
|
1706 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
1707 |
! ! |
|
1708 |
||
997 | 1709 |
!TextView methodsFor:'queries'! |
1710 |
||
1711 |
specClass |
|
1380 | 1712 |
"redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)" |
1713 |
||
997 | 1714 |
self class == TextView ifTrue:[^ TextEditorSpec]. |
1046 | 1715 |
^ super specClass |
997 | 1716 |
|
1380 | 1717 |
"Modified: / 31.10.1997 / 19:48:35 / cg" |
997 | 1718 |
! ! |
1719 |
||
248 | 1720 |
!TextView methodsFor:'redrawing'! |
1721 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1722 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1723 |
"if there is a margin, clear it - a helper for selection drawing" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1724 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1725 |
(leftMargin ~~ 0) ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1726 |
self paint:color. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1727 |
self fillRectangleX:margin |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1728 |
y:(self yOfVisibleLine:visLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1729 |
width:leftMargin |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1730 |
height:fontHeight |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1731 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1732 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1733 |
"Created: 6.3.1996 / 14:22:55 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1734 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1735 |
|
248 | 1736 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
1737 |
"redraw a visible line range" |
|
1738 |
||
1739 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
1740 |
||
1741 |
shown ifFalse:[^ self]. |
|
1742 |
||
1743 |
end := endVisLineNr. |
|
1744 |
(end > nLinesShown) ifTrue:[ |
|
1745 |
end := nLinesShown |
|
1746 |
]. |
|
1747 |
||
1748 |
selectionStartLine isNil ifTrue:[ |
|
1749 |
specialCare := false |
|
1750 |
] ifFalse:[ |
|
1751 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
|
1752 |
(startLine > selectionEndLine) ifTrue:[ |
|
1753 |
specialCare := false |
|
1754 |
] ifFalse:[ |
|
1755 |
endLine := self visibleLineToAbsoluteLine:end. |
|
1756 |
(endLine < selectionStartLine) ifTrue:[ |
|
1757 |
specialCare := false |
|
1758 |
] ifFalse:[ |
|
1759 |
specialCare := true |
|
1760 |
] |
|
1761 |
] |
|
1762 |
]. |
|
1763 |
||
1764 |
"easy: nothing is selected" |
|
1765 |
specialCare ifFalse:[ |
|
1766 |
super redrawFromVisibleLine:startVisLineNr to:end. |
|
1767 |
^ self |
|
1768 |
]. |
|
1769 |
||
1770 |
"easy: all is selected" |
|
1771 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
1772 |
self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor |
|
1773 |
and:selectionBgColor. |
|
1774 |
^ self |
|
1775 |
]. |
|
1776 |
||
1777 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
1778 |
"draw unselected top part" |
|
1779 |
||
1780 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
1781 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
1782 |
||
1783 |
"and first partial selected line" |
|
1784 |
self redrawVisibleLine:selVisStart. |
|
1785 |
||
1786 |
"rest starts after this one" |
|
1787 |
line1 := selVisStart + 1 |
|
1788 |
] ifFalse:[ |
|
1789 |
line1 := 1 |
|
1790 |
]. |
|
1791 |
||
1792 |
(line1 > end) ifTrue:[^ self]. |
|
1793 |
(line1 < startVisLineNr) ifTrue:[ |
|
1794 |
line1 := startVisLineNr |
|
1795 |
]. |
|
1796 |
||
1797 |
"draw middle part of selection" |
|
1798 |
||
1799 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
1800 |
line2 := nLinesShown |
|
1801 |
] ifFalse:[ |
|
1802 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
|
1803 |
]. |
|
1804 |
(line2 > end) ifTrue:[ |
|
1805 |
line2 := end |
|
1806 |
]. |
|
1807 |
||
1808 |
self drawFromVisibleLine:line1 to:line2 with:selectionFgColor |
|
1809 |
and:selectionBgColor. |
|
1810 |
||
1811 |
(line2 >= end) ifTrue:[^ self]. |
|
1812 |
||
1813 |
"last line of selection" |
|
1814 |
self redrawVisibleLine:(line2 + 1). |
|
1815 |
||
1816 |
((line2 + 2) <= end) ifTrue:[ |
|
1817 |
super redrawFromVisibleLine:(line2 + 2) to:end |
|
1818 |
] |
|
1819 |
! |
|
1820 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1821 |
redrawMarginOfVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1822 |
"draw margin - a helper for selection drawing" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1823 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1824 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1825 |
(leftMargin ~~ 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1826 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1827 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1828 |
"Created: 6.3.1996 / 14:21:48 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1829 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1830 |
|
248 | 1831 |
redrawVisibleLine:visLine |
1832 |
"redraw visible line lineNr" |
|
1833 |
||
1834 |
|len line l| |
|
1835 |
||
1836 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1837 |
line := self visibleLineToAbsoluteLine:visLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1838 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1839 |
(line == selectionStartLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1840 |
(line == selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1841 |
"its part-of-single-line selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1842 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1843 |
(selectionStartCol > 1) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1844 |
super redrawVisibleLine:visLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1845 |
from:1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1846 |
to:(selectionStartCol - 1) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1847 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1848 |
self drawVisibleLine:visLine from:selectionStartCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1849 |
to:selectionEndCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1850 |
with:selectionFgColor |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1851 |
and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1852 |
super redrawVisibleLine:visLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1853 |
from:(selectionEndCol + 1). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1854 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1855 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1856 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1857 |
"its the first line of a multi-line selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1858 |
(selectionStartCol ~~ 1) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1859 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1860 |
super redrawVisibleLine:visLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1861 |
from:1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1862 |
to:(selectionStartCol - 1) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1863 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1864 |
leftOffset == 0 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1865 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1866 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1867 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1868 |
self drawVisibleLine:visLine from:selectionStartCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1869 |
with:selectionFgColor and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1870 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1871 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1872 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1873 |
(line == selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1874 |
"its the last line of a multi-line selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1875 |
(selectionEndCol == 0) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1876 |
^ super redrawVisibleLine:visLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1877 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1878 |
l := self visibleAt:selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1879 |
len := l size. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1880 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1881 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1882 |
self drawVisibleLine:visLine from:1 to:selectionEndCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1883 |
with:selectionFgColor and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1884 |
super redrawVisibleLine:visLine from:(selectionEndCol + 1). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1885 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1886 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1887 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1888 |
"its a full line in a multi-line selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1889 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1890 |
self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1891 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1892 |
] |
248 | 1893 |
]. |
1894 |
super redrawVisibleLine:visLine |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1895 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1896 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 1897 |
! |
1898 |
||
1899 |
redrawVisibleLine:visLine col:col |
|
633 | 1900 |
"redraw single character at col in visible line lineNr." |
248 | 1901 |
|
633 | 1902 |
|line fg bg| |
248 | 1903 |
|
1904 |
line := self visibleLineToAbsoluteLine:visLine. |
|
633 | 1905 |
|
1906 |
"/ |
|
1907 |
"/ care for selection |
|
1908 |
"/ |
|
1909 |
fg := fgColor. |
|
1910 |
bg := bgColor. |
|
1911 |
||
248 | 1912 |
selectionStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1913 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1914 |
((line == selectionStartLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1915 |
and: [col < selectionStartCol]) ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1916 |
((line == selectionEndLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1917 |
and: [col > selectionEndCol]) ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1918 |
"its in the selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1919 |
fg := selectionFgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1920 |
bg := selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1921 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1922 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1923 |
] |
248 | 1924 |
]. |
633 | 1925 |
self drawVisibleLine:visLine col:col with:fg and:bg |
1496 | 1926 |
|
1927 |
"Modified: / 22.4.1998 / 08:53:05 / cg" |
|
248 | 1928 |
! |
1929 |
||
1930 |
redrawVisibleLine:visLine from:startCol |
|
1931 |
"redraw visible line lineNr from startCol to end of line" |
|
1932 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1933 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1934 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1935 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1936 |
col == 0 ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1937 |
col := 1. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1938 |
]. |
248 | 1939 |
|
1940 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1941 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1942 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1943 |
((line == selectionStartLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1944 |
or:[line == selectionEndLine]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1945 |
"since I'm lazy, redraw full line" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1946 |
self redrawVisibleLine:visLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1947 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1948 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1949 |
"the line is fully within the selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1950 |
self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1951 |
drawVisibleLine:visLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1952 |
from:col |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1953 |
with:selectionFgColor |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1954 |
and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1955 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1956 |
] |
248 | 1957 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1958 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1959 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1960 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 1961 |
! |
1962 |
||
1963 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
1964 |
"redraw visible line lineNr from startCol to endCol" |
|
1965 |
||
1966 |
|line allOut allIn leftCol rightCol| |
|
1967 |
||
1968 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1969 |
||
1970 |
allIn := false. |
|
1971 |
allOut := false. |
|
1972 |
selectionStartLine isNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1973 |
allOut := true |
248 | 1974 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1975 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1976 |
allOut := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1977 |
] ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1978 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1979 |
((endCol < selectionStartCol) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1980 |
or:[startCol > selectionEndCol]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1981 |
allOut := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1982 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1983 |
((startCol >= selectionStartCol) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1984 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1985 |
allIn := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1986 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1987 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1988 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1989 |
(line == selectionStartLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1990 |
(endCol < selectionStartCol) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1991 |
allOut := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1992 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1993 |
(startCol >= selectionStartCol) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1994 |
allIn := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1995 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1996 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1997 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1998 |
(line == selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
1999 |
(startCol > selectionEndCol) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2000 |
allOut := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2001 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2002 |
(endCol <= selectionEndCol) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2003 |
allIn := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2004 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2005 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2006 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2007 |
allIn := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2008 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2009 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2010 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2011 |
] |
248 | 2012 |
]. |
2013 |
allOut ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2014 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2015 |
^ self |
248 | 2016 |
]. |
2017 |
||
2018 |
allIn ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2019 |
self drawVisibleLine:visLine from:startCol to:endCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2020 |
with:selectionFgColor and:selectionBgColor |
248 | 2021 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2022 |
"redraw part before selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2023 |
((line == selectionStartLine) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2024 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2025 |
super redrawVisibleLine:visLine from:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2026 |
to:(selectionStartCol - 1). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2027 |
leftCol := selectionStartCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2028 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2029 |
leftCol := startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2030 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2031 |
"redraw selected part" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2032 |
(selectionEndLine > line) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2033 |
rightCol := endCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2034 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2035 |
rightCol := selectionEndCol min:endCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2036 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2037 |
self drawVisibleLine:visLine from:leftCol to:rightCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2038 |
with:selectionFgColor and:selectionBgColor. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2039 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2040 |
"redraw part after selection" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2041 |
(rightCol < endCol) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2042 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2043 |
] |
248 | 2044 |
]. |
2045 |
||
2046 |
"special care for first and last line of selection: |
|
2047 |
must handle margin also" |
|
2048 |
||
2049 |
((line == selectionEndLine) |
|
2050 |
and:[(startCol == 1) |
|
2051 |
and:[selectionStartLine < selectionEndLine]]) |
|
2052 |
ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2053 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
248 | 2054 |
]. |
2055 |
||
2056 |
((line == selectionStartLine) |
|
2057 |
and:[(startCol == 1) |
|
2058 |
and:[selectionStartLine < selectionEndLine]]) |
|
2059 |
ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2060 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
248 | 2061 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2062 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2063 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 2064 |
! ! |
2065 |
||
2066 |
!TextView methodsFor:'searching'! |
|
2067 |
||
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2068 |
scanFor:aCharacter fromLine:startLine col:startCol forward:forward |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2069 |
ifFound:foundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2070 |
ifNotFound:notFoundBlock |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2071 |
"search for a character in the direction given by forward. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2072 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not." |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2073 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2074 |
|i lineString |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2075 |
line "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2076 |
col "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2077 |
delta "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2078 |
endCol "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2079 |
cc |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2080 |
maxLine "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2081 |
| |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2082 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2083 |
col := startCol. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2084 |
line := startLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2085 |
forward ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2086 |
delta := 1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2087 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2088 |
delta := -1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2089 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2090 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2091 |
lineString := list at:line. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2092 |
maxLine := list size. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2093 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2094 |
col := col + delta. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2095 |
[true] whileTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2096 |
lineString notNil ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2097 |
forward ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2098 |
endCol := lineString size. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2099 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2100 |
endCol := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2101 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2102 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2103 |
col to:endCol by:delta do:[:rCol | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2104 |
cc := lineString at:rCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2105 |
cc == aCharacter ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2106 |
^ foundBlock value:line value:rCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2107 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2108 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2109 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2110 |
line := line + delta. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2111 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2112 |
^ notFoundBlock value |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2113 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2114 |
lineString := list at:line. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2115 |
forward ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2116 |
col := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2117 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2118 |
col := lineString size |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2119 |
] |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2120 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2121 |
"not reached" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2122 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2123 |
"Modified: 15.10.1996 / 12:22:30 / cg" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2124 |
"Created: 11.9.1997 / 04:36:29 / cg" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2125 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2126 |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2127 |
searchAgainInSameDirection |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2128 |
"search again in the same direction and -if found- position cursor" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2129 |
|
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2130 |
|ign| |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2131 |
|
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2132 |
ign := lastSearchIgnoredCase ? false. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2133 |
|
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2134 |
self setSearchPattern. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2135 |
lastSearchPattern notNil ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2136 |
lastSearchDirection == #backward ifTrue:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2137 |
self |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2138 |
searchBwd:lastSearchPattern |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2139 |
ignoreCase:ign |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2140 |
] ifFalse:[ |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2141 |
self |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2142 |
searchFwd:lastSearchPattern |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2143 |
ignoreCase:ign |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2144 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2145 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2146 |
|
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2147 |
"Modified: / 3.5.1999 / 15:00:28 / cg" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2148 |
"Created: / 3.5.1999 / 15:02:16 / cg" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2149 |
! |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2150 |
|
248 | 2151 |
searchBwd |
2152 |
"search backward and -if found- position cursor" |
|
2153 |
||
1353 | 2154 |
|ign| |
2155 |
||
2156 |
ign := lastSearchIgnoredCase ? false. |
|
2157 |
||
248 | 2158 |
self setSearchPattern. |
1326 | 2159 |
lastSearchPattern notNil ifTrue:[ |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2160 |
lastSearchDirection := #backward. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2161 |
self |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2162 |
searchBwd:lastSearchPattern |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2163 |
ignoreCase:ign |
248 | 2164 |
] |
1326 | 2165 |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2166 |
"Modified: / 3.5.1999 / 15:00:28 / cg" |
248 | 2167 |
! |
2168 |
||
2169 |
searchBwd:pattern |
|
2170 |
"do a backward search" |
|
2171 |
||
2172 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
1326 | 2173 |
lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2174 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2175 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2176 |
"Modified: / 6.3.1999 / 23:46:40 / cg" |
248 | 2177 |
! |
2178 |
||
2179 |
searchBwd:pattern ifAbsent:aBlock |
|
2180 |
"do a backward search" |
|
2181 |
||
2182 |
|startLine startCol| |
|
2183 |
||
2184 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2185 |
startLine := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2186 |
startCol := selectionStartCol |
248 | 2187 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2188 |
startLine := 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2189 |
startCol := 1 |
248 | 2190 |
]. |
1326 | 2191 |
self |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2192 |
searchBackwardFor:pattern startingAtLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2193 |
ifFound:[:line :col | self showMatch:pattern atLine:line col:col] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2194 |
ifAbsent:aBlock |
1326 | 2195 |
|
2196 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
2197 |
! |
|
2198 |
||
2199 |
searchBwd:pattern ignoreCase:ign |
|
2200 |
"do a backward search" |
|
2201 |
||
2202 |
self searchBwd:pattern ignoreCase:ign ifAbsent:[self showNotFound]. |
|
2203 |
lastSearchIgnoredCase := ign. |
|
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2204 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2205 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2206 |
"Created: / 13.9.1997 / 06:18:00 / cg" |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2207 |
"Modified: / 6.3.1999 / 23:46:47 / cg" |
1326 | 2208 |
! |
2209 |
||
2210 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
2211 |
"do a backward search" |
|
2212 |
||
2213 |
|startLine startCol| |
|
2214 |
||
2215 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2216 |
startLine := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2217 |
startCol := selectionStartCol |
1326 | 2218 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2219 |
startLine := 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2220 |
startCol := 1 |
1326 | 2221 |
]. |
2222 |
self |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2223 |
searchBackwardFor:pattern |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2224 |
ignoreCase:ign |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2225 |
startingAtLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2226 |
ifFound:[:line :col | self showMatch:pattern atLine:line col:col] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2227 |
ifAbsent:aBlock |
1326 | 2228 |
|
2229 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
2230 |
"Created: 13.9.1997 / 06:18:41 / cg" |
|
248 | 2231 |
! |
2232 |
||
2233 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2234 |
ifFound:foundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2235 |
ifNotFound:notFoundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2236 |
onError:failBlock |
248 | 2237 |
|
2238 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
|
2239 |
Search for the corresponding character is done forward if its an opening, |
|
2240 |
backwards if its a closing parenthesis. |
|
2241 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
2242 |
If there is a nesting error, performs failBlock." |
|
2243 |
||
2244 |
^ self |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2245 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2246 |
ifFound:foundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2247 |
ifNotFound:notFoundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2248 |
onError:failBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2249 |
ignoring:#( $' $" '$[' '$]' '${' '$)' ) |
248 | 2250 |
|
651
1e7153e21b36
skip character consts in match parent
Claus Gittinger <cg@exept.de>
parents:
649
diff
changeset
|
2251 |
"Modified: 18.5.1996 / 11:05:57 / cg" |
248 | 2252 |
! |
2253 |
||
2254 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2255 |
ifFound:foundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2256 |
ifNotFound:notFoundBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2257 |
onError:failBlock |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2258 |
ignoring:ignoreSet |
248 | 2259 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
2260 |
Search for the corresponding character is done forward if its an opening, |
|
2261 |
backwards if its a closing parenthesis. |
|
2262 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
2263 |
If there is a nesting error, performs failBlock." |
|
2264 |
||
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2265 |
|i direction lineString |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2266 |
parChar charSet closingChar |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2267 |
ignoring |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2268 |
line "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2269 |
col "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2270 |
delta "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2271 |
endCol "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2272 |
runCol "{ Class: SmallInteger }" |
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2273 |
cc prevCC nextCC incSet decSet |
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2274 |
nesting "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
2275 |
maxLine "{ Class: SmallInteger }" |
1454 | 2276 |
ign skip anySet| |
248 | 2277 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2278 |
charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
248 | 2279 |
|
2280 |
parChar := self characterAtLine:startLine col:startCol. |
|
2281 |
i := charSet indexOf:parChar. |
|
2282 |
i == 0 ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2283 |
^ failBlock value "not a parenthesis" |
248 | 2284 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2285 |
direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2286 |
closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
248 | 2287 |
|
2288 |
col := startCol. |
|
2289 |
line := startLine. |
|
2290 |
direction == #fwd ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2291 |
delta := 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2292 |
incSet := #( $( $[ ${ "$<" ). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2293 |
decSet := #( $) $] $} "$>" ). |
248 | 2294 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2295 |
delta := -1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2296 |
incSet := #( $) $] $} "$>" ). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2297 |
decSet := #( $( $[ ${ "$<" ). |
248 | 2298 |
]. |
1454 | 2299 |
anySet := Set new. |
2300 |
anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
2301 |
anySet := (anySet select:[:c | c isCharacter]) asString. |
|
248 | 2302 |
|
2303 |
nesting := 1. |
|
2304 |
ignoring := false. |
|
2305 |
lineString := list at:line. |
|
2306 |
maxLine := list size. |
|
2307 |
||
2308 |
col := col + delta. |
|
2309 |
[nesting ~~ 0] whileTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2310 |
(lineString notNil |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2311 |
and:[lineString includesAny:anySet]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2312 |
direction == #fwd ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2313 |
endCol := lineString size. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2314 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2315 |
endCol := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2316 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2317 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2318 |
col to:endCol by:delta do:[:rCol | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2319 |
runCol := rCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2320 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2321 |
cc := lineString at:runCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2322 |
runCol < lineString size ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2323 |
nextCC := lineString at:runCol+1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2324 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2325 |
nextCC := nil |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2326 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2327 |
runCol > 1 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2328 |
prevCC := lineString at:runCol-1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2329 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2330 |
prevCC := nil |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2331 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2332 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2333 |
ign := skip := false. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2334 |
(cc == $" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2335 |
and:[nextCC == $/ or:[prevCC == $$ ]]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2336 |
"/ do nothing |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2337 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2338 |
skip := true. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2339 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2340 |
ignoreSet do:[:ignore | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2341 |
ignore == cc ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2342 |
ign := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2343 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2344 |
ignore isString ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2345 |
cc == (ignore at:2) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2346 |
runCol > 1 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2347 |
(lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2348 |
skip := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2349 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2350 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2351 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2352 |
cc == (ignore at:1) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2353 |
runCol < lineString size ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2354 |
(lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2355 |
skip := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2356 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2357 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2358 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2359 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2360 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2361 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2362 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2363 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2364 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2365 |
ign ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2366 |
ignoring := ignoring not |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2367 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2368 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2369 |
ignoring ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2370 |
skip ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2371 |
(incSet includes:cc) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2372 |
nesting := nesting + 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2373 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2374 |
(decSet includes:cc) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2375 |
nesting := nesting - 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2376 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2377 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2378 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2379 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2380 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2381 |
nesting == 0 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2382 |
"check if legal" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2383 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2384 |
skip ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2385 |
cc == closingChar ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2386 |
^ failBlock value |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2387 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2388 |
^ foundBlock value:line value:runCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2389 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2390 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2391 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2392 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2393 |
line := line + delta. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2394 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2395 |
^ failBlock value |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2396 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2397 |
lineString := list at:line. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2398 |
direction == #fwd ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2399 |
col := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2400 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2401 |
col := lineString size |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2402 |
] |
248 | 2403 |
]. |
2404 |
^ notFoundBlock value |
|
2405 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2406 |
"Modified: 15.10.1996 / 12:22:30 / cg" |
248 | 2407 |
! |
2408 |
||
2409 |
searchFwd |
|
2410 |
"search forward for pattern or selection" |
|
2411 |
||
1353 | 2412 |
|ign| |
2413 |
||
2414 |
ign := lastSearchIgnoredCase ? false. |
|
2415 |
||
248 | 2416 |
selectStyle == #wordLeft ifTrue:[ |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2417 |
" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2418 |
remove the space from the selection |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2419 |
" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2420 |
selectionStartCol := selectionStartCol + 1. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2421 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2422 |
selectStyle := #word. |
248 | 2423 |
]. |
2424 |
self setSearchPattern. |
|
1326 | 2425 |
lastSearchPattern notNil ifTrue:[ |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2426 |
lastSearchDirection := #forward. |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2427 |
self |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2428 |
searchFwd:lastSearchPattern |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2429 |
ignoreCase:ign |
248 | 2430 |
] |
1326 | 2431 |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2432 |
"Modified: / 3.5.1999 / 15:00:40 / cg" |
248 | 2433 |
! |
2434 |
||
2435 |
searchFwd:pattern |
|
2436 |
"do a forward search" |
|
2437 |
||
2438 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
1326 | 2439 |
lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2440 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2441 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2442 |
"Modified: / 6.3.1999 / 23:46:53 / cg" |
248 | 2443 |
! |
2444 |
||
2445 |
searchFwd:pattern ifAbsent:aBlock |
|
2446 |
"do a forward search" |
|
2447 |
||
2448 |
|startLine startCol| |
|
2449 |
||
2450 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2451 |
startLine := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2452 |
startCol := selectionStartCol |
248 | 2453 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2454 |
startLine := 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2455 |
startCol := 1 |
248 | 2456 |
]. |
1326 | 2457 |
self |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2458 |
searchForwardFor:pattern startingAtLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2459 |
ifFound:[:line :col | self showMatch:pattern atLine:line col:col] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2460 |
ifAbsent:aBlock |
1326 | 2461 |
|
2462 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
2463 |
! |
|
2464 |
||
2465 |
searchFwd:pattern ignoreCase:ign |
|
2466 |
"do a forward search" |
|
2467 |
||
2468 |
self searchFwd:pattern ignoreCase:ign ifAbsent:[self showNotFound]. |
|
2469 |
lastSearchIgnoredCase := ign. |
|
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2470 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2471 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2472 |
"Created: / 13.9.1997 / 06:18:13 / cg" |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2473 |
"Modified: / 6.3.1999 / 23:46:58 / cg" |
1326 | 2474 |
! |
2475 |
||
2476 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
2477 |
"do a forward search" |
|
2478 |
||
2479 |
|startLine startCol| |
|
2480 |
||
2481 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2482 |
startLine := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2483 |
startCol := selectionStartCol |
1326 | 2484 |
] ifFalse:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2485 |
startLine := 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2486 |
startCol := 1 |
1326 | 2487 |
]. |
2488 |
self |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2489 |
searchForwardFor:pattern |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2490 |
ignoreCase:ign |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2491 |
startingAtLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2492 |
ifFound:[:line :col | self showMatch:pattern atLine:line col:col] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2493 |
ifAbsent:aBlock |
1326 | 2494 |
|
2495 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
2496 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
248 | 2497 |
! |
2498 |
||
2499 |
searchPattern |
|
2500 |
"return the last search pattern" |
|
2501 |
||
1326 | 2502 |
^ lastSearchPattern |
248 | 2503 |
! |
2504 |
||
2505 |
setSearchPattern |
|
2506 |
"set the searchpattern from the selection if there is one" |
|
2507 |
||
2508 |
|sel| |
|
2509 |
||
2510 |
sel := self selection. |
|
2511 |
sel notNil ifTrue:[ |
|
1784
e45846a6af7a
remember clickPosition (for single character selection)
Claus Gittinger <cg@exept.de>
parents:
1769
diff
changeset
|
2512 |
self setSearchPattern:sel |
248 | 2513 |
] |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2514 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2515 |
"Modified: / 6.3.1999 / 23:48:04 / cg" |
248 | 2516 |
! |
2517 |
||
2518 |
setSearchPattern:aString |
|
2519 |
"set the searchpattern for future searches" |
|
2520 |
||
2521 |
aString isNil ifTrue:[ |
|
1841 | 2522 |
lastSearchPattern := aString |
248 | 2523 |
] ifFalse:[ |
1841 | 2524 |
lastSearchPattern := aString asString withoutSeparators string |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2525 |
]. |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2526 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
2527 |
"Modified: / 6.3.1999 / 23:47:36 / cg" |
248 | 2528 |
! |
2529 |
||
2530 |
showMatch:pattern atLine:line col:col |
|
2531 |
"after a search, highlight the matched pattern. |
|
2532 |
The code below needs a rewrite to take care of match-characters |
|
2533 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
2534 |
||
2535 |
|realPattern| |
|
2536 |
||
2537 |
realPattern := pattern. |
|
2538 |
(realPattern startsWith:$*) ifTrue:[ |
|
2539 |
realPattern := realPattern copyFrom:2 |
|
2540 |
]. |
|
2541 |
(realPattern endsWith:$*) ifTrue:[ |
|
2542 |
realPattern := realPattern copyWithoutLast:1 |
|
2543 |
]. |
|
2544 |
||
2545 |
self selectFromLine:line col:col |
|
2546 |
toLine:line col:(col + realPattern size - 1). |
|
2547 |
self makeLineVisible:line |
|
2548 |
! |
|
2549 |
||
2550 |
showNotFound |
|
2551 |
"search not found - tell user by beeping and changing |
|
2552 |
cursor for a while (sometimes I work with a headset :-) |
|
2553 |
(used to be: tell user by changing cursor for a while)" |
|
2554 |
||
2555 |
|savedCursor| |
|
2556 |
||
2557 |
savedCursor := cursor. |
|
1028 | 2558 |
[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2559 |
self cursor:(Cursor cross). |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2560 |
self beep. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2561 |
Processor activeProcess millisecondDelay:300. |
1028 | 2562 |
] valueNowOrOnUnwindDo:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2563 |
self cursor:savedCursor |
1028 | 2564 |
] |
2565 |
||
2566 |
"Modified: 20.2.1997 / 12:49:27 / cg" |
|
248 | 2567 |
! ! |
2568 |
||
2569 |
!TextView methodsFor:'selections'! |
|
2570 |
||
458 | 2571 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2572 |
|l t| |
458 | 2573 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2574 |
selectionStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2575 |
expandingTop ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2576 |
l := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2577 |
selectionStartLine := selectionStartLine + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2578 |
(selectionStartLine > clickLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2579 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2580 |
ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2581 |
t := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2582 |
selectionStartLine := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2583 |
selectionEndLine := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2584 |
t := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2585 |
selectionStartCol := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2586 |
selectionEndCol := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2587 |
expandingTop := false |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2588 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2589 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2590 |
l := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2591 |
selectionEndLine := selectionEndLine + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2592 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2593 |
self redrawLine:l. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2594 |
self redrawLine:l+1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2595 |
self makeSelectionVisible. |
458 | 2596 |
]. |
2597 |
||
2598 |
"Created: 1.3.1996 / 23:35:08 / cg" |
|
502 | 2599 |
"Modified: 18.3.1996 / 17:18:15 / cg" |
458 | 2600 |
! |
2601 |
||
2602 |
expandSelectionLeft |
|
502 | 2603 |
|c l t c1 c2| |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2604 |
|
458 | 2605 |
selectionStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2606 |
expandingTop ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2607 |
selectionStartCol == 0 ifTrue:[^ self]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2608 |
l := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2609 |
selectionStartCol := (selectionStartCol - 1) max:1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2610 |
c := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2611 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2612 |
l := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2613 |
selectionEndCol := (selectionEndCol - 1) max:0. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2614 |
c := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2615 |
selectionEndLine == selectionStartLine ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2616 |
selectionEndCol <= selectionStartCol ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2617 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2618 |
selectionEndCol := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2619 |
expandingTop := true. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2620 |
c := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2621 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2622 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2623 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2624 |
c1 := c. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2625 |
c2 := c1 + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2626 |
c1 == 0 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2627 |
c1 := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2628 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2629 |
self redrawLine:l from:c1 to:c2. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2630 |
self makeSelectionVisible. |
458 | 2631 |
]. |
2632 |
||
502 | 2633 |
"Modified: 18.3.1996 / 17:05:46 / cg" |
458 | 2634 |
! |
2635 |
||
2636 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2637 |
|l c t| |
458 | 2638 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2639 |
selectionStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2640 |
expandingTop ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2641 |
l := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2642 |
c := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2643 |
selectionStartCol := selectionStartCol + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2644 |
l == selectionEndLine ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2645 |
c >= selectionEndCol ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2646 |
expandingTop := false. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2647 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2648 |
selectionEndCol := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2649 |
c := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2650 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2651 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2652 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2653 |
l := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2654 |
c := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2655 |
selectionEndCol := selectionEndCol + 1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2656 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2657 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2658 |
self redrawLine:l from:c to:c+1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2659 |
self makeSelectionVisible. |
458 | 2660 |
]. |
2661 |
||
2662 |
"Created: 1.3.1996 / 23:33:17 / cg" |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2663 |
"Modified: 6.3.1996 / 13:54:10 / cg" |
458 | 2664 |
! |
2665 |
||
2666 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2667 |
|l t| |
458 | 2668 |
|
2669 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2670 |
expandingTop ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2671 |
selectionStartLine := (selectionStartLine - 1) max:1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2672 |
l := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2673 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2674 |
selectionEndLine := (selectionEndLine - 1) max:0. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2675 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2676 |
l := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2677 |
(selectionEndLine < clickLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2678 |
or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])]) |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2679 |
ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2680 |
t := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2681 |
selectionStartLine := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2682 |
selectionEndLine := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2683 |
t := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2684 |
selectionStartCol := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2685 |
selectionEndCol := t. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2686 |
l := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2687 |
expandingTop := true |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2688 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2689 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2690 |
self redrawLine:l. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2691 |
self redrawLine:l+1. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2692 |
self makeSelectionVisible. |
458 | 2693 |
]. |
2694 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2695 |
"Modified: 6.3.1996 / 14:12:06 / cg" |
458 | 2696 |
! |
2697 |
||
248 | 2698 |
hasSelection |
2699 |
"return true, if there is a selection" |
|
2700 |
||
2701 |
^ selectionStartLine notNil |
|
2702 |
! |
|
2703 |
||
2704 |
makeSelectionVisible |
|
2705 |
"scroll to make the selection visible" |
|
2706 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2707 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2708 |
|
248 | 2709 |
selectionStartLine notNil ifTrue:[ |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2710 |
expandingTop ~~ false ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2711 |
line := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2712 |
col := selectionStartCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2713 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2714 |
line := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2715 |
col := selectionEndCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2716 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2717 |
self makeLineVisible:line. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2718 |
self makeColVisible:col inLine:line. |
248 | 2719 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2720 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2721 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 2722 |
! |
2723 |
||
2724 |
selectAll |
|
2725 |
"select the whole text" |
|
2726 |
||
2727 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
2728 |
! |
|
2729 |
||
2730 |
selectFromCharacterPosition:pos1 to:pos2 |
|
2731 |
"compute line/col from character positions and select the text" |
|
2732 |
||
2733 |
|line1 col1 line2 col2| |
|
2734 |
||
2735 |
line1 := self lineOfCharacterPosition:pos1. |
|
2736 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
2737 |
line2 := self lineOfCharacterPosition:pos2. |
|
2738 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
2739 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
2740 |
! |
|
2741 |
||
2742 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
2743 |
"select a piece of text and redraw that area" |
|
2744 |
||
2745 |
self unselect. |
|
2746 |
startLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2747 |
"new:" |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2748 |
endLine < startLine ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2749 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2750 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2751 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2752 |
endCol ~~ 0 ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2753 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2754 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2755 |
^ self |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2756 |
]. |
248 | 2757 |
|
2758 |
" old: |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2759 |
endLine < startLine ifTrue:[^ self]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2760 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
248 | 2761 |
" |
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2762 |
selectionStartLine := startLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2763 |
selectionStartCol := startCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2764 |
selectionEndLine := endLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2765 |
selectionEndCol := endCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2766 |
self validateNewSelection. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2767 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2768 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2769 |
self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2770 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2771 |
selectionStartLine to:selectionEndLine do:[:lineNr | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2772 |
self redrawLine:lineNr |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2773 |
] |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2774 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2775 |
selectStyle := nil. |
248 | 2776 |
] |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2777 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2778 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2779 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2780 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2781 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2782 |
v contents:('smalltalk.rc' asFilename contentsOfEntireFile). |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2783 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2784 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2785 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2786 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2787 |
v selectFromLine:2 col:2 toLine:10 col:15 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2788 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2789 |
|
904
597bf5cfe653
care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents:
896
diff
changeset
|
2790 |
"Modified: 2.1.1997 / 13:32:25 / cg" |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2791 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2792 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2793 |
selectFromLine:startLine toLine:endLine |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2794 |
"select a piece of text and redraw that area" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2795 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2796 |
self selectFromLine:startLine col:1 toLine:endLine+1 col:0 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2797 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2798 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2799 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2800 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2801 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2802 |
v contents:('smalltalk.rc' asFilename contentsOfEntireFile). |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2803 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2804 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2805 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2806 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2807 |
v selectFromLine:2 toLine:10 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2808 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2809 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2810 |
"Modified: 29.4.1996 / 12:23:46 / cg" |
248 | 2811 |
! |
2812 |
||
2813 |
selectLine:selectLine |
|
2814 |
"select one line and redraw it" |
|
2815 |
||
2816 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
2817 |
wordStartCol := selectionStartCol. |
|
2818 |
wordEndCol := selectionEndCol. |
|
2819 |
wordStartLine := selectionStartLine. |
|
2820 |
wordEndLine := selectionEndLine. |
|
2821 |
selectStyle := #line |
|
2822 |
! |
|
2823 |
||
2824 |
selectLineAtY:y |
|
2825 |
"select the line at given y-(view-)coordinate" |
|
2826 |
||
2827 |
|selectVisibleLine selectLine| |
|
2828 |
||
2829 |
selectVisibleLine := self visibleLineOfY:y. |
|
2830 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
2831 |
selectLine notNil ifTrue:[ |
|
2832 |
self selectLine:selectLine |
|
2833 |
] |
|
2834 |
! |
|
2835 |
||
2836 |
selectLineWhereCharacterPosition:pos |
|
2837 |
"select the line, where characterPosition pos is living. |
|
2838 |
The argument pos starts at 1 from the start of the text |
|
2839 |
and counts characters (i.e. can be used to convert from |
|
2840 |
character position within a string to line-position in view)." |
|
2841 |
||
2842 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
2843 |
! |
|
2844 |
||
2845 |
selectWordAtLine:line col:col |
|
2846 |
"select the word at given line/col" |
|
2847 |
||
2848 |
self wordAtLine:line col:col do:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2849 |
:beginLine :beginCol :endLine :endCol :style | |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2850 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2851 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2852 |
selectStyle := style |
248 | 2853 |
] |
504 | 2854 |
|
2855 |
"Modified: 18.3.1996 / 17:30:38 / cg" |
|
248 | 2856 |
! |
2857 |
||
2858 |
selectWordAtX:x y:y |
|
2859 |
"select the word at given x/y-(view-)coordinate" |
|
2860 |
||
2861 |
|selectVisibleLine selectLine selectCol| |
|
2862 |
||
2863 |
selectStyle := nil. |
|
2864 |
selectVisibleLine := self visibleLineOfY:y. |
|
2865 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
2866 |
selectLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2867 |
selectCol := self colOfX:x inVisibleLine:selectVisibleLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2868 |
self selectWordAtLine:selectLine col:selectCol |
248 | 2869 |
] |
1661
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
2870 |
|
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
2871 |
"Modified: / 8.9.1998 / 21:22:46 / cg" |
248 | 2872 |
! |
2873 |
||
2874 |
selection |
|
2875 |
"return the selection as a collection of (line-)strings. |
|
2876 |
If the selection ends in a full line, the last entry in the returned |
|
2877 |
collection will be an empty string." |
|
2878 |
||
2879 |
|text sz index last |
|
2880 |
startLine "{ Class: SmallInteger }" |
|
2881 |
endLine "{ Class: SmallInteger }"| |
|
2882 |
||
2883 |
selectionStartLine isNil ifTrue:[^ nil]. |
|
2884 |
startLine := selectionStartLine. |
|
2885 |
endLine := selectionEndLine. |
|
2886 |
||
2887 |
(startLine == endLine) ifTrue:[ |
|
2888 |
"part of a line" |
|
2889 |
^ StringCollection with:(self listAt:startLine |
|
2890 |
from:selectionStartCol |
|
2891 |
to:selectionEndCol) |
|
2892 |
]. |
|
2893 |
sz := endLine - startLine + 1. |
|
2894 |
text := StringCollection new:sz. |
|
2895 |
||
2896 |
"get 1st and last (possibly) partial lines" |
|
2897 |
text at:1 put:(self listAt:startLine from:selectionStartCol). |
|
2898 |
selectionEndCol == 0 ifTrue:[ |
|
2899 |
last := '' |
|
2900 |
] ifFalse:[ |
|
2901 |
last := self listAt:selectionEndLine to:selectionEndCol. |
|
2902 |
]. |
|
2903 |
text at:sz put:last. |
|
2904 |
||
2905 |
"get bulk of text" |
|
2906 |
index := 2. |
|
2907 |
(startLine + 1) to:(endLine - 1) do:[:lineNr | |
|
2908 |
text at:index put:(self listAt:lineNr). |
|
2909 |
index := index + 1 |
|
2910 |
]. |
|
2911 |
^ text |
|
2912 |
! |
|
2913 |
||
2914 |
selectionEndCol |
|
2915 |
^ selectionEndCol |
|
2916 |
! |
|
2917 |
||
2918 |
selectionEndLine |
|
2919 |
^ selectionEndLine |
|
2920 |
! |
|
2921 |
||
2922 |
selectionStartCol |
|
2923 |
^ selectionStartCol |
|
2924 |
! |
|
2925 |
||
2926 |
selectionStartLine |
|
2927 |
^ selectionStartLine |
|
2928 |
! |
|
2929 |
||
2930 |
unselect |
|
2931 |
"unselect - if there was a selection redraw that area" |
|
2932 |
||
2933 |
|startLine endLine startVisLine endVisLine| |
|
2934 |
||
2935 |
selectionStartLine notNil ifTrue:[ |
|
1728
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2936 |
startLine := selectionStartLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2937 |
endLine := selectionEndLine. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2938 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2939 |
self unselectWithoutRedraw. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2940 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2941 |
"/ if the selection is not visible, we are done |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2942 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2943 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2944 |
endLine < firstLineShown ifTrue:[^ self]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2945 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2946 |
startLine < firstLineShown ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2947 |
startVisLine := 1 |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2948 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2949 |
startVisLine := self listLineToVisibleLine:startLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2950 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2951 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2952 |
endVisLine := nLinesShown |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2953 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2954 |
endVisLine := self listLineToVisibleLine:endLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2955 |
]. |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2956 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2957 |
"/ if its only part of a line, just redraw what has to be |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2958 |
|
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2959 |
(startLine == endLine) ifTrue:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2960 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2961 |
] ifFalse:[ |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2962 |
self redrawFromVisibleLine:startVisLine to:endVisLine |
516cb89919f1
moved lastSearchPattern to TextView
Claus Gittinger <cg@exept.de>
parents:
1677
diff
changeset
|
2963 |
]. |
248 | 2964 |
]. |
2965 |
selectStyle := nil |
|
503 | 2966 |
|
715 | 2967 |
"Modified: 29.5.1996 / 14:54:11 / cg" |
248 | 2968 |
! |
2969 |
||
2970 |
unselectWithoutRedraw |
|
2971 |
"forget selection but do not redraw the selection area |
|
2972 |
- can be done when the selected area is redrawn anyway or |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2973 |
known to be invisible (however, redraw knows about that anyway)." |
248 | 2974 |
|
2975 |
selectionStartLine := nil. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2976 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2977 |
"Modified: 29.4.1996 / 12:33:28 / cg" |
248 | 2978 |
! |
2979 |
||
2980 |
validateNewSelection |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2981 |
"make certain that the selection is valid. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2982 |
This is a dummy here, but subclasses (like single-line editFields) |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2983 |
may redefine it to limit the selection to a single line, or whatever." |
248 | 2984 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2985 |
^ self |
504 | 2986 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
2987 |
"Modified: 29.4.1996 / 12:32:08 / cg" |
248 | 2988 |
! ! |
2989 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2990 |
!TextView class methodsFor:'documentation'! |
248 | 2991 |
|
2992 |
version |
|
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
2993 |
^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.149 2000-01-31 18:58:49 cg Exp $' |
248 | 2994 |
! ! |