author | sr |
Tue, 11 Jun 2019 11:47:16 +0200 | |
changeset 6604 | 89a0c07bbba9 |
parent 6553 | 1b15add12d92 |
child 6618 | 25d16c26e044 |
permissions | -rw-r--r-- |
6475 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
5791 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2191 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5247 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
ListView subclass:#TextView |
5902 | 19 |
instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine |
20 |
selectionEndCol clickPos clickStartLine clickStartCol clickLine |
|
21 |
clickCol clickCount expandingTop wordStartCol wordStartLine |
|
22 |
wordEndCol wordEndLine selectionFgColor selectionBgColor |
|
23 |
selectStyle directoryForFileDialog defaultFileNameForFileDialog |
|
24 |
externalEncoding contentsWasSaved searchAction lastSearchPattern |
|
25 |
lastSearchWasMatch lastSearchIgnoredCase lastSearchDirection |
|
26 |
lastSearchWasVariableSearch parenthesisSpecification dropSource |
|
27 |
dragIsActive saveAction st80SelectMode searchBarActionBlock' |
|
6324 | 28 |
classVariableNames:'DefaultAlternativeSelectionBackgroundColor |
5902 | 29 |
DefaultAlternativeSelectionForegroundColor |
6324 | 30 |
DefaultParenthesisSpecification DefaultSelectionBackgroundColor |
31 |
DefaultSelectionForegroundColor DefaultViewBackground |
|
32 |
LastSearchIgnoredCase LastSearchPatterns LastSearchReplacedString |
|
33 |
LastSearchWasMatch LastSearchWasMatchWithRegex |
|
34 |
LastSearchWasReplace LastSearchWasWrapAtEndOfText MatchDelayTime |
|
35 |
NumRememberedSearchPatterns WordSelectCatchesBlanks' |
|
5902 | 36 |
poolDictionaries:'' |
37 |
category:'Views-Text' |
|
0 | 38 |
! |
39 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
40 |
!TextView class methodsFor:'documentation'! |
0 | 41 |
|
38 | 42 |
copyright |
43 |
" |
|
44 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
5791 | 45 |
All Rights Reserved |
38 | 46 |
|
47 |
This software is furnished under a license and may be used |
|
48 |
only in accordance with the terms of that license and with the |
|
49 |
inclusion of the above copyright notice. This software may not |
|
50 |
be provided or otherwise made available to, or used by, any |
|
51 |
other person. No title to or ownership of the software is |
|
52 |
hereby transferred. |
|
53 |
" |
|
54 |
! |
|
55 |
||
22 | 56 |
documentation |
0 | 57 |
" |
120 | 58 |
a view for readOnly text - this class adds selections to a simple list. |
38 | 59 |
The text is not editable and there is no cursor. |
120 | 60 |
Use TextViews for readonly text, EditTextView for editable text. |
0 | 61 |
|
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
|
62 |
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
|
63 |
|
586 | 64 |
[Instance variables:] |
0 | 65 |
|
120 | 66 |
selectionStartLine <Number> the line of the selection start (or nil) |
67 |
selectionStartCol <Number> the col of the selection start |
|
68 |
selectionEndLine <Number> the line of the selection end |
|
69 |
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
|
70 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
71 |
clickStartLine <Number> temporary - remember where select operation started |
120 | 72 |
clickStartCol <Number> temporary |
73 |
clickLine <Number> temporary |
|
74 |
clickCol <Number> temporary |
|
75 |
clickCount <Number> temporary |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
76 |
expandingTop <Boolean> temporary - for expandSelection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
77 |
|
120 | 78 |
selectionFgColor <Color> color used to draw selections |
79 |
selectionBgColor <Color> color used to draw selections |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
80 |
|
120 | 81 |
selectStyle <Symbol> how words are selected |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
82 |
|
120 | 83 |
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
|
84 |
|
120 | 85 |
contentsWasSaved <Boolean> set to true, whenever saved in a file |
77 | 86 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
87 |
externalEncoding <Symbol|nil> external encoding, used when text is saved to |
5791 | 88 |
a file. Usually something like |
89 |
#jis7, #euc, #sjis etc. |
|
90 |
(currently only passed down from the |
|
91 |
fileBrowser) |
|
2588 | 92 |
|
93 |
dropSource <DropSource> drag operation descriptor or nil (dragging disabled) |
|
4500 | 94 |
dragIsActive <Boolean> true, drag operation is activated |
95 |
||
96 |
searchAction <Block> an autosearch action; typically set by the browser. |
|
5791 | 97 |
Will be used as default when searchFwd/searchBwd is |
98 |
pressed. If the searchPattern is changed, no autosearch |
|
99 |
action will be executed. |
|
3981 | 100 |
|
101 |
searchBarActionBlock <Block> search action block for embedded search |
|
5791 | 102 |
panel. Used as second chance for searchFwd/bwd |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
103 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
104 |
[class variables:] |
5791 | 105 |
ST80Selections <Boolean> enables ST80 style doubleclick behavior |
106 |
(right after opening parenthesis, right before |
|
107 |
closing parenthesis, at begin of a line |
|
108 |
at begin of text) |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
109 |
|
586 | 110 |
[StyleSheet parameters:] |
77 | 111 |
|
2600 | 112 |
textView.background defaults to viewBackground |
113 |
textView.ViewFont defaults to textFont |
|
114 |
||
115 |
text.st80Selections st80 behavior (click on char after parent or quote) |
|
116 |
||
117 |
text.selectionForegroundColor defaults to textBackgroundColor |
|
118 |
text.selectionBackgroundColor defaults to textForegroundColor |
|
119 |
||
120 |
text.alternativeSelectionForegroundColor pasted text (i.e. paste will not replace) |
|
5791 | 121 |
defaults to selectionForegroundColor |
2600 | 122 |
text.alternativeSelectionBackgroundColor pasted text (i.e. paste will not replace) |
5791 | 123 |
defaults to selectionBackgroundColor |
586 | 124 |
[author:] |
5791 | 125 |
Claus Gittinger |
586 | 126 |
|
127 |
[see also:] |
|
5791 | 128 |
EditTextView CodeView Workspace |
0 | 129 |
" |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
130 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
131 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
132 |
examples |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
133 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
134 |
although textViews (and instances of subclasses) are mostly used |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
135 |
as components (in the fileBrowser, the browser, the launcher etc.), |
5842 | 136 |
they may also be opened as a textEditor. Notice, that usually, |
137 |
instances of one of my subclasses (EditTextView, TextCollector, Workspace) |
|
138 |
are actually used. |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
139 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
140 |
open a (readonly) textView on some information text: |
5791 | 141 |
[exBegin] |
142 |
TextView |
|
6135 | 143 |
openWith:'read this |
144 |
and that, |
|
145 |
and also this' |
|
5791 | 146 |
title:'demonstration' |
147 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
148 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
149 |
the same, but open it modal: |
5791 | 150 |
[exBegin] |
151 |
TextView |
|
152 |
openModalWith:'read this first' |
|
153 |
title:'demonstration' |
|
154 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
155 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
156 |
|
1016 | 157 |
open it modal (but editable) on some text: |
158 |
(must accept before closing) |
|
159 |
This is somewhat kludgy - when closed, the view has already |
|
160 |
nilled its link to the model. Therefore, the accept must be |
|
161 |
done 'manually' below. |
|
162 |
However, usually an applicationModel is installed as the |
|
163 |
editor-topViews application. This would get a closeRequest, |
|
164 |
where it could handle things. |
|
5791 | 165 |
[exBegin] |
166 |
|m textView| |
|
167 |
||
168 |
m := 'read this first' asValue. |
|
169 |
textView := EditTextView openModalOnModel:m. |
|
170 |
textView modified ifTrue:[ |
|
171 |
(self confirm:'text was not accepted - do it now ?') |
|
172 |
ifTrue:[ |
|
173 |
m value:textView contents |
|
174 |
] |
|
175 |
]. |
|
176 |
||
177 |
Transcript showCR:m value. |
|
178 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
179 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
180 |
|
1016 | 181 |
open a textEditor on some file: |
5791 | 182 |
[exBegin] |
183 |
EditTextView openOn:'Makefile' |
|
184 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
185 |
|
5841 | 186 |
|
187 |
configuring the TextView to NOT expand tabs and scan for special lines |
|
188 |
(to avoid reading all lines, when usig a virtualArray) |
|
189 |
[exBegin] |
|
190 |
|a m| |
|
5845 | 191 |
|
192 |
a := VirtualArray new |
|
5841 | 193 |
setSize:100000000; |
5845 | 194 |
generator:[:lNr | Transcript show:'called for '; showCR:lNr. |
5841 | 195 |
'this is line: ',lNr printString ]. |
5845 | 196 |
m := a asValue. |
197 |
(ScrollableView forView:TextView new) |
|
198 |
expandTabsWhenUpdating:false; |
|
5841 | 199 |
checkLineEndConventionWhenUpdating:false; |
5845 | 200 |
model:m; |
201 |
open; inspect. |
|
5841 | 202 |
[exEnd] |
203 |
||
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
204 |
" |
0 | 205 |
! ! |
206 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
207 |
!TextView class methodsFor:'instance creation'! |
119 | 208 |
|
209 |
on:aModel aspect:aspect change:change menu:menu initialSelection:initial |
|
210 |
"for ST-80 compatibility" |
|
211 |
||
4500 | 212 |
^ (self new) |
5791 | 213 |
on:aModel |
214 |
aspect:aspect |
|
215 |
list:aspect |
|
216 |
change:change |
|
217 |
menu:menu |
|
218 |
initialSelection:initial |
|
3280 | 219 |
! |
220 |
||
221 |
with:someText |
|
4500 | 222 |
^ (self new) |
5791 | 223 |
contents:someText |
119 | 224 |
! ! |
225 |
||
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
226 |
!TextView class methodsFor:'class initialization'! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
227 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
228 |
initialize |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
229 |
DefaultParenthesisSpecification isNil ifTrue:[ |
5791 | 230 |
DefaultParenthesisSpecification := IdentityDictionary new. |
231 |
DefaultParenthesisSpecification at:#open put:#( $( $[ ${ "$> $<") . |
|
232 |
DefaultParenthesisSpecification at:#close put:#( $) $] $} "$> $<"). |
|
233 |
DefaultParenthesisSpecification at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
|
234 |
DefaultParenthesisSpecification at:#eolComment put:'"/'. "/ sigh - must be 2 characters |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
235 |
]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
236 |
! ! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
237 |
|
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
238 |
!TextView class methodsFor:'defaults'! |
38 | 239 |
|
896 | 240 |
defaultIcon |
1195 | 241 |
"return the default icon if started as a topView" |
242 |
||
3496 | 243 |
<resource: #programImage> |
1195 | 244 |
<resource: #style (#ICON #ICON_FILE)> |
245 |
||
246 |
|nm i| |
|
1143 | 247 |
|
1146 | 248 |
i := self classResources at:'ICON' default:nil. |
1143 | 249 |
i isNil ifTrue:[ |
5791 | 250 |
nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'. |
251 |
i := Smalltalk imageFromFileNamed:nm forClass:self. |
|
1195 | 252 |
]. |
253 |
i notNil ifTrue:[ |
|
5791 | 254 |
i := i onDevice:Display |
1143 | 255 |
]. |
256 |
^ i |
|
257 |
||
3496 | 258 |
"Modified: / 17-09-2007 / 11:36:29 / cg" |
896 | 259 |
! |
260 |
||
910
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
261 |
defaultMenuMessage |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
262 |
"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
|
263 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
264 |
^ #editMenu |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
265 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
266 |
"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
|
267 |
! |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
268 |
|
4254
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
269 |
defaultParenthesisSpecification |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
270 |
^ DefaultParenthesisSpecification |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
271 |
|
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
272 |
"Created: / 14-06-2011 / 14:00:59 / cg" |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
273 |
! |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
274 |
|
2306 | 275 |
defaultSelectionBackgroundColor |
276 |
"return the default selection background color" |
|
277 |
||
278 |
^DefaultSelectionBackgroundColor |
|
279 |
! |
|
280 |
||
281 |
defaultSelectionForegroundColor |
|
282 |
"return the default selection foreground color" |
|
283 |
||
284 |
^DefaultSelectionForegroundColor |
|
285 |
! |
|
286 |
||
1477
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
287 |
defaultViewBackgroundColor |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
288 |
"return the default view background" |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
289 |
|
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
290 |
^DefaultViewBackground |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
291 |
! |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
292 |
|
3226 | 293 |
lastSearchIgnoredCase |
294 |
^ LastSearchIgnoredCase |
|
295 |
! |
|
296 |
||
3577 | 297 |
lastSearchWasMatch |
298 |
^ LastSearchWasMatch |
|
299 |
! |
|
300 |
||
1729 | 301 |
st80SelectMode |
3308 | 302 |
^ UserPreferences current st80SelectMode |
303 |
||
304 |
"Modified: / 03-07-2006 / 16:26:44 / cg" |
|
1729 | 305 |
! |
306 |
||
307 |
st80SelectMode:aBoolean |
|
3308 | 308 |
UserPreferences current st80SelectMode:aBoolean |
309 |
||
310 |
"Created: / 07-01-1999 / 13:35:24 / cg" |
|
311 |
"Modified: / 03-07-2006 / 16:27:01 / cg" |
|
1729 | 312 |
! |
313 |
||
59 | 314 |
updateStyleCache |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
315 |
"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
|
316 |
|
1353 | 317 |
<resource: #style (#'textView.background' |
5791 | 318 |
#'text.selectionForegroundColor' |
319 |
#'text.selectionBackgroundColor' |
|
320 |
#'text.alternativeSelectionForegroundColor' |
|
321 |
#'text.alternativeSelectionBackgroundColor' |
|
322 |
#'textView.font' |
|
323 |
#'text.wordSelectCatchesBlanks' |
|
324 |
#'text.st80Selections')> |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
325 |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
326 |
DefaultViewBackground := StyleSheet colorAt:'textView.background' default:Color white. |
1380 | 327 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'text.selectionForegroundColor'. |
328 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'text.selectionBackgroundColor'. |
|
2630
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
329 |
"/ DefaultAlternativeSelectionForegroundColor := StyleSheet colorAt:'text.alternativeSelectionForegroundColor' default:DefaultSelectionForegroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
330 |
"/ DefaultAlternativeSelectionBackgroundColor := StyleSheet colorAt:'text.alternativeSelectionBackgroundColor' default:DefaultSelectionBackgroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
331 |
DefaultAlternativeSelectionForegroundColor := DefaultSelectionForegroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
332 |
DefaultAlternativeSelectionBackgroundColor := DefaultSelectionBackgroundColor. |
1353 | 333 |
DefaultFont := StyleSheet fontAt:'textView.font'. |
504 | 334 |
MatchDelayTime := 0.6. |
1380 | 335 |
WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false. |
3308 | 336 |
|
337 |
"Modified: / 03-07-2006 / 16:29:42 / cg" |
|
0 | 338 |
! ! |
339 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
340 |
!TextView class methodsFor:'help specs'! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
341 |
|
6256 | 342 |
helpSpec |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
343 |
"This resource specification was automatically generated |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
344 |
by the UIHelpTool of ST/X." |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
345 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
346 |
"Do not manually edit this!! If it is corrupted, |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
347 |
the UIHelpTool may not be able to read the specification." |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
348 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
349 |
" |
4500 | 350 |
UIHelpTool openOnClass:TextView |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
351 |
" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
352 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
353 |
<resource: #help> |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
354 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
355 |
^ Dictionary new addPairsFrom:#( |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
356 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
357 |
#matchSearch |
5741 | 358 |
'Search for a pattern (GLOB) as opposed to a direct string search' |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
359 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
360 |
#searchCaseSensitive |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
361 |
'Care for case differences' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
362 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
363 |
#searchFullWord |
5741 | 364 |
'Search only for full words (ignore occurrences in substring)' |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
365 |
|
5078 | 366 |
#searchAtBeginOfLineOnly |
5741 | 367 |
'Search only for the string at the beginning of a line' |
5078 | 368 |
|
6428 | 369 |
#searchAtEndOfLineOnly |
370 |
'Search only for the string at the end of a line' |
|
371 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
372 |
#searchPattern |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
373 |
'String or match-pattern to be searched' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
374 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
375 |
#searchVariable |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
376 |
'Search only for that variable name (ignore occurrences in other contexts)' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
377 |
|
4485 | 378 |
#replaceText |
5741 | 379 |
'If checked, matching text is replaced by this' |
4485 | 380 |
|
381 |
#selectLines |
|
382 |
'If checked, lines containing the matched string are selected.' |
|
383 |
||
5556 | 384 |
#replacePreserveCase |
5727 | 385 |
'Preserve the title case of replaced text' |
5556 | 386 |
|
387 |
#replaceAll |
|
388 |
'Search and replace all occurrences of the searched string' |
|
389 |
||
390 |
#searchWithWrap |
|
5726 | 391 |
'Wrap around at the end of the text, and continue the search from the top' |
5556 | 392 |
|
393 |
#matchWithRegex |
|
5741 | 394 |
'Use regex pattern for search (as opposed to GLOB pattern)' |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
395 |
) |
6428 | 396 |
|
397 |
"Modified: / 13-09-2018 / 10:03:15 / Claus Gittinger" |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
398 |
! ! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
399 |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
400 |
!TextView class methodsFor:'interface specs'! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
401 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
402 |
searchDialogSpec |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
403 |
"This resource specification was automatically generated |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
404 |
by the UIPainter of ST/X." |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
405 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
406 |
"Do not manually edit this!! If it is corrupted, |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
407 |
the UIPainter may not be able to read the specification." |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
408 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
409 |
" |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
410 |
UIPainter new openOnClass:TextView andSelector:#searchDialogSpec |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
411 |
" |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
412 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
413 |
<resource: #canvas> |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
414 |
|
5918 | 415 |
^ |
4767 | 416 |
#(FullSpec |
417 |
name: searchDialogSpec |
|
6428 | 418 |
uuid: '218d9e60-b72e-11e8-aeef-b8f6b1108e05' |
5918 | 419 |
window: |
4767 | 420 |
(WindowSpec |
5791 | 421 |
label: 'String search' |
422 |
name: 'String search' |
|
6378 | 423 |
uuid: 'c93c164e-8698-11e8-80e0-b8f6b1108e05' |
5791 | 424 |
min: (Point 10 10) |
425 |
max: (Point 1280 1024) |
|
6428 | 426 |
bounds: (Rectangle 0 0 551 407) |
4767 | 427 |
) |
5918 | 428 |
component: |
4767 | 429 |
(SpecCollection |
5791 | 430 |
collection: ( |
431 |
(LabelSpec |
|
432 |
label: 'SearchPattern:' |
|
433 |
name: 'label' |
|
434 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
6378 | 435 |
uuid: 'c93c1a7c-8698-11e8-80e0-b8f6b1108e05' |
5791 | 436 |
level: 0 |
437 |
translateLabel: true |
|
438 |
adjust: left |
|
439 |
) |
|
440 |
(ComboBoxSpec |
|
441 |
name: 'patternComboBox' |
|
442 |
layout: (LayoutFrame 2 0.0 26 0 -2 1.0 48 0) |
|
443 |
activeHelpKey: searchPattern |
|
6378 | 444 |
uuid: 'c93c1d38-8698-11e8-80e0-b8f6b1108e05' |
5791 | 445 |
tabable: true |
446 |
model: searchPattern |
|
447 |
immediateAccept: false |
|
448 |
acceptOnLeave: true |
|
449 |
acceptOnReturn: true |
|
450 |
acceptOnTab: true |
|
451 |
acceptOnLostFocus: true |
|
452 |
acceptOnPointerLeave: false |
|
453 |
autoSelectInitialText: true |
|
454 |
comboList: patternList |
|
455 |
) |
|
456 |
(VerticalPanelViewSpec |
|
457 |
name: 'VerticalPanel1' |
|
458 |
layout: (LayoutFrame 0 0.0 52 0 0 1.0 -32 1) |
|
6378 | 459 |
uuid: 'c93c21e8-8698-11e8-80e0-b8f6b1108e05' |
5791 | 460 |
horizontalLayout: fit |
461 |
verticalLayout: top |
|
5918 | 462 |
component: |
5791 | 463 |
(SpecCollection |
464 |
collection: ( |
|
465 |
(CheckBoxSpec |
|
466 |
label: 'Case Sensitive' |
|
467 |
name: 'ignoreCaseCheckBox' |
|
468 |
activeHelpKey: searchCaseSensitive |
|
6378 | 469 |
uuid: 'c93c242c-8698-11e8-80e0-b8f6b1108e05' |
5791 | 470 |
level: 0 |
471 |
tabable: true |
|
472 |
model: caseSensitive |
|
473 |
translateLabel: true |
|
6428 | 474 |
extent: (Point 551 24) |
5791 | 475 |
) |
476 |
(ViewSpec |
|
477 |
name: 'MatchBox' |
|
6378 | 478 |
uuid: 'c93c2620-8698-11e8-80e0-b8f6b1108e05' |
5918 | 479 |
component: |
5791 | 480 |
(SpecCollection |
481 |
collection: ( |
|
482 |
(CheckBoxSpec |
|
483 |
label: 'Match (forward only)' |
|
484 |
name: 'matchCheckBox' |
|
485 |
layout: (LayoutFrame 0 0 0 0 260 0 0 1) |
|
486 |
activeHelpKey: matchSearch |
|
6378 | 487 |
uuid: 'c93c272e-8698-11e8-80e0-b8f6b1108e05' |
5791 | 488 |
level: 0 |
489 |
tabable: true |
|
490 |
model: match |
|
491 |
translateLabel: true |
|
492 |
) |
|
493 |
(CheckBoxSpec |
|
494 |
label: 'Regex Match' |
|
495 |
name: 'CheckBox6' |
|
496 |
layout: (LayoutFrame -170 1 0 0 0 1 22 0) |
|
497 |
activeHelpKey: matchWithRegex |
|
6378 | 498 |
uuid: 'c93c285a-8698-11e8-80e0-b8f6b1108e05' |
5791 | 499 |
enableChannel: matchWithRegexVisible |
500 |
model: matchWithRegex |
|
501 |
translateLabel: true |
|
502 |
) |
|
503 |
) |
|
5918 | 504 |
|
5791 | 505 |
) |
6428 | 506 |
extent: (Point 551 24) |
5791 | 507 |
) |
508 |
(CheckBoxSpec |
|
509 |
label: 'Search Full Words' |
|
510 |
name: 'CheckBox2' |
|
511 |
activeHelpKey: searchFullWord |
|
6378 | 512 |
uuid: 'c93c29ae-8698-11e8-80e0-b8f6b1108e05' |
5791 | 513 |
level: 0 |
514 |
enableChannel: searchFullWordEnabled |
|
515 |
tabable: true |
|
516 |
model: searchFullWord |
|
517 |
translateLabel: true |
|
6428 | 518 |
extent: (Point 551 24) |
5791 | 519 |
) |
520 |
(CheckBoxSpec |
|
521 |
label: 'At Begin of Line Only' |
|
522 |
name: 'CheckBox5' |
|
523 |
activeHelpKey: searchAtBeginOfLineOnly |
|
6378 | 524 |
uuid: 'c93c2ac6-8698-11e8-80e0-b8f6b1108e05' |
5791 | 525 |
level: 0 |
526 |
tabable: true |
|
527 |
model: searchAtBeginOfLineOnly |
|
528 |
translateLabel: true |
|
6428 | 529 |
extent: (Point 551 24) |
530 |
) |
|
531 |
(CheckBoxSpec |
|
532 |
label: 'At End of Line Only' |
|
533 |
name: 'CheckBox7' |
|
534 |
activeHelpKey: searchAtEndOfLineOnly |
|
535 |
uuid: 'c93c2ac6-8698-11e8-80e0-b8f6b1108e05' |
|
536 |
level: 0 |
|
537 |
enableChannel: atEndOfLineOnlyEnabled |
|
538 |
tabable: true |
|
539 |
model: searchAtEndOfLineOnly |
|
540 |
translateLabel: true |
|
541 |
extent: (Point 551 24) |
|
5791 | 542 |
) |
543 |
(CheckBoxSpec |
|
544 |
label: 'Variable Only' |
|
545 |
name: 'CheckBox1' |
|
546 |
activeHelpKey: searchVariable |
|
6378 | 547 |
uuid: 'c93c2bde-8698-11e8-80e0-b8f6b1108e05' |
5791 | 548 |
level: 0 |
549 |
visibilityChannel: searchVariableVisible |
|
550 |
enableChannel: searchVariableEnabled |
|
551 |
tabable: true |
|
552 |
model: searchVariable |
|
553 |
translateLabel: true |
|
554 |
labelChannel: stringWithVariableUnderCursorHolder |
|
6428 | 555 |
extent: (Point 551 24) |
5791 | 556 |
) |
557 |
(CheckBoxSpec |
|
558 |
label: 'Select Lines' |
|
559 |
name: 'CheckBox3' |
|
560 |
activeHelpKey: selectLines |
|
6378 | 561 |
uuid: 'c93c2d0a-8698-11e8-80e0-b8f6b1108e05' |
5791 | 562 |
level: 0 |
563 |
initiallyInvisible: true |
|
564 |
tabable: true |
|
565 |
model: selectLinesHolder |
|
566 |
translateLabel: true |
|
567 |
extent: (Point 429 24) |
|
568 |
) |
|
569 |
(CheckBoxSpec |
|
570 |
label: 'Wrap at End of Text (forward only)' |
|
6428 | 571 |
name: 'CheckBox8' |
5791 | 572 |
activeHelpKey: searchWithWrap |
6378 | 573 |
uuid: 'c93c2e2c-8698-11e8-80e0-b8f6b1108e05' |
5791 | 574 |
level: 0 |
575 |
tabable: true |
|
576 |
model: wrapAtEndOfTextHolder |
|
577 |
translateLabel: true |
|
6428 | 578 |
extent: (Point 551 24) |
5791 | 579 |
) |
580 |
(ViewSpec |
|
581 |
name: 'Box1' |
|
6378 | 582 |
uuid: 'c93c2f44-8698-11e8-80e0-b8f6b1108e05' |
6428 | 583 |
extent: (Point 551 10) |
5791 | 584 |
) |
585 |
(HorizontalPanelViewSpec |
|
586 |
name: 'HorizontalPanel1' |
|
6378 | 587 |
uuid: 'c93c3016-8698-11e8-80e0-b8f6b1108e05' |
5791 | 588 |
horizontalLayout: leftFit |
589 |
verticalLayout: fit |
|
590 |
ignoreInvisibleComponents: false |
|
591 |
elementsChangeSize: true |
|
5918 | 592 |
component: |
5791 | 593 |
(SpecCollection |
594 |
collection: ( |
|
595 |
(CheckBoxSpec |
|
596 |
label: 'Replace By:' |
|
597 |
name: 'CheckBox4' |
|
598 |
activeHelpKey: replaceText |
|
6378 | 599 |
uuid: 'c93c3192-8698-11e8-80e0-b8f6b1108e05' |
5791 | 600 |
level: 0 |
601 |
enableChannel: replaceEnabled |
|
602 |
tabable: true |
|
603 |
model: replaceBoolean |
|
604 |
translateLabel: true |
|
605 |
resizeForLabel: true |
|
606 |
useDefaultExtent: true |
|
607 |
) |
|
608 |
(InputFieldSpec |
|
609 |
name: 'ReplaceEntryField' |
|
610 |
activeHelpKey: replaceText |
|
6378 | 611 |
uuid: 'c93c32f0-8698-11e8-80e0-b8f6b1108e05' |
5791 | 612 |
visibilityChannel: replaceBoolean |
613 |
enableChannel: replaceBoolean |
|
614 |
model: replaceTextHolder |
|
615 |
acceptOnReturn: true |
|
616 |
acceptOnTab: true |
|
617 |
acceptOnPointerLeave: true |
|
6428 | 618 |
extent: (Point 416 24) |
5791 | 619 |
) |
620 |
) |
|
5918 | 621 |
|
5791 | 622 |
) |
6428 | 623 |
extent: (Point 551 24) |
5791 | 624 |
) |
625 |
(CheckBoxSpec |
|
626 |
label: ' Replace All (to End of Text)' |
|
6428 | 627 |
name: 'CheckBox9' |
5791 | 628 |
activeHelpKey: replaceAll |
6378 | 629 |
uuid: 'c93c353e-8698-11e8-80e0-b8f6b1108e05' |
5791 | 630 |
level: 0 |
631 |
enableChannel: replaceBoolean |
|
632 |
tabable: true |
|
633 |
model: replaceAllBoolean |
|
634 |
translateLabel: true |
|
6428 | 635 |
extent: (Point 551 24) |
5791 | 636 |
) |
637 |
(CheckBoxSpec |
|
638 |
label: ' Preserve Case' |
|
6428 | 639 |
name: 'CheckBox10' |
5791 | 640 |
activeHelpKey: replacePreserveCase |
6378 | 641 |
uuid: 'c93c366a-8698-11e8-80e0-b8f6b1108e05' |
5791 | 642 |
level: 0 |
643 |
enableChannel: replaceBoolean |
|
644 |
tabable: true |
|
645 |
model: replacePreserveCaseBoolean |
|
646 |
translateLabel: true |
|
6428 | 647 |
extent: (Point 551 24) |
5791 | 648 |
) |
649 |
) |
|
5918 | 650 |
|
5791 | 651 |
) |
652 |
) |
|
653 |
(HorizontalPanelViewSpec |
|
654 |
name: 'horizontalPanelView' |
|
6428 | 655 |
layout: (LayoutFrame 20 0.0 -38 1.0 -30 1.0 -2 1.0) |
6378 | 656 |
uuid: 'c93c3908-8698-11e8-80e0-b8f6b1108e05' |
5791 | 657 |
level: 0 |
6378 | 658 |
horizontalLayout: leftSpace |
5791 | 659 |
verticalLayout: center |
660 |
horizontalSpace: 3 |
|
661 |
verticalSpace: 3 |
|
662 |
ignoreInvisibleComponents: true |
|
663 |
reverseOrderIfOKAtLeft: true |
|
5918 | 664 |
component: |
5791 | 665 |
(SpecCollection |
666 |
collection: ( |
|
667 |
(ActionButtonSpec |
|
668 |
label: 'Cancel' |
|
669 |
name: 'cancelButton' |
|
6378 | 670 |
uuid: 'c93c3b74-8698-11e8-80e0-b8f6b1108e05' |
5791 | 671 |
level: 2 |
672 |
translateLabel: true |
|
673 |
tabable: true |
|
674 |
model: cancel |
|
6428 | 675 |
extent: (Point 85 36) |
5791 | 676 |
) |
6378 | 677 |
(ViewSpec |
678 |
name: 'Box2' |
|
679 |
uuid: 'db91ecb4-8699-11e8-80e0-b8f6b1108e05' |
|
680 |
extent: (Point 80 30) |
|
5791 | 681 |
) |
6378 | 682 |
(HorizontalPanelViewSpec |
683 |
name: 'HorizontalPanel2' |
|
684 |
uuid: 'c93c3908-8698-11e8-80e0-b8f6b1108e05' |
|
685 |
level: 0 |
|
686 |
horizontalLayout: fitSpace |
|
687 |
verticalLayout: center |
|
688 |
horizontalSpace: 3 |
|
689 |
verticalSpace: 3 |
|
690 |
ignoreInvisibleComponents: true |
|
691 |
component: |
|
692 |
(SpecCollection |
|
693 |
collection: ( |
|
694 |
(ActionButtonSpec |
|
695 |
label: 'Prev' |
|
696 |
name: 'prevButton' |
|
697 |
uuid: 'c93c3e6c-8698-11e8-80e0-b8f6b1108e05' |
|
698 |
level: 2 |
|
699 |
translateLabel: true |
|
700 |
tabable: true |
|
701 |
model: prevAction |
|
702 |
useDefaultExtent: true |
|
703 |
) |
|
704 |
(ActionButtonSpec |
|
705 |
label: 'Next' |
|
706 |
name: 'nextButton' |
|
707 |
uuid: 'c93c3ffc-8698-11e8-80e0-b8f6b1108e05' |
|
708 |
level: 2 |
|
709 |
borderWidth: 1 |
|
710 |
translateLabel: true |
|
711 |
tabable: true |
|
712 |
model: nextAction |
|
713 |
isDefault: true |
|
6428 | 714 |
defaultable: true |
715 |
extent: (Point 101 36) |
|
6378 | 716 |
) |
717 |
(ActionButtonSpec |
|
718 |
label: 'Last' |
|
719 |
name: 'lastButton' |
|
720 |
uuid: 'db91f074-8699-11e8-80e0-b8f6b1108e05' |
|
721 |
level: 2 |
|
722 |
borderWidth: 1 |
|
723 |
translateLabel: true |
|
724 |
tabable: true |
|
725 |
model: lastAction |
|
726 |
useDefaultExtent: true |
|
727 |
) |
|
728 |
) |
|
729 |
||
730 |
) |
|
6428 | 731 |
extent: (Point 320 36) |
5791 | 732 |
) |
733 |
) |
|
5918 | 734 |
|
5791 | 735 |
) |
736 |
keepSpaceForOSXResizeHandleH: true |
|
737 |
) |
|
738 |
) |
|
5918 | 739 |
|
4767 | 740 |
) |
741 |
) |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
742 |
! ! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
743 |
|
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
744 |
!TextView class methodsFor:'startup'! |
121 | 745 |
|
248 | 746 |
open |
747 |
"start an empty TextView" |
|
748 |
||
749 |
^ self openWith:nil |
|
0 | 750 |
! |
751 |
||
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
752 |
openModalOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
753 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
754 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
755 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
756 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
757 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
758 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
759 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
760 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
761 |
"Created: 14.2.1997 / 15:24:12 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
762 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
763 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
764 |
openModalWith:aString |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
765 |
"start a textView with aString as initial contents" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
766 |
|
4500 | 767 |
^ self openModalWith:aString title:nil |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
768 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
769 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
770 |
TextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
771 |
EditTextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
772 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
773 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
774 |
"Created: 14.2.1997 / 15:19:04 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
775 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
776 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
777 |
openModalWith:aString title:aTitle |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
778 |
"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
|
779 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
780 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
781 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
782 |
textView := self setupWith:aString title:aTitle. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
783 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
784 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
785 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
786 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
787 |
TextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
788 |
EditTextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
789 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
790 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
791 |
"Modified: 9.9.1996 / 19:32:29 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
792 |
"Created: 14.2.1997 / 15:19:18 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
793 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
794 |
|
248 | 795 |
openOn:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
796 |
"start a textView on a file; return the textView" |
0 | 797 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
798 |
|textView| |
248 | 799 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
800 |
textView := self setupForFile:aFileName. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
801 |
textView topView open. |
248 | 802 |
^ textView |
803 |
||
804 |
" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
805 |
TextView openOn:'../../doc/overview.doc' |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
806 |
EditTextView openOn:'../../doc/overview.doc' |
248 | 807 |
" |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
808 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
809 |
"Modified: 14.2.1997 / 15:21:51 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
810 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
811 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
812 |
openOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
813 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
814 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
815 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
816 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
817 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
818 |
textView topView open. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
819 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
820 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
821 |
"Created: 14.2.1997 / 15:23:36 / cg" |
0 | 822 |
! |
823 |
||
1100 | 824 |
openWith:aStringOrStringCollection |
825 |
"start a textView with aStringOrStringCollection as initial contents" |
|
826 |
||
4500 | 827 |
^ self openWith:aStringOrStringCollection selected:false |
0 | 828 |
|
248 | 829 |
" |
830 |
TextView openWith:'some text' |
|
831 |
EditTextView openWith:'some text' |
|
2794 | 832 |
Workspace openWith:'some text' |
248 | 833 |
" |
119 | 834 |
|
248 | 835 |
"Created: 10.12.1995 / 17:41:32 / cg" |
1100 | 836 |
"Modified: 5.3.1997 / 15:37:19 / cg" |
126 | 837 |
! |
838 |
||
2793 | 839 |
openWith:aStringOrStringCollection selected:selectedBoolean |
4500 | 840 |
"start a textView with aStringOrStringCollection as initial (optionally selected) contents. |
2793 | 841 |
Return the textView." |
842 |
||
843 |
|textView| |
|
844 |
||
845 |
textView := self setupEmpty. |
|
846 |
textView contents:aStringOrStringCollection selected:selectedBoolean. |
|
847 |
textView topView open. |
|
848 |
^ textView |
|
849 |
||
850 |
" |
|
851 |
TextView openWith:'some text' selected:true |
|
852 |
EditTextView openWith:'some text' selected:false |
|
853 |
" |
|
854 |
! |
|
855 |
||
1100 | 856 |
openWith:aStringOrStringCollection title:aTitle |
857 |
"start a textView with aStringOrStringCollection as initial contents. Return the textView." |
|
248 | 858 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
859 |
|textView| |
248 | 860 |
|
1100 | 861 |
textView := self setupWith:aStringOrStringCollection title:aTitle. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
862 |
textView topView open. |
248 | 863 |
^ textView |
864 |
||
865 |
" |
|
866 |
TextView openWith:'some text' title:'testing' |
|
867 |
EditTextView openWith:'some text' title:'testing' |
|
868 |
" |
|
126 | 869 |
|
248 | 870 |
"Created: 10.12.1995 / 17:40:02 / cg" |
1100 | 871 |
"Modified: 5.3.1997 / 15:37:26 / cg" |
248 | 872 |
! |
873 |
||
874 |
setupEmpty |
|
875 |
"create a textview in a topview, with horizontal and |
|
876 |
vertical scrollbars - a helper for #startWith: and #startOn:" |
|
877 |
||
878 |
|top frame label| |
|
879 |
||
880 |
label := 'unnamed'. |
|
896 | 881 |
top := StandardSystemView label:label icon:self defaultIcon. |
248 | 882 |
|
4500 | 883 |
frame := HVScrollableView |
5791 | 884 |
for:self |
885 |
miniScrollerH:true miniScrollerV:false |
|
886 |
in:top. |
|
248 | 887 |
frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
888 |
^ frame scrolledView |
|
896 | 889 |
|
890 |
"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
|
891 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
892 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
893 |
setupForFile:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
894 |
"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
|
895 |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
896 |
|textView| |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
897 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
898 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
899 |
aFileName notNil ifTrue:[ |
5791 | 900 |
textView setupForFile:aFileName. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
901 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
902 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
903 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
904 |
|
3417 | 905 |
"Created: / 14-02-1997 / 15:21:43 / cg" |
906 |
"Modified: / 25-10-2006 / 14:46:54 / cg" |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
907 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
908 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
909 |
setupForModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
910 |
"setup a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
911 |
|
2793 | 912 |
|textView| |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
913 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
914 |
textView := self setupEmpty. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
915 |
textView model:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
916 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
917 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
918 |
"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
|
919 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
920 |
|
1100 | 921 |
setupWith:aStringOrStringCollection title:aTitle |
922 |
"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
|
923 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
924 |
|top textView| |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
925 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
926 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
927 |
top := textView topView. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
928 |
aTitle notNil ifTrue:[top label:aTitle]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
929 |
|
1100 | 930 |
aStringOrStringCollection notNil ifTrue:[ |
5791 | 931 |
textView contents:aStringOrStringCollection |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
932 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
933 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
934 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
935 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
936 |
"Created: 9.9.1996 / 19:31:22 / cg" |
1100 | 937 |
"Modified: 5.3.1997 / 15:37:37 / cg" |
119 | 938 |
! ! |
939 |
||
2744 | 940 |
!TextView methodsFor:'Compatibility-ST80'! |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
941 |
|
2291 | 942 |
displaySelection:aBoolean |
943 |
"ST-80 compatibility: ignored here." |
|
944 |
||
945 |
! |
|
946 |
||
2118
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
947 |
editText:someText |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
948 |
"ST-80 compatibility: set the edited text." |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
949 |
|
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
950 |
self contents:someText |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
951 |
|
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
952 |
"Created: / 5.2.2000 / 17:06:18 / cg" |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
953 |
! |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
954 |
|
2291 | 955 |
selectAndScroll |
956 |
"ST-80 compatibility: ignored here." |
|
957 |
||
958 |
! |
|
959 |
||
4554 | 960 |
selectFrom:startPos to:endPos |
961 |
"change the selection given two character positions." |
|
962 |
||
963 |
self selectFromCharacterPosition:startPos to:endPos |
|
964 |
! |
|
965 |
||
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
966 |
selectionStartIndex |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
967 |
"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
|
968 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
969 |
^ self characterPositionOfSelection |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
970 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
971 |
"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
|
972 |
! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
973 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
974 |
selectionStopIndex |
2052 | 975 |
"ST-80 compatibility: return the character position of |
976 |
the character right after the selection." |
|
977 |
||
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
978 |
|idx| |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
979 |
|
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
980 |
idx := self characterPositionOfSelectionEnd. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
981 |
idx == 0 ifTrue:[^ 0]. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
982 |
^ idx + 1 |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
983 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
984 |
"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
|
985 |
! ! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
986 |
|
0 | 987 |
!TextView methodsFor:'accessing'! |
988 |
||
989 |
characterPositionOfSelection |
|
1303 | 990 |
"return the character index of the first character in the selection. |
991 |
Returns 0 if there is no selection." |
|
992 |
||
6294 | 993 |
|startLine| |
994 |
||
995 |
(startLine := self selectionStartLine) isNil ifTrue:[^ 0]. |
|
996 |
^ self characterPositionOfLine:startLine col:(self selectionStartCol) |
|
1303 | 997 |
|
998 |
"Modified: 14.8.1997 / 16:35:37 / cg" |
|
999 |
! |
|
1000 |
||
1001 |
characterPositionOfSelectionEnd |
|
1002 |
"return the character index of the last character in the selection. |
|
1003 |
Returns 0 if there is no selection." |
|
1004 |
||
6294 | 1005 |
self selectionStartLine isNil ifTrue:[^ 0]. "/ no selection |
1006 |
^ self characterPositionOfLine:self selectionEndLine col:self selectionEndCol |
|
1303 | 1007 |
|
1008 |
"Created: 14.8.1997 / 16:35:24 / cg" |
|
1009 |
"Modified: 14.8.1997 / 16:35:45 / cg" |
|
0 | 1010 |
! |
1011 |
||
1012 |
contentsWasSaved |
|
1013 |
"return true, if the contents was saved (by a save action), |
|
1014 |
false if not (or was modified again after the last save)." |
|
1015 |
||
1016 |
^ contentsWasSaved |
|
1017 |
! |
|
1018 |
||
3214 | 1019 |
contentsWasSaved:aBoolean |
1020 |
contentsWasSaved := aBoolean |
|
1021 |
! |
|
1022 |
||
3212
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
1023 |
defaultFileNameForFileDialog |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
1024 |
"return the default fileName to use for the save-box" |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
1025 |
|
4500 | 1026 |
^ defaultFileNameForFileDialog |
3212
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
1027 |
! |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
1028 |
|
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1029 |
defaultFileNameForFileDialog:aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1030 |
"define the default fileName to use for the save-box" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1031 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1032 |
defaultFileNameForFileDialog := aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1033 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1034 |
"Created: 13.2.1997 / 18:29:53 / cg" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1035 |
! |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1036 |
|
248 | 1037 |
directoryForFileDialog:aDirectory |
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1038 |
"define the default directory to use for save-box" |
248 | 1039 |
|
1040 |
directoryForFileDialog := aDirectory |
|
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1041 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
1042 |
"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
|
1043 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1044 |
|
2941 | 1045 |
externalEncoding |
1046 |
"return the encoding used when the contents is saved via the 'save / save as' dialog. |
|
1047 |
This is (currently only) passed down from the fileBrowser, |
|
1048 |
and required when utf8/japanese/chinese/korean text is edited. |
|
1049 |
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc). |
|
1050 |
Notice: this only affects the external representation of the text." |
|
1051 |
||
1052 |
^ externalEncoding |
|
1053 |
! |
|
1054 |
||
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1055 |
externalEncoding:encodingSymOrNil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1056 |
"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
|
1057 |
via the 'save / save as' dialog. |
2916 | 1058 |
This is (currently only) passed down from the fileBrowser, |
1059 |
and required when utf8/japanese/chinese/korean text is edited. |
|
1060 |
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc). |
|
1061 |
Notice: this only affects the external representation of the text." |
|
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1062 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
1063 |
externalEncoding := encodingSymOrNil |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1064 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1065 |
|
2581 | 1066 |
parenthesisSpecification |
1067 |
"return the value of the instance variable 'parenthesisSpecification' (automatically generated)" |
|
1068 |
||
1069 |
^ parenthesisSpecification |
|
1070 |
! |
|
1071 |
||
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1072 |
parenthesisSpecification:aDictionary |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1073 |
"set the dictionary which specifies which characters are opening, which are closing |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1074 |
and which are ignored characters w.r.t. parenthesis matching. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1075 |
See the classes initialize method for a useful value." |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1076 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1077 |
parenthesisSpecification := aDictionary |
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1078 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1079 |
|
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1080 |
saveAction:something |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1081 |
saveAction := something. |
3581 | 1082 |
! |
1083 |
||
3981 | 1084 |
searchBarActionBlock |
1085 |
^ searchBarActionBlock |
|
3581 | 1086 |
! |
1087 |
||
3981 | 1088 |
searchBarActionBlock:something |
1089 |
searchBarActionBlock := something. |
|
5848 | 1090 |
! |
1091 |
||
1092 |
textView |
|
1093 |
"added to allow sending textView in any context, where either |
|
5923 | 1094 |
a TextView or a CodeView2 can be encountered. |
1095 |
Sigh - all of this because CodeView2 wraps a textView, and does not forward |
|
1096 |
all messages. |
|
1097 |
Thus, the codeView2 framework always sends codeView2 textView doSomething" |
|
5848 | 1098 |
|
1099 |
^ self |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1100 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1101 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1102 |
!TextView methodsFor:'accessing-contents'! |
248 | 1103 |
|
2791 | 1104 |
contents:newContents selected:selectedBoolean |
1105 |
self contents:newContents. |
|
1106 |
selectedBoolean ifTrue:[ |
|
5791 | 1107 |
list size == 1 ifTrue:[ |
1108 |
self selectFromLine:1 col:1 toLine:1 col:(list at:1) size |
|
1109 |
] ifFalse:[ |
|
1110 |
self selectAll |
|
1111 |
] |
|
2791 | 1112 |
] |
1113 |
||
1114 |
" |
|
1115 |
|w| |
|
1116 |
||
1117 |
w := Workspace new open. |
|
1118 |
w contents:'Hello world' selected:true. |
|
1119 |
" |
|
1120 |
! |
|
1121 |
||
0 | 1122 |
fromFile:aFileName |
1123 |
"take contents from a named file" |
|
3724 | 1124 |
<resource: #obsolete> |
0 | 1125 |
|
3417 | 1126 |
self obsoleteMethodWarning. |
1127 |
^ self loadTextFile:aFileName. |
|
1128 |
||
1129 |
"Modified: / 25-10-2006 / 14:47:35 / cg" |
|
0 | 1130 |
! |
1131 |
||
4755 | 1132 |
list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
1133 |
"set the displayed contents (a collection of strings) with redraw. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1134 |
Redefined since changing the contents implies deselect" |
0 | 1135 |
|
1136 |
self unselect. |
|
4755 | 1137 |
super list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
0 | 1138 |
! |
1139 |
||
3417 | 1140 |
loadTextFile:aFileName |
1141 |
"take contents from a named file" |
|
1142 |
||
1143 |
|f| |
|
1144 |
||
1145 |
f := aFileName asFilename. |
|
1146 |
self directoryForFileDialog:(f directoryName). |
|
1147 |
self contents:(f contents) |
|
1148 |
||
1149 |
"Created: / 25-10-2006 / 14:44:01 / cg" |
|
1150 |
! |
|
1151 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1152 |
setContents:something |
6294 | 1153 |
"set the contents (either a string or a collection of strings). |
1154 |
Does not change the position (i.e. does not scroll) |
|
1155 |
and (tries to) keep the selection." |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1156 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1157 |
|selStartLine selStartCol selEndLine selEndCol selStyle| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1158 |
|
6294 | 1159 |
selStartLine := self selectionStartLine. |
1160 |
selStartCol := self selectionStartCol. |
|
1161 |
selEndLine := self selectionEndLine. |
|
1162 |
selEndCol := self selectionEndCol. |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1163 |
selStyle := selectStyle. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1164 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1165 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1166 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1167 |
selStartLine notNil ifTrue:[ |
5791 | 1168 |
self |
1169 |
selectFromLine:selStartLine col:selStartCol |
|
1170 |
toLine:selEndLine col:selEndCol. |
|
1171 |
selectStyle := selStyle |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1172 |
]. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1173 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1174 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1175 |
"Modified: / 31.3.1998 / 23:33:21 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1176 |
! |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1177 |
|
248 | 1178 |
setList:something |
1179 |
"set the displayed contents (a collection of strings) |
|
1180 |
without redraw. |
|
1181 |
Redefined since changing contents implies deselect" |
|
0 | 1182 |
|
248 | 1183 |
self unselect. |
1184 |
super setList:something |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1185 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1186 |
|
3417 | 1187 |
setupForFile:aFileName |
1188 |
"take contents from a named file" |
|
1189 |
||
1190 |
|baseName| |
|
1191 |
||
1192 |
self loadTextFile:aFileName. |
|
1193 |
aFileName notNil ifTrue:[ |
|
5791 | 1194 |
baseName := aFileName asFilename baseName. |
1195 |
self topView label:baseName. |
|
1196 |
self defaultFileNameForFileDialog:baseName. |
|
3417 | 1197 |
]. |
1198 |
||
1199 |
"Created: / 25-10-2006 / 14:47:13 / cg" |
|
1200 |
! |
|
1201 |
||
1487
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1202 |
text |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1203 |
"for ST80 compatibility" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1204 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1205 |
^ self contents |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1206 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1207 |
"Created: / 19.4.1998 / 12:53:10 / cg" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1208 |
! |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1209 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1210 |
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
|
1211 |
"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
|
1212 |
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
|
1213 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1214 |
|beginCol endCol endLine thisCharacter flag| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1215 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1216 |
flag := #word. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1217 |
beginCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1218 |
endCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1219 |
endLine := selectLine. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1220 |
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
|
1221 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1222 |
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
|
1223 |
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
|
1224 |
endCol == 0 ifTrue:[ |
5791 | 1225 |
endLine := selectLine + 1 |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1226 |
]. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1227 |
|
1750 | 1228 |
"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
|
1229 |
(wordCheck value:thisCharacter) ifTrue:[ |
5791 | 1230 |
" |
1231 |
try to catch a blank ... |
|
1232 |
" |
|
1233 |
||
1234 |
WordSelectCatchesBlanks ifTrue:[ |
|
1235 |
((beginCol == 1) |
|
1236 |
or:[(self characterAtLine:selectLine col:(beginCol - 1)) |
|
1237 |
~~ Character space]) ifTrue:[ |
|
1238 |
((self characterAtLine:selectLine col:(endCol + 1)) |
|
1239 |
== Character space) ifTrue:[ |
|
1240 |
endCol := endCol + 1. |
|
1241 |
flag := #wordRight |
|
1242 |
] |
|
1243 |
] ifFalse:[ |
|
1244 |
beginCol := beginCol - 1. |
|
1245 |
flag := #wordLeft |
|
1246 |
]. |
|
1247 |
]. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1248 |
]. |
4500 | 1249 |
aFiveArgBlock value:selectLine |
5791 | 1250 |
value:beginCol |
1251 |
value:endLine |
|
1252 |
value:endCol |
|
1253 |
value:flag |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1254 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1255 |
"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
|
1256 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1257 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1258 |
!TextView methodsFor:'accessing-look'! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1259 |
|
2027
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1260 |
selectionBackgroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1261 |
"return the selection-background color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1262 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1263 |
^ selectionBgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1264 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1265 |
|
5847 | 1266 |
selectionBackgroundColor:aColor |
1267 |
"set the selection-background color. |
|
1268 |
The default is defined by the styleSheet; |
|
1269 |
typically black-on-green for color displays and white-on-black for b&w displays." |
|
1270 |
||
1271 |
selectionBgColor := aColor onDevice:device. |
|
1272 |
self hasSelection ifTrue:[ |
|
1273 |
self invalidate |
|
1274 |
] |
|
1275 |
! |
|
1276 |
||
2027
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1277 |
selectionForegroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1278 |
"return the selection-foreground color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1279 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1280 |
^ selectionFgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1281 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1282 |
|
5847 | 1283 |
selectionForegroundColor:aColor |
1284 |
"set the selection-foreground color. |
|
1285 |
The default is defined by the styleSheet; |
|
1286 |
typically black-on-green for color displays and white-on-black for b&w displays." |
|
1287 |
||
1288 |
selectionFgColor := aColor onDevice:device. |
|
1289 |
self hasSelection ifTrue:[ |
|
1290 |
self invalidate |
|
1291 |
] |
|
1292 |
! |
|
1293 |
||
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1294 |
selectionForegroundColor:color1 backgroundColor:color2 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1295 |
"set both the selection-foreground and cursor background colors. |
4500 | 1296 |
The default is defined by the styleSheet; |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1297 |
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
|
1298 |
|
1987 | 1299 |
selectionFgColor := color1 onDevice:device. |
1300 |
selectionBgColor := color2 onDevice:device. |
|
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
1301 |
self hasSelection ifTrue:[ |
5791 | 1302 |
self invalidate |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1303 |
] |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1304 |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
715
diff
changeset
|
1305 |
"Modified: 29.5.1996 / 16:22:15 / cg" |
0 | 1306 |
! ! |
1307 |
||
248 | 1308 |
!TextView methodsFor:'accessing-mvc'! |
0 | 1309 |
|
248 | 1310 |
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
|
1311 |
"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
|
1312 |
and selection. Added for ST-80 compatibility" |
0 | 1313 |
|
4500 | 1314 |
aspectSym notNil ifTrue:[aspectMsg := aspectSym. |
5791 | 1315 |
listMsg isNil ifTrue:[listMsg := aspectSym]]. |
248 | 1316 |
changeSym notNil ifTrue:[changeMsg := changeSym]. |
1317 |
listSym notNil ifTrue:[listMsg := listSym]. |
|
1318 |
menuSym notNil ifTrue:[menuMsg := menuSym]. |
|
1319 |
"/ initial notNil ifTrue:[initialSelectionMsg := initial]. |
|
1320 |
self model:aModel. |
|
0 | 1321 |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1322 |
"Modified: 15.8.1996 / 12:52:54 / stefan" |
906 | 1323 |
"Modified: 2.1.1997 / 16:11:28 / cg" |
0 | 1324 |
! ! |
1325 |
||
2588 | 1326 |
!TextView methodsFor:'drag & drop'! |
1327 |
||
1328 |
allowDrag:aBoolean |
|
1329 |
"enable/disable dragging support |
|
1330 |
" |
|
1331 |
aBoolean ifFalse:[ |
|
5791 | 1332 |
dropSource := nil. |
2588 | 1333 |
] ifTrue:[ |
5791 | 1334 |
dropSource isNil ifTrue:[ |
1335 |
dropSource := DropSource |
|
1336 |
receiver:self |
|
1337 |
argument:nil |
|
1338 |
dropObjectSelector:#collectionOfDragObjects |
|
1339 |
displayObjectSelector:nil |
|
1340 |
] |
|
2588 | 1341 |
]. |
1342 |
! |
|
1343 |
||
1344 |
canDrag |
|
4368 | 1345 |
"returns true if dragging is enabled" |
1346 |
||
1347 |
^ dropSource notNil and:[ self hasSelection ] |
|
1348 |
||
1349 |
"Modified (comment): / 12-02-2012 / 08:37:21 / cg" |
|
2588 | 1350 |
! |
1351 |
||
1352 |
collectionOfDragObjects |
|
1353 |
"returns collection of dragable objects assigned to selection |
|
1354 |
Here, by default, a collection of text-dragObjects is generated; |
|
1355 |
however, if a dragObjectConverter is defined, that one gets a chance |
|
1356 |
to convert as appropriate. |
|
1357 |
" |
|
1358 |
|selection| |
|
1359 |
||
1360 |
selection := self selection. |
|
1361 |
||
1362 |
selection size == 0 ifTrue:[^ nil]. |
|
5249 | 1363 |
^ Array with:(DropObject newText:selection). |
2588 | 1364 |
! |
1365 |
||
1366 |
dropSource |
|
3245 | 1367 |
"returns the dropSource or nil" |
4500 | 1368 |
|
2588 | 1369 |
^ dropSource |
1370 |
! |
|
1371 |
||
4500 | 1372 |
dropSource:aDropSourceOrNil |
3245 | 1373 |
"set the dropSource or nil" |
4500 | 1374 |
|
2588 | 1375 |
dropSource := aDropSourceOrNil. |
1376 |
! ! |
|
1377 |
||
2881 | 1378 |
!TextView methodsFor:'encoding'! |
1379 |
||
1380 |
validateFontEncodingFor:newEncoding ask:ask |
|
1381 |
"if required, query user if he/she wants to change to another font, |
|
1382 |
which is able to display text encoded as specified by newEncoding" |
|
1383 |
||
4500 | 1384 |
|fontsEncoding msg filter f defaultFont pref matchingFonts |
2881 | 1385 |
matchingFamilyFonts matchingFamilyFaceFonts matchingFamilyFaceStyleFonts |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
1386 |
matchingFamilyFaceStyleSizeFonts font| |
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
1387 |
|
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
1388 |
font := gc font. |
2881 | 1389 |
fontsEncoding := font encoding. |
1390 |
||
1391 |
pref := FontDescription preferredFontEncodingFor:newEncoding. |
|
1392 |
||
1393 |
(pref match:fontsEncoding) ifTrue:[ |
|
5412 | 1394 |
^ self |
2881 | 1395 |
]. |
5412 | 1396 |
(fontsEncoding notNil and:[CharacterEncoder isEncoding:pref subSetOf:fontsEncoding]) ifTrue:[ |
1397 |
^ self |
|
2881 | 1398 |
]. |
1399 |
||
1400 |
filter := [:f | |coding| |
|
5412 | 1401 |
(coding := f encoding) notNil |
1402 |
and:[pref match:coding]]. |
|
2881 | 1403 |
|
1404 |
device flushListOfAvailableFonts. |
|
1405 |
matchingFonts := device listOfAvailableFonts select:filter. |
|
1406 |
matchingFamilyFonts := matchingFonts select:[:f | f family = font family]. |
|
1407 |
matchingFamilyFaceFonts := matchingFamilyFonts select:[:f | f face = font face]. |
|
1408 |
matchingFamilyFaceStyleFonts := matchingFamilyFaceFonts select:[:f | f style = font style]. |
|
1409 |
matchingFamilyFaceStyleSizeFonts := matchingFamilyFaceStyleFonts select:[:f | f size = font size]. |
|
6553 | 1410 |
matchingFamilyFaceStyleSizeFonts size ~~ 0 ifTrue:[ |
5412 | 1411 |
defaultFont := matchingFamilyFaceStyleSizeFonts first |
2881 | 1412 |
] ifFalse:[ |
6553 | 1413 |
matchingFamilyFaceStyleFonts size ~~ 0 ifTrue:[ |
5412 | 1414 |
defaultFont := matchingFamilyFaceStyleFonts first |
1415 |
] ifFalse:[ |
|
6553 | 1416 |
matchingFamilyFaceFonts size ~~ 0 ifTrue:[ |
5412 | 1417 |
defaultFont := matchingFamilyFaceFonts first |
1418 |
] ifFalse:[ |
|
6553 | 1419 |
matchingFamilyFonts size ~~ 0 ifTrue:[ |
5412 | 1420 |
defaultFont := matchingFamilyFonts first |
1421 |
] ifFalse:[ |
|
6553 | 1422 |
matchingFonts size ~~ 0 ifTrue:[ |
5412 | 1423 |
defaultFont := matchingFonts first |
1424 |
]. |
|
1425 |
]. |
|
1426 |
]. |
|
1427 |
]. |
|
2881 | 1428 |
]. |
1429 |
||
1430 |
defaultFont isNil ifTrue:[ |
|
6459 | 1431 |
self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'. |
1432 |
pref := #'iso10646-1'. |
|
2881 | 1433 |
]. |
1434 |
||
2916 | 1435 |
msg := 'Switch to a %1 encoded font ?'. |
3189 | 1436 |
(ask not or:[self confirm:(resources stringWithCRs:msg with:pref)]) |
2881 | 1437 |
ifTrue:[ |
5412 | 1438 |
self withWaitCursorDo:[ |
1439 |
f := FontPanel |
|
1440 |
fontFromUserInitial:defaultFont |
|
1441 |
title:(resources string:'Font selection') |
|
1442 |
filter:filter |
|
1443 |
encoding:pref. |
|
1444 |
||
1445 |
f notNil ifTrue:[ |
|
1446 |
self font:f. |
|
1447 |
] |
|
1448 |
] |
|
2881 | 1449 |
] |
1450 |
||
6459 | 1451 |
"Created: / 26-10-1996 / 12:06:54 / cg" |
1452 |
"Modified: / 30-06-1997 / 17:46:46 / cg" |
|
1453 |
"Modified: / 22-10-2018 / 11:55:44 / Stefan Vogel" |
|
6553 | 1454 |
"Modified: / 01-03-2019 / 16:14:53 / Claus Gittinger" |
2881 | 1455 |
! ! |
1456 |
||
2752 | 1457 |
!TextView methodsFor:'event handling'! |
0 | 1458 |
|
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1459 |
buttonMotion:buttonState x:x y:y |
0 | 1460 |
"mouse-move while button was pressed - handle selection changes" |
1461 |
||
3219
e8c7679a8a94
buttonrelease behavior, when released in another view
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
1462 |
(clickLine isNil or:[clickPos isNil]) ifTrue:[ |
5791 | 1463 |
dragIsActive := false. |
1464 |
^ self |
|
2588 | 1465 |
]. |
1466 |
||
1467 |
dragIsActive ifTrue:[ |
|
5791 | 1468 |
(clickPos dist:(x@y)) >= 5.0 ifTrue:[ |
1469 |
dragIsActive := false. |
|
1470 |
||
1471 |
self hasSelection ifTrue:[ |
|
1472 |
dropSource startDragIn:self at:(x@y) |
|
1473 |
] |
|
1474 |
]. |
|
1475 |
^ self |
|
2588 | 1476 |
]. |
0 | 1477 |
|
63 | 1478 |
"is it the select or 1-button ?" |
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1479 |
buttonState == 0 ifTrue:[^ self]. |
4885 | 1480 |
self sensor leftButtonPressed ifFalse:[ |
5791 | 1481 |
"/ self setPrimarySelection. |
1482 |
"/ self selectionChanged. |
|
1483 |
^ self |
|
4885 | 1484 |
]. |
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1485 |
"/ (device buttonMotionMask:buttonState includesButton:#select) ifFalse:[ |
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1486 |
"/ (device buttonMotionMask:buttonState includesButton:1) ifFalse:[ |
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1487 |
"/ ^ self |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1488 |
"/ ]. |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1489 |
"/ ]. |
53 | 1490 |
|
0 | 1491 |
"if moved outside of view, start autoscroll" |
3202
8217b0acc9f2
select from beginning (in editField
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
1492 |
|
4160 | 1493 |
((y < 0) and:[firstLineShown ~~ 0]) ifTrue:[ |
5791 | 1494 |
self compressMotionEvents:false. |
1495 |
(self startAutoScrollUp:y negated) ifTrue:[ |
|
1496 |
^ self |
|
1497 |
]. |
|
0 | 1498 |
]. |
1499 |
(y > height) ifTrue:[ |
|
5791 | 1500 |
self compressMotionEvents:false. |
1501 |
(self startAutoScrollDown:(y - height)) ifTrue:[ |
|
1502 |
^ self |
|
1503 |
]. |
|
59 | 1504 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1505 |
((x < 0) and:[viewOrigin x ~~ 0]) ifTrue:[ |
5791 | 1506 |
self compressMotionEvents:false. |
1507 |
(self startAutoScrollLeft:x) ifTrue:[ |
|
1508 |
^ self |
|
1509 |
]. |
|
59 | 1510 |
]. |
1511 |
(x > width) ifTrue:[ |
|
5791 | 1512 |
self compressMotionEvents:false. |
1513 |
(self startAutoScrollRight:(x - width)) ifTrue:[ |
|
1514 |
^ self |
|
1515 |
]. |
|
0 | 1516 |
]. |
1517 |
||
1518 |
"move inside - stop autoscroll if any" |
|
1519 |
autoScrollBlock notNil ifTrue:[ |
|
5791 | 1520 |
self stopScrollSelect |
0 | 1521 |
]. |
3220 | 1522 |
|
4885 | 1523 |
self extendSelectionToX:x y:y setPrimarySelection:false. |
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1524 |
|
4160 | 1525 |
"Modified: / 08-08-2010 / 11:20:54 / cg" |
0 | 1526 |
! |
1527 |
||
248 | 1528 |
buttonMultiPress:button x:x y:y |
1529 |
"multi-mouse-click - select word under pointer" |
|
1530 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1531 |
(button == 1) ifTrue:[ |
5791 | 1532 |
clickPos := x @ y. |
1533 |
||
1534 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
|
4063 | 1535 |
"/ self clearSearchAction. |
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
1536 |
|
5791 | 1537 |
clickCount notNil ifTrue:[ |
1538 |
clickCount := clickCount + 1. |
|
1539 |
(clickCount == 2) ifTrue:[ |
|
1540 |
self doubleClickX:x y:y |
|
1541 |
] ifFalse:[ |
|
1542 |
(clickCount == 3) ifTrue:[ |
|
1543 |
self tripleClickX:x y:y |
|
1544 |
] ifFalse:[ |
|
1545 |
(clickCount == 4) ifTrue:[ |
|
1546 |
self quadClickX:x y:y |
|
1547 |
] |
|
1548 |
] |
|
1549 |
] |
|
1550 |
] |
|
248 | 1551 |
] ifFalse:[ |
5791 | 1552 |
super buttonMultiPress:button x:x y:y |
248 | 1553 |
] |
1554 |
||
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1555 |
"Modified: 11.9.1997 / 04:15:35 / cg" |
248 | 1556 |
! |
1557 |
||
1558 |
buttonPress:button x:x y:y |
|
1559 |
"mouse-click - prepare for selection change" |
|
1560 |
||
1308 | 1561 |
|sensor clickVisibleLine| |
1562 |
||
2588 | 1563 |
dragIsActive := false. |
1564 |
sensor := self sensor. |
|
1565 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1566 |
(button == 1) ifTrue:[ |
5791 | 1567 |
sensor shiftDown ifTrue:[ |
1568 |
"mouse-click with shift - adding to selection" |
|
1569 |
self extendSelectionToX:x y:y. |
|
1570 |
^ self |
|
1571 |
]. |
|
1572 |
||
1573 |
clickVisibleLine := self visibleLineOfY:y. |
|
1574 |
clickPos := x @ y. |
|
1575 |
clickCol := self colOfX:x inVisibleLine:clickVisibleLine. |
|
1576 |
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine. |
|
1577 |
clickStartLine := clickLine. |
|
1578 |
clickStartCol := clickCol. |
|
1579 |
||
1580 |
(self canDrag |
|
1581 |
and:[(self isInSelection:clickLine col:clickCol) |
|
1582 |
and:[UserPreferences current startTextDragWithControl not |
|
1583 |
or:[sensor ctrlDown]]]) ifTrue:[ |
|
1584 |
dragIsActive := true |
|
1585 |
] ifFalse:[ |
|
1586 |
self unselect. |
|
1587 |
]. |
|
1588 |
clickCount := 1 |
|
248 | 1589 |
] ifFalse:[ |
5791 | 1590 |
super buttonPress:button x:x y:y |
248 | 1591 |
] |
813
7168eda47e3b
Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents:
770
diff
changeset
|
1592 |
|
1909 | 1593 |
"Modified: / 20.5.1999 / 17:02:45 / cg" |
248 | 1594 |
! |
1595 |
||
0 | 1596 |
buttonRelease:button x:x y:y |
1597 |
"mouse- button release - turn off autoScroll if any" |
|
1598 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1599 |
(button == 1) ifTrue:[ |
5791 | 1600 |
self hasSelection ifTrue:[ |
1601 |
self setPrimarySelection. |
|
1602 |
self selectionChanged. |
|
1603 |
]. |
|
1604 |
||
1605 |
autoScrollBlock notNil ifTrue:[ |
|
1606 |
self stopScrollSelect |
|
1607 |
]. |
|
1608 |
dragIsActive ifTrue:[ |
|
1609 |
self unselect |
|
1610 |
]. |
|
1611 |
clickPos := nil. |
|
0 | 1612 |
] ifFalse:[ |
5791 | 1613 |
super buttonRelease:button x:x y:y |
1909 | 1614 |
]. |
2588 | 1615 |
dragIsActive := false. |
1616 |
||
1909 | 1617 |
"/ clickPos := clickLine := clickCol := nil. |
1618 |
||
1619 |
"Modified: / 20.5.1999 / 17:14:23 / cg" |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1620 |
! |
248 | 1621 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1622 |
doubleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1623 |
"double-click - select word under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1624 |
|
3588
a70267e5b501
st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents:
3587
diff
changeset
|
1625 |
|sel ch scanCh matchCol scanCol fwdScan fwdSelect| |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1626 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1627 |
self selectWordAtX:x y:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1628 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1629 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1630 |
special - if clicked on a parenthesis, select to matching |
4702 | 1631 |
(must de before doing the ST80 stuff below) |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1632 |
" |
4500 | 1633 |
((sel := self selection) size == 1 |
6456 | 1634 |
and:[(sel := sel at:1) size == 1]) ifTrue:[ |
5791 | 1635 |
ch := sel at:1. |
1636 |
||
1637 |
((self isOpeningParenthesis:ch) |
|
6459 | 1638 |
or:[(self isClosingParenthesis:ch) |
1639 |
or:[self isBeginOfIgnoredBlock:ch]]) ifTrue:[ |
|
5791 | 1640 |
self |
1641 |
searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol |
|
1642 |
ifFound:[:line :col | |
|
1643 |
|prevLine prevCol moveBack pos1| |
|
1644 |
||
1645 |
prevLine := firstLineShown. |
|
1646 |
prevCol := viewOrigin x. |
|
1647 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1648 |
toLine:line col:col. |
|
1649 |
||
1650 |
self sensor ctrlDown ifFalse:[ |
|
1651 |
"/ undo scroll operation ... |
|
1652 |
self withCursor:Cursor eye do:[ |
|
1653 |
|delayCount| |
|
1654 |
||
1655 |
moveBack := false. |
|
1656 |
(self isClosingParenthesis:ch) ifTrue:[ |
|
1657 |
(firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[ |
|
1658 |
moveBack := true |
|
1659 |
] |
|
1660 |
] ifFalse:[ |
|
1661 |
selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[ |
|
1662 |
self makeLineVisible:selectionEndLine. |
|
1663 |
moveBack := true |
|
1664 |
] |
|
1665 |
]. |
|
1666 |
moveBack ifTrue:[ |
|
1667 |
delayCount := 0. |
|
1668 |
pos1 := x@y. |
|
1669 |
self invalidateRepairNow:true. |
|
1670 |
Delay waitForSeconds:MatchDelayTime. |
|
1671 |
delayCount := delayCount + MatchDelayTime. |
|
1672 |
[self sensor hasUserEventFor:self] whileFalse:[ |
|
1673 |
Delay waitForSeconds:MatchDelayTime / 2. |
|
1674 |
delayCount := delayCount + (MatchDelayTime / 2). |
|
1675 |
delayCount > 2 ifTrue:[ |
|
1676 |
self cursor:Cursor eyeClosed. |
|
1677 |
]. |
|
1678 |
delayCount >= 2.3 ifTrue:[ |
|
1679 |
self cursor:Cursor eye. |
|
1680 |
delayCount := 0. |
|
1681 |
] |
|
1682 |
]. |
|
1683 |
self scrollToLine:prevLine; scrollToCol:prevCol. |
|
1684 |
]. |
|
1685 |
] |
|
1686 |
]. |
|
1687 |
^ self. |
|
1688 |
] |
|
1689 |
ifNotFound:[self showNotFound] |
|
6264 | 1690 |
onError:[self beepInEditor] |
5791 | 1691 |
openingCharacters:((parenthesisSpecification at:#open) ", '([{'") |
6459 | 1692 |
closingCharacters:((parenthesisSpecification at:#close) ", ')]}'") |
1693 |
ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#()) |
|
1694 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()). |
|
5791 | 1695 |
selectStyle := nil |
1696 |
] |
|
4702 | 1697 |
]. |
1698 |
||
1699 |
(self st80SelectMode or:[ self sensor ctrlDown]) ifTrue:[ |
|
5791 | 1700 |
"/ st80 selects: |
1701 |
"/ - if clicked right after a parenthesis -> select to matching parenthesis |
|
1702 |
"/ - if clicked right after a quote -> select to matching quote (unless escaped ;-) |
|
1703 |
"/ - if clicked at beginning of the line -> select that line |
|
1704 |
"/ - if clicked at the top of the text -> select all |
|
1705 |
"/ however, do none of the above, if clicked on a parenthesis |
|
1706 |
clickCol == 1 ifTrue:[ |
|
1707 |
clickLine == 1 ifTrue:[ |
|
1708 |
self selectAll. |
|
1709 |
^ self. |
|
1710 |
]. |
|
1711 |
self selectLineAtY:y. |
|
1712 |
selectStyle := #line. |
|
1713 |
^ self |
|
1714 |
]. |
|
1715 |
||
1716 |
matchCol := nil. |
|
1717 |
"/ see what is to the left of that character ... |
|
1718 |
clickCol > 1 ifTrue:[ |
|
1719 |
ch := self characterAtLine:clickLine col:clickCol-1. |
|
1720 |
(self isOpeningParenthesis:ch) ifTrue:[ |
|
1721 |
matchCol := clickCol - 1 |
|
1722 |
] ifFalse:[ |
|
1723 |
('"''|' includes:ch) ifTrue:[ |
|
1724 |
scanCol := clickCol - 1. |
|
1725 |
fwdScan := true. |
|
1726 |
scanCh := ch. |
|
1727 |
] |
|
1728 |
] |
|
1729 |
]. |
|
1730 |
fwdSelect := true. |
|
1731 |
(matchCol isNil and:[scanCol isNil]) ifTrue:[ |
|
1732 |
clickCol < (self listAt:clickLine) size ifTrue:[ |
|
1733 |
ch := self characterAtLine:clickLine col:clickCol+1. |
|
1734 |
(self isClosingParenthesis:ch) ifTrue:[ |
|
1735 |
matchCol := clickCol + 1. |
|
1736 |
fwdSelect := false. |
|
1737 |
] ifFalse:[ |
|
1738 |
('"''|' includes:ch) ifTrue:[ |
|
1739 |
scanCol := clickCol + 1. |
|
1740 |
fwdScan := false. |
|
1741 |
scanCh := ch. |
|
1742 |
] |
|
1743 |
] |
|
1744 |
]. |
|
1745 |
]. |
|
1746 |
matchCol notNil ifTrue:[ |
|
1747 |
self |
|
1748 |
searchForMatchingParenthesisFromLine:clickLine col:matchCol |
|
1749 |
ifFound:[:line :col | |
|
1750 |
self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1) |
|
1751 |
toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)] |
|
1752 |
ifNotFound:[self showNotFound] |
|
1753 |
onError:[self beep] |
|
1754 |
openingCharacters:((parenthesisSpecification at:#open) , '([{') |
|
6459 | 1755 |
closingCharacters:((parenthesisSpecification at:#close) , ')]}') |
1756 |
ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#()) |
|
1757 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()). |
|
5791 | 1758 |
^ self |
1759 |
]. |
|
1760 |
scanCol notNil ifTrue:[ |
|
6099 | 1761 |
"/ if it's an EOL comment, do it differently |
5791 | 1762 |
ch := self characterAtLine:clickLine col:clickCol. |
1763 |
ch == $/ ifTrue:[ |
|
1764 |
self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0. |
|
1765 |
^ self |
|
1766 |
]. |
|
1767 |
||
1768 |
self |
|
1769 |
scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan |
|
1770 |
ifFound:[:line :col | |
|
1771 |
|selStart selEnd| |
|
1772 |
||
1773 |
fwdScan ifTrue:[ |
|
1774 |
selStart := scanCol+1. |
|
1775 |
selEnd := col-1. |
|
1776 |
] ifFalse:[ |
|
1777 |
selStart := scanCol-1. |
|
1778 |
selEnd := col+1. |
|
1779 |
]. |
|
1780 |
self selectFromLine:clickLine col:selStart |
|
1781 |
toLine:line col:selEnd. |
|
1782 |
^ self |
|
1783 |
] |
|
1784 |
ifNotFound:[self showNotFound]. |
|
1785 |
^ self |
|
1786 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1787 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1788 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1789 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1790 |
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
|
1791 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1792 |
wordStartLine := selectionStartLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1793 |
wordEndLine := selectionEndLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1794 |
selectStyle == #wordLeft ifTrue:[ |
5791 | 1795 |
wordStartCol := selectionStartCol + 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1796 |
] ifFalse:[ |
5791 | 1797 |
wordStartCol := selectionStartCol. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1798 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1799 |
selectStyle == #wordRight ifTrue:[ |
5791 | 1800 |
wordEndCol := selectionEndCol - 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1801 |
] ifFalse:[ |
5791 | 1802 |
wordEndCol := selectionEndCol |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1803 |
] |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1804 |
|
3308 | 1805 |
"Created: / 11-09-1997 / 04:12:55 / cg" |
4255 | 1806 |
"Modified: / 14-06-2011 / 14:04:59 / cg" |
6099 | 1807 |
"Modified (format): / 13-02-2017 / 20:32:08 / cg" |
6459 | 1808 |
"Modified: / 22-10-2018 / 10:54:32 / Stefan Vogel" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1809 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1810 |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1811 |
extendSelectionToX:x y:y |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1812 |
"mouse-move while button was pressed - handle selection changes" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1813 |
|
4885 | 1814 |
self extendSelectionToX:x y:y setPrimarySelection:true |
1815 |
! |
|
1816 |
||
1817 |
extendSelectionToX:x y:y setPrimarySelection:aBoolean |
|
6351 | 1818 |
"mouse-move while button was pressed or shift-clicked |
1819 |
- handle selection changes" |
|
4885 | 1820 |
|
4500 | 1821 |
|movedVisibleLine movedLine movedCol |
1822 |
movedUp |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1823 |
oldStartLine oldEndLine oldStartCol oldEndCol| |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1824 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1825 |
movedVisibleLine := self visibleLineOfY:y. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1826 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1827 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1828 |
(x < leftMargin) ifTrue:[ |
5791 | 1829 |
movedCol := 0 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1830 |
] ifFalse:[ |
5791 | 1831 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1832 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1833 |
y < 0 ifTrue:[ |
5791 | 1834 |
movedCol := 0 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1835 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1836 |
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[ |
5791 | 1837 |
selectionStartLine notNil ifTrue:[ |
1838 |
^ self |
|
1839 |
]. |
|
1840 |
(clickPos isNil |
|
1841 |
or:[(clickPos x - x) abs < 3 |
|
1842 |
and:[(clickPos y - y) abs < 3]]) ifTrue:[ |
|
1843 |
^ self |
|
1844 |
]. |
|
1845 |
selectionStartLine := clickLine. |
|
1846 |
selectionStartCol := clickCol. |
|
1847 |
selectionEndLine := selectionStartLine. |
|
1848 |
selectionEndCol := selectionStartCol. |
|
1849 |
||
1850 |
oldStartLine := selectionStartLine. |
|
1851 |
oldEndLine := selectionEndLine. |
|
1852 |
oldStartCol := selectionStartCol. |
|
1853 |
oldEndCol := selectionEndCol-1. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1854 |
] ifFalse:[ |
5791 | 1855 |
selectionStartLine isNil ifTrue:[ |
1856 |
selectionStartLine := selectionEndLine := clickLine. |
|
1857 |
selectionStartCol := selectionEndCol := clickCol. |
|
1858 |
]. |
|
1859 |
oldStartLine := selectionStartLine. |
|
1860 |
oldEndLine := selectionEndLine. |
|
1861 |
oldStartCol := selectionStartCol. |
|
1862 |
oldEndCol := selectionEndCol. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1863 |
]. |
3692 | 1864 |
oldEndLine isNil ifTrue:[ |
5791 | 1865 |
oldEndLine := selectionEndLine ? clickLine ? movedLine. |
3692 | 1866 |
]. |
1867 |
oldEndCol isNil ifTrue:[ |
|
5791 | 1868 |
oldEndCol := selectionEndCol ? clickCol. |
3692 | 1869 |
]. |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1870 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1871 |
"find out if we are before or after initial click" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1872 |
movedUp := false. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1873 |
clickStartLine isNil ifTrue:[ |
5791 | 1874 |
clickStartLine := movedLine. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1875 |
]. |
3505 | 1876 |
clickStartCol isNil ifTrue:[ |
5791 | 1877 |
clickStartCol := movedCol. |
3505 | 1878 |
]. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1879 |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1880 |
(movedLine < clickStartLine) ifTrue:[ |
5791 | 1881 |
movedUp := true |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1882 |
] ifFalse:[ |
5791 | 1883 |
(movedLine == clickStartLine) ifTrue:[ |
1884 |
(movedCol < clickStartCol) ifTrue:[ |
|
1885 |
movedUp := true |
|
1886 |
] |
|
1887 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1888 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1889 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1890 |
movedUp ifTrue:[ |
6351 | 1891 |
"select backwards" |
5791 | 1892 |
selectionStartCol := movedCol. |
1893 |
selectionStartLine := movedLine. |
|
6351 | 1894 |
"/ with shift-click, take char before cursor pos |
1895 |
"/ with button motion, take char at cursor pos |
|
1896 |
self sensor shiftDown ifTrue:[ |
|
1897 |
selectionEndCol := clickStartCol-1. |
|
1898 |
] ifFalse:[ |
|
1899 |
selectionEndCol := clickStartCol. |
|
1900 |
]. |
|
5791 | 1901 |
selectionEndLine := clickStartLine. |
1902 |
selectStyle notNil ifTrue:[ |
|
1903 |
selectionEndCol := wordEndCol. |
|
1904 |
selectionEndLine := wordEndLine. |
|
1905 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1906 |
] ifFalse:[ |
6351 | 1907 |
"self forward" |
5791 | 1908 |
selectionEndCol := movedCol. |
1909 |
selectionEndLine := movedLine. |
|
1910 |
selectionStartCol := clickStartCol. |
|
1911 |
selectionStartLine := clickStartLine. |
|
1912 |
selectStyle notNil ifTrue:[ |
|
1913 |
selectionStartCol := wordStartCol. |
|
1914 |
selectionStartLine := wordStartLine. |
|
1915 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1916 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1917 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1918 |
selectionStartLine isNil ifTrue:[^ self]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1919 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1920 |
(selectionStartCol == 0) ifTrue:[ |
5791 | 1921 |
selectionStartCol := 1 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1922 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1923 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1924 |
" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1925 |
if in word-select, just catch the rest of the word |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1926 |
" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1927 |
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[ |
5791 | 1928 |
movedUp ifTrue:[ |
1929 |
selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol |
|
1930 |
] ifFalse:[ |
|
1931 |
selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol. |
|
1932 |
selectionEndCol == 0 ifTrue:[ |
|
1933 |
selectionEndLine := selectionEndLine + 1 |
|
1934 |
] |
|
1935 |
]. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1936 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1937 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1938 |
selectStyle == #line ifTrue:[ |
5791 | 1939 |
movedUp ifTrue:[ |
1940 |
selectionStartCol := 1. |
|
1941 |
] ifFalse:[ |
|
1942 |
selectionEndCol := 0. |
|
1943 |
selectionEndLine := selectionEndLine + 1 |
|
1944 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1945 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1946 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1947 |
self validateNewSelection. |
4885 | 1948 |
aBoolean ifTrue:[ |
5791 | 1949 |
self setPrimarySelection. |
1950 |
self selectionChanged. |
|
4885 | 1951 |
]. |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1952 |
|
4063 | 1953 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
1954 |
"/ self clearSearchAction. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1955 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1956 |
(oldStartLine == selectionStartLine) ifTrue:[ |
5791 | 1957 |
(oldStartCol ~~ selectionStartCol) ifTrue:[ |
1958 |
self |
|
1959 |
redrawLine:oldStartLine |
|
1960 |
from:((selectionStartCol min:oldStartCol) max:1) |
|
1961 |
to:((selectionStartCol max:oldStartCol) max:1) |
|
1962 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1963 |
] ifFalse:[ |
5791 | 1964 |
self |
1965 |
redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine) |
|
1966 |
to:(oldStartLine?selectionStartLine max:selectionStartLine) |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1967 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1968 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1969 |
(oldEndLine == selectionEndLine) ifTrue:[ |
5791 | 1970 |
(oldEndCol notNil and:[oldEndCol ~~ selectionEndCol]) ifTrue:[ |
1971 |
self redrawLine:oldEndLine |
|
1972 |
from:((selectionEndCol min:oldEndCol) max:1) |
|
1973 |
to:((selectionEndCol max:oldEndCol) max:1) |
|
1974 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1975 |
] ifFalse:[ |
5791 | 1976 |
selectionEndLine isNil ifTrue:[ |
1977 |
selectionStartLine := nil. |
|
1978 |
self redraw. |
|
1979 |
] ifFalse:[ |
|
1980 |
(selectionStartLine notNil) ifTrue:[ |
|
1981 |
self redrawFromLine:(oldEndLine min:selectionEndLine) |
|
1982 |
to:(oldEndLine max:selectionEndLine) |
|
1983 |
] |
|
1984 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1985 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1986 |
clickLine := movedLine. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1987 |
clickCol := movedCol |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1988 |
|
4234
65f202270d2c
changed: #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
4178
diff
changeset
|
1989 |
"Modified: / 05-04-2011 / 17:13:35 / cg" |
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
1990 |
"Modified: / 17-04-2012 / 21:00:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6351 | 1991 |
"Modified: / 15-06-2018 / 13:55:19 / Claus Gittinger" |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1992 |
! |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1993 |
|
248 | 1994 |
keyPress:key x:x y:y |
1995 |
"handle some keyboard input (there is not much to be done here)" |
|
1996 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1997 |
<resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain |
5791 | 1998 |
#GotoLine #SelectAll #SaveAs #Print |
6204 | 1999 |
#OpenWorkspaceOnIt |
5791 | 2000 |
#'F*' #'f*')> |
248 | 2001 |
|
2002 |
(key == #Find) ifTrue:[self search. ^self]. |
|
2003 |
(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
|
2004 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
248 | 2005 |
|
2006 |
(key == #FindNext) ifTrue:[self searchFwd. ^self]. |
|
2007 |
(key == #FindPrev) ifTrue:[self searchBwd. ^self]. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
2008 |
(key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self]. |
248 | 2009 |
|
2010 |
(key == #SelectAll) ifTrue:[self selectAll. ^self]. |
|
2011 |
||
614 | 2012 |
(key == #SaveAs) ifTrue:[self save. ^self]. |
2013 |
(key == #Print) ifTrue:[self doPrint. ^self]. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
2014 |
|
6204 | 2015 |
(key == #OpenWorkspaceOnIt) ifTrue:[self openWorkspaceWithIt. ^self]. |
2016 |
||
248 | 2017 |
" |
4500 | 2018 |
shift-Fn defines a key-sequence |
248 | 2019 |
Fn pastes that sequence |
2020 |
cmd-Fn performs a 'doIt' on the sequence (Workspaces only) |
|
2021 |
||
2022 |
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y) |
|
2023 |
" |
|
6292 | 2024 |
"/ do NOT replace by notEmptyOrNil !!!!!! |
2025 |
"/ key can be a character!!!!!!!! |
|
6553 | 2026 |
(key size ~~ 0 and:[(key at:1) asLowercase == $f]) ifTrue:[ |
5791 | 2027 |
(('[fF][0-9]' match:key) |
6140 | 2028 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
5791 | 2029 |
self sensor shiftDown ifTrue:[ |
2030 |
UserPreferences current functionKeySequences |
|
2031 |
at:key put:(self selection) |
|
2032 |
]. |
|
2033 |
^ self |
|
2034 |
]. |
|
248 | 2035 |
]. |
2036 |
||
2037 |
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
|
2038 |
|
6140 | 2039 |
"Modified (format): / 30-03-2017 / 22:35:58 / stefan" |
6204 | 2040 |
"Modified: / 01-09-2017 / 14:32:27 / cg" |
6292 | 2041 |
"Modified: / 09-03-2018 / 00:58:56 / mawalch" |
6553 | 2042 |
"Modified: / 01-03-2019 / 16:14:03 / Claus Gittinger" |
248 | 2043 |
! |
2044 |
||
4500 | 2045 |
mapped |
248 | 2046 |
super mapped. |
1987 | 2047 |
selectionFgColor := selectionFgColor onDevice:device. |
2048 |
selectionBgColor := selectionBgColor onDevice:device. |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2049 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2050 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2051 |
quadClickX:x y:y |
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
2052 |
"quadrupleClick-click - select all" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2053 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2054 |
self selectAll |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2055 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
2056 |
"Created: / 11.9.1997 / 04:15:24 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
2057 |
"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
|
2058 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2059 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2060 |
tripleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2061 |
"triple-click - select line under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2062 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2063 |
self selectLineAtY:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2064 |
selectStyle := #line |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2065 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
2066 |
"Created: 11.9.1997 / 04:13:37 / cg" |
0 | 2067 |
! ! |
248 | 2068 |
|
2120 | 2069 |
!TextView methodsFor:'initialization & release'! |
248 | 2070 |
|
941 | 2071 |
fetchDeviceResources |
2072 |
"fetch device colors, to avoid reallocation at redraw time" |
|
2073 |
||
2074 |
super fetchDeviceResources. |
|
2075 |
||
1987 | 2076 |
selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor onDevice:device]. |
2077 |
selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor onDevice:device]. |
|
941 | 2078 |
|
2079 |
"Created: 14.1.1997 / 00:14:33 / cg" |
|
2080 |
! |
|
2081 |
||
248 | 2082 |
initStyle |
966 | 2083 |
"setup viewStyle specifics" |
2084 |
||
248 | 2085 |
super initStyle. |
2086 |
||
2087 |
viewBackground := DefaultViewBackground. |
|
2088 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
2089 |
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor]. |
|
2090 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
2091 |
selectionBgColor isNil ifTrue:[ |
|
5791 | 2092 |
device hasColors ifTrue:[ |
2093 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
2094 |
selectionFgColor := fgColor |
|
2095 |
]. |
|
2096 |
selectionBgColor := Color green |
|
2097 |
] ifFalse:[ |
|
2098 |
device hasGrayscales ifTrue:[ |
|
2099 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
2100 |
selectionFgColor := fgColor |
|
2101 |
]. |
|
2102 |
selectionBgColor := Color gray |
|
2103 |
] ifFalse:[ |
|
2104 |
selectionBgColor := fgColor |
|
2105 |
] |
|
2106 |
] |
|
248 | 2107 |
]. |
708 | 2108 |
|
4321 | 2109 |
"Modified: / 22-01-1997 / 11:57:53 / cg" |
2110 |
"Modified (comment): / 05-10-2011 / 15:50:45 / az" |
|
248 | 2111 |
! |
2112 |
||
2113 |
initialize |
|
2114 |
super initialize. |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2115 |
self initializeSaveAction. |
248 | 2116 |
contentsWasSaved := false. |
2588 | 2117 |
dragIsActive := false. |
4864 | 2118 |
lastSearchWasMatch := lastSearchWasVariableSearch := false. |
2119 |
lastSearchIgnoredCase := true. |
|
248 | 2120 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2121 |
parenthesisSpecification isNil ifTrue:[ |
5791 | 2122 |
parenthesisSpecification := DefaultParenthesisSpecification. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2123 |
]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2124 |
|
911 | 2125 |
"I handle menus myself" |
2126 |
menuHolder := menuPerformer := self. |
|
2127 |
||
2588 | 2128 |
"/ on default allow drag |
2129 |
self allowDrag:true. |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2130 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2131 |
|
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2132 |
initializeSaveAction |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2133 |
saveAction := [ self openSaveDialog ] |
248 | 2134 |
! ! |
2135 |
||
4450 | 2136 |
!TextView methodsFor:'menu & menu actions'! |
248 | 2137 |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2138 |
appendTo:aFileName |
248 | 2139 |
"append contents to a file named fileName" |
2140 |
||
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2141 |
|aStream msg filename| |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2142 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2143 |
filename := aFileName asFilename. |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2144 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2145 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[ |
5791 | 2146 |
msg := resources string:'Refused to append to file ''%1'' !!' with:filename name. |
2147 |
self warn:(msg , '\\(ST/X internal permission check)' ) withCRs. |
|
2148 |
^ self |
|
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
2149 |
]. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
2150 |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2151 |
[ |
5791 | 2152 |
aStream := filename appendingWriteStream. |
2153 |
[ |
|
2154 |
self fileOutContentsOn:aStream compressTabs:true encoding:externalEncoding. |
|
2155 |
] ensure:[ |
|
2156 |
aStream close. |
|
2157 |
]. |
|
2158 |
contentsWasSaved := true |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2159 |
] on:FileStream openErrorSignal do:[:ex| |
5791 | 2160 |
msg := resources string:'cannot append to file %1 !!' with:filename name. |
2161 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
|
248 | 2162 |
] |
4437 | 2163 |
|
2164 |
"Modified: / 27-07-2012 / 09:41:18 / cg" |
|
248 | 2165 |
! |
2166 |
||
2167 |
changeFont |
|
2168 |
"pop up a fontPanel to change font" |
|
2169 |
||
5676 | 2170 |
|newFont fp userPrefs fontPrefs newFontPrefs| |
248 | 2171 |
|
5005 | 2172 |
self withWaitCursorDo:[ |
5791 | 2173 |
fp := FontPanel new. |
5902 | 2174 |
newFont := |
2175 |
fp fontFromUserInitial:gc font |
|
2176 |
title:nil |
|
2177 |
filter:nil |
|
2178 |
encoding:nil |
|
2179 |
enabled:true |
|
2180 |
withChangeAllOption:true. |
|
5005 | 2181 |
]. |
411 | 2182 |
newFont notNil ifTrue:[ |
5791 | 2183 |
self font:newFont. |
2184 |
fp changeFontInAllViews ifTrue:[ |
|
2185 |
"/ user checked this box - change the defaults, |
|
2186 |
"/ and update all other textviews now. |
|
2187 |
userPrefs := UserPreferences current. |
|
2188 |
fontPrefs := userPrefs fontPreferences. |
|
2189 |
fontPrefs isNil ifTrue:[ fontPrefs := newFontPrefs := Dictionary new ]. |
|
2190 |
||
6546 | 2191 |
fontPrefs at:#Text put:(newFont asFontDescription storeString). |
5791 | 2192 |
newFontPrefs notNil ifTrue:[ userPrefs fontPreferences:newFontPrefs ]. |
2193 |
userPrefs beModified. |
|
6547 | 2194 |
"/ FIXME: should we save the prefs automatically here? |
5914 | 2195 |
"/ DebugView newDebugger. |
5791 | 2196 |
TextView allSubInstances do:[:v | |
5912 | 2197 |
v class defaultFont:newFont. |
5791 | 2198 |
v font:newFont |
2199 |
]. |
|
2200 |
]. |
|
411 | 2201 |
] |
2202 |
||
6546 | 2203 |
"Modified: / 27-02-1996 / 00:53:51 / cg" |
6547 | 2204 |
"Modified (comment): / 01-03-2019 / 11:59:45 / Claus Gittinger" |
248 | 2205 |
! |
2206 |
||
6202 | 2207 |
compareAgainst:otherText named:whatIsIt |
2208 |
"common code for compate with file and compare with clipboard" |
|
2209 |
||
2210 |
|myText| |
|
2211 |
||
2212 |
otherText isEmptyOrNil ifTrue:[ |
|
6205 | 2213 |
Dialog information:(resources string:(whatIsIt,' is empty.')). "/ don't use %1 - may need different xlations |
6202 | 2214 |
^ self. |
2215 |
]. |
|
2216 |
||
2217 |
self hasSelection ifTrue:[ |
|
2218 |
myText := self selectionAsString. |
|
2219 |
] ifFalse:[ |
|
2220 |
myText := self contents asString |
|
2221 |
]. |
|
2222 |
myText := myText string. |
|
2223 |
||
2224 |
myText = otherText ifTrue:[ |
|
2225 |
Dialog information:(resources string:'Strings are equal.'). |
|
2226 |
^ self. |
|
2227 |
]. |
|
2228 |
DiffTextView |
|
2229 |
openOn:myText label:'Editor' |
|
2230 |
and:otherText label:whatIsIt |
|
2231 |
||
2232 |
"Created: / 01-09-2017 / 14:11:20 / cg" |
|
2233 |
! |
|
2234 |
||
2235 |
compareWithClipboard |
|
2236 |
"compare the selection against the clipboard contents" |
|
2237 |
||
2238 |
self compareAgainst:(self getClipboardText) named:'Clipboard' |
|
2239 |
||
2240 |
"Modified: / 01-09-2017 / 14:11:44 / cg" |
|
2241 |
! |
|
2242 |
||
2243 |
compareWithFile |
|
2244 |
"compare the selection or the whole text against the contents of a file" |
|
2245 |
||
2246 |
|fn fileText| |
|
2247 |
||
2248 |
fn := Dialog requestFileName:(resources string:'Compare against file:') |
|
2249 |
default:defaultFileNameForFileDialog. |
|
2250 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
2251 |
||
2252 |
fileText := fn asFilename contentsOfEntireFile. |
|
2253 |
self compareAgainst:fileText named:'File' |
|
2254 |
||
2255 |
"Modified: / 01-09-2017 / 14:11:15 / cg" |
|
2256 |
! |
|
2257 |
||
248 | 2258 |
copySelection |
2259 |
"copy contents into smalltalk copybuffer" |
|
2260 |
||
863 | 2261 |
|text| |
248 | 2262 |
|
2263 |
text := self selection. |
|
2264 |
text notNil ifTrue:[ |
|
5791 | 2265 |
self unselect. |
2266 |
||
2267 |
"/ forget any emphasis ... |
|
2268 |
text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]]. |
|
2269 |
self setClipboardText:text. |
|
248 | 2270 |
] |
649
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
2271 |
|
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
2272 |
"Modified: 17.5.1996 / 08:57:54 / cg" |
248 | 2273 |
! |
2274 |
||
6135 | 2275 |
copySelectionBox |
2276 |
"copy contents into the smalltalk copybuffer. |
|
2277 |
This copies it as a rectangular text area (INed/MAXed-like)" |
|
2278 |
||
2279 |
|text startCol endCol len| |
|
2280 |
||
2281 |
text := self selection. |
|
2282 |
text notNil ifTrue:[ |
|
2283 |
"/ forget any emphasis ... |
|
6206 | 2284 |
text := text collect:[:line | line isNil ifTrue:[''] ifFalse:[line string]]. |
6135 | 2285 |
|
2286 |
startCol := selectionStartCol. |
|
2287 |
endCol := selectionEndCol. |
|
2288 |
len := endCol - startCol + 1. |
|
2289 |
text := text keysAndValuesCollect:[:idx :line | |
|
2290 |
||
2291 |
idx == 1 ifTrue:[ |
|
2292 |
(line paddedTo:len) copyTo:len |
|
2293 |
] ifFalse:[ |
|
2294 |
(line paddedTo:startCol+len-1) copyFrom:startCol |
|
2295 |
]. |
|
2296 |
]. |
|
2297 |
self unselect. |
|
2298 |
self setClipboardText:text. |
|
2299 |
] |
|
2300 |
||
2301 |
"Created: / 14-03-2017 / 16:06:02 / cg" |
|
6206 | 2302 |
"Modified (format): / 01-09-2017 / 14:43:07 / cg" |
6135 | 2303 |
! |
2304 |
||
248 | 2305 |
defaultForGotoLine |
2306 |
"return a default value to show in the gotoLine box" |
|
2307 |
||
6294 | 2308 |
^ self selectionStartLine |
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
2309 |
|
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
2310 |
"Modified: 1.3.1996 / 18:44:36 / cg" |
248 | 2311 |
! |
2312 |
||
614 | 2313 |
doPrint |
2314 |
"print the contents on the printer" |
|
2315 |
||
2316 |
|printStream| |
|
2317 |
||
2318 |
list isNil ifTrue:[^ self]. |
|
2319 |
||
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2320 |
self withWaitCursorDo:[ |
5791 | 2321 |
printStream := Printer new. |
2322 |
printStream supportsContext ifTrue:[ |
|
2323 |
printStream printerContext font:(self font). |
|
2324 |
]. |
|
2325 |
||
2326 |
Printer writeErrorSignal handle:[:ex | |
|
2327 |
self warn:('error while printing:\\' |
|
2328 |
, ex description |
|
2329 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs |
|
2330 |
] do:[ |
|
2331 |
self fileOutContentsOn:printStream. |
|
2332 |
]. |
|
2333 |
printStream close |
|
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2334 |
]. |
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2335 |
|
4363 | 2336 |
"Created: / 06-05-1996 / 16:11:26 / cg" |
2337 |
"Modified: / 31-01-2012 / 18:16:39 / cg" |
|
614 | 2338 |
! |
2339 |
||
248 | 2340 |
editMenu |
1109 | 2341 |
"return my popUpMenu" |
2342 |
||
489 | 2343 |
<resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1255
diff
changeset
|
2344 |
<resource: #programMenu> |
489 | 2345 |
|
6375 | 2346 |
|item1 items m toolItems toolSubMenu| |
6135 | 2347 |
|
2348 |
self sensor metaDown ifTrue:[ |
|
2349 |
item1 := #( |
|
2350 |
('Copy Box' copySelectionBox CopyBox) |
|
2351 |
) |
|
2352 |
] ifFalse:[ |
|
2353 |
item1 := #( |
|
5791 | 2354 |
('Copy' copySelection Copy) |
6135 | 2355 |
) |
2356 |
]. |
|
2357 |
||
2358 |
items := item1 , #( |
|
5791 | 2359 |
('-' nil ) |
2360 |
('Search...' search Find) |
|
2361 |
('Goto Line...' gotoLine GotoLine) |
|
2362 |
('-' nil ) |
|
6375 | 2363 |
('Tools' tools ) |
5791 | 2364 |
('Font...' changeFont ) |
2365 |
('-' nil ) |
|
2366 |
('Save As...' save SaveAs) |
|
2367 |
('Print' doPrint Print) |
|
2368 |
). |
|
248 | 2369 |
|
6375 | 2370 |
toolItems := #( |
2371 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
2372 |
('Open WebBrowser on It' openWebBrowserOnIt ) |
|
2373 |
). |
|
2374 |
||
1545 | 2375 |
m := PopUpMenu itemList:items resources:resources. |
6375 | 2376 |
|
2377 |
toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model. |
|
2378 |
toolSubMenu receiver:self. |
|
2379 |
m subMenuAt:#tools put:toolSubMenu. |
|
6135 | 2380 |
|
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
2381 |
self hasSelectionForCopy ifFalse:[ |
5791 | 2382 |
m disable:#copySelection. |
6135 | 2383 |
m disable:#copySelectionBox. |
248 | 2384 |
]. |
6375 | 2385 |
self hasSelection ifFalse:[ |
2386 |
m disableAll:#(openFileBrowserOnIt openWebBrowserOnIt). |
|
2387 |
] ifTrue:[ |
|
2388 |
(Error handle:[:ex | |
|
2389 |
ex return:false |
|
2390 |
] do:[ |
|
2391 |
|fn| |
|
2392 |
fn := self selectionAsString withoutSeparators. |
|
2393 |
fn asFilename exists or:[ fn withoutQuotes asFilename exists ] |
|
2394 |
]) ifFalse:[ |
|
2395 |
m disableAll:#(openFileBrowserOnIt). |
|
2396 |
]. |
|
2397 |
(Error handle:[:ex | |
|
2398 |
ex return:false |
|
2399 |
] do:[ |
|
2400 |
|url| |
|
2401 |
url := self selectionAsString withoutSeparators. |
|
2402 |
#('http' 'https' 'ftp') includes:url asURL method |
|
2403 |
]) ifFalse:[ |
|
2404 |
m disableAll:#(openWebBrowserOnIt). |
|
2405 |
] |
|
2406 |
]. |
|
6146 | 2407 |
m := m asMenu. |
248 | 2408 |
^ m |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
2409 |
|
6146 | 2410 |
"Modified: / 12-04-2017 / 09:06:22 / cg" |
6375 | 2411 |
"Modified: / 06-07-2018 / 08:42:17 / Claus Gittinger" |
248 | 2412 |
! |
2413 |
||
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2414 |
find |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2415 |
"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
|
2416 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2417 |
self search |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2418 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2419 |
"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
|
2420 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2421 |
|
248 | 2422 |
gotoLine |
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
2423 |
"show a box to enter lineNumber for positioning; |
4500 | 2424 |
The entered number may be prefixed by a + or -; |
1926 | 2425 |
in this case, the linenumber is taken relative to the current position." |
2426 |
||
6140 | 2427 |
|l lineNumberBox input lineToGo relative peekc| |
248 | 2428 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2429 |
lineNumberBox := |
5791 | 2430 |
EnterBox |
2431 |
title:(resources string:'Line number (or +/- relativeNr):') |
|
2432 |
okText:(resources string:'Goto') |
|
2433 |
abortText:(resources string:'Cancel') |
|
6140 | 2434 |
action:[:l | input := l readStream]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2435 |
|
248 | 2436 |
l := self defaultForGotoLine. |
6140 | 2437 |
lineNumberBox initialText:(l ifNotNil:[l printString]). |
3394 | 2438 |
lineNumberBox label:(resources string:'Goto Line'). |
1380 | 2439 |
lineNumberBox showAtPointer. |
2440 |
||
6140 | 2441 |
input isNil ifTrue:[ |
2442 |
^ self. |
|
2443 |
]. |
|
2444 |
||
2445 |
peekc := input skipSpaces. |
|
2446 |
peekc notNil ifTrue:[ |
|
2447 |
(peekc == $+) ifTrue:[ |
|
2448 |
relative := 1. |
|
2449 |
] ifFalse:[ |
|
2450 |
(peekc == $-) ifTrue:[ |
|
2451 |
relative := -1. |
|
5791 | 2452 |
]. |
6140 | 2453 |
]. |
2454 |
relative notNil ifTrue:[ |
|
2455 |
input next. |
|
2456 |
]. |
|
2457 |
lineToGo := Integer readFrom:input onError:[^ self]. |
|
2458 |
relative notNil ifTrue:[ |
|
2459 |
lineToGo := self currentLine + (lineToGo * relative) |
|
2460 |
]. |
|
2461 |
self gotoLine:lineToGo. |
|
1380 | 2462 |
]. |
2463 |
||
6140 | 2464 |
"Modified: / 17-05-1998 / 20:07:59 / cg" |
2465 |
"Modified: / 30-03-2017 / 23:05:07 / stefan" |
|
248 | 2466 |
! |
2467 |
||
6202 | 2468 |
openFileBrowserOnFileNamed:fileNameString |
2469 |
"open a fileBrowser on the given fileNameString" |
|
2470 |
||
2471 |
|fn| |
|
2472 |
||
2473 |
fn := fileNameString asFilename. |
|
2474 |
fn exists ifFalse:[ |
|
2475 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
|
2476 |
fn exists ifFalse:[ |
|
2477 |
^ self warn:(resources |
|
2478 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
2479 |
with:fn baseName allBold |
|
2480 |
with:fn directory baseName allBold). |
|
2481 |
]. |
|
2482 |
]. |
|
2483 |
FileBrowser default openOn:fn |
|
2484 |
||
2485 |
"Modified: / 01-09-2017 / 14:03:54 / cg" |
|
2486 |
! |
|
2487 |
||
2488 |
openFileBrowserOnIt |
|
2489 |
"open a fileBrowser on the selected fileName" |
|
2490 |
||
2491 |
|fileNameString| |
|
2492 |
||
6373 | 2493 |
fileNameString := self selectionAsString withoutSeparators. |
6202 | 2494 |
self openFileBrowserOnFileNamed:fileNameString |
2495 |
||
2496 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
6373 | 2497 |
"Modified: / 06-07-2018 / 07:30:20 / Claus Gittinger" |
6202 | 2498 |
! |
2499 |
||
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2500 |
openSaveDialog |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2501 |
"Ask user for filename using a fileSelectionBox |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2502 |
and save contents into that file." |
248 | 2503 |
|
2695
7e13db2802df
better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents:
2693
diff
changeset
|
2504 |
Dialog |
5791 | 2505 |
requestSaveFileName:(resources string:'Save contents in:') |
2506 |
default:defaultFileNameForFileDialog |
|
2507 |
fromDirectory:directoryForFileDialog |
|
2508 |
action:[:fileName | self saveAs:fileName] |
|
2509 |
appendAction:[:fileName | self appendTo:fileName] |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2510 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2511 |
|
4399 | 2512 |
openSearchBoxAndSearch |
5736 | 2513 |
"search for a string - show a box to enter searchpattern. |
2514 |
TODO: this started as an ad-hoc box, which is manually constructed. |
|
2515 |
over time, it got more and more functions, so a separate appModel class |
|
2516 |
would no be appropriate..." |
|
4399 | 2517 |
|
6324 | 2518 |
^ self openSearchBoxAndSearchWithReplaceChecked:false |
2519 |
||
2520 |
"Modified: / 11-07-2006 / 11:18:38 / fm" |
|
2521 |
"Created: / 08-03-2012 / 14:02:59 / cg" |
|
2522 |
"Modified: / 22-05-2018 / 15:48:41 / Claus Gittinger" |
|
2523 |
! |
|
2524 |
||
2525 |
openSearchBoxAndSearchWithReplaceChecked:replaceChecked |
|
2526 |
"search for a string - show a box to enter searchpattern and replace options. |
|
2527 |
If replaceChecked is true, the 'replace' checkbox and 'replace to end' are |
|
2528 |
initially checked, and the focus is on the replace field. |
|
2529 |
TODO: this started as an ad-hoc box, which is manually constructed. |
|
2530 |
over time, it got more and more functions, so a separate appModel class |
|
2531 |
would now be appropriate..." |
|
2532 |
||
4399 | 2533 |
" |
4985 | 2534 |
Q: is it a good idea to preserve the last searchstring between views? |
2535 |
cg: yes - turns out to be useful and less confusing than keeping last per view |
|
4399 | 2536 |
" |
5547 | 2537 |
|searchBox patternHolder caseHolder matchHolder matchWithRegexHolder wrapAtEndHolder |
6378 | 2538 |
fwd last ign match initialString |
5757 | 2539 |
bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder selectLinesHolder |
5077 | 2540 |
replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder |
5556 | 2541 |
replaceAllBooleanHolder replacePreserveCaseBooleanHolder |
6428 | 2542 |
searchAtBeginOfLineOnlyHolder searchAtEndOfLineOnlyHolder updateReturnKeyBehavior| |
4399 | 2543 |
|
2544 |
searchBarActionBlock notNil ifTrue:[ |
|
5791 | 2545 |
self resetVariablesBeforeNewSearch. |
2546 |
searchBarActionBlock value:#search value:self. |
|
2547 |
^ self |
|
4399 | 2548 |
]. |
2549 |
||
5734 | 2550 |
modal := (UserPreferences current searchDialogIsModal). "/ that's experimental |
2551 |
||
2552 |
(searchBox := self objectAttributeAt:#currentModelessSearchBox) notNil ifTrue:[ |
|
5791 | 2553 |
(modal not |
2554 |
and:[ searchBox window realized ]) ifTrue:[ |
|
2555 |
"/ reuse it. |
|
2556 |
searchBox window |
|
2557 |
raiseDeiconified; |
|
2558 |
requestFocus; |
|
2559 |
assignKeyboardFocusToFirstKeyboardConsumer. |
|
2560 |
^ self. |
|
2561 |
]. |
|
2562 |
searchBox closeRequest. |
|
5734 | 2563 |
]. |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
2564 |
|
4864 | 2565 |
ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true. |
6324 | 2566 |
replaceChecked ifTrue:[ign := false]. |
4399 | 2567 |
caseHolder := ign not asValue. |
2568 |
||
2569 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
|
2570 |
matchHolder := match asValue. |
|
5543 | 2571 |
matchWithRegexHolder := (LastSearchWasMatchWithRegex ? false) asValue. |
5547 | 2572 |
wrapAtEndHolder := (LastSearchWasWrapAtEndOfText ? false) asValue. |
4399 | 2573 |
searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue. |
6324 | 2574 |
searchFullWordHolder := replaceChecked asValue. |
5077 | 2575 |
searchAtBeginOfLineOnlyHolder := false asValue. |
6428 | 2576 |
searchAtEndOfLineOnlyHolder := false asValue. |
5757 | 2577 |
selectLinesHolder := false asValue. |
6324 | 2578 |
replaceBooleanHolder := replaceChecked asValue. |
2579 |
replaceAllBooleanHolder := replaceChecked asValue. |
|
5556 | 2580 |
replacePreserveCaseBooleanHolder := false asValue. |
5555 | 2581 |
replaceTextHolder := (LastSearchReplacedString ? '') asValue. |
4485 | 2582 |
replaceBooleanEnabledHolder := self isReadOnly not asValue. |
4399 | 2583 |
|
2584 |
patternHolder := '' asValue. |
|
2585 |
||
2586 |
self setSearchPatternWithMatchEscapes: match. |
|
2587 |
||
2588 |
lastSearchPattern notNil ifTrue:[ |
|
5791 | 2589 |
initialString := lastSearchPattern. |
4399 | 2590 |
]. |
6324 | 2591 |
"/ No longer force the current selection to be the initialString |
2592 |
"/ self hasSelectionWithinSingleLine ifTrue:[ |
|
2593 |
"/ initialString := self selection asString. |
|
2594 |
"/ ]. |
|
4399 | 2595 |
initialString isNil ifTrue:[ |
6553 | 2596 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
5791 | 2597 |
initialString := LastSearchPatterns first. |
2598 |
] |
|
4399 | 2599 |
]. |
2600 |
||
2601 |
initialString notNil ifTrue:[ |
|
5791 | 2602 |
patternHolder value:initialString. |
4399 | 2603 |
]. |
2604 |
||
4500 | 2605 |
fwd := true. |
6378 | 2606 |
last := false. |
2607 |
||
2608 |
doSearch := [:fwdOrLast | |
|
2609 |
|isVariableSearch pattern searchAction fwd last| |
|
2610 |
||
2611 |
fwdOrLast == #last ifTrue:[ |
|
2612 |
fwd := last := true. |
|
2613 |
] ifFalse:[ |
|
2614 |
fwd := fwdOrLast. |
|
2615 |
last := false |
|
2616 |
]. |
|
2617 |
||
5791 | 2618 |
self resetVariablesBeforeNewSearch. |
2619 |
||
2620 |
isVariableSearch := self searchVariableVisible |
|
2621 |
and:[searchVariableHolder value |
|
2622 |
and:[selectedVariable notNil]]. |
|
2623 |
||
2624 |
isVariableSearch ifTrue:[ |
|
2625 |
searchAction := |
|
2626 |
[ |
|
2627 |
self searchVariableWithSyntaxElement:selectedVariable forward:fwd |
|
2628 |
]. |
|
2629 |
] ifFalse:[ |
|
2630 |
lastSearchWasVariableSearch := false. |
|
2631 |
LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not). |
|
2632 |
LastSearchWasMatch := lastSearchWasMatch := matchHolder value. |
|
2633 |
LastSearchWasMatchWithRegex := matchWithRegexHolder value. |
|
2634 |
LastSearchWasWrapAtEndOfText := wrapAtEndHolder value. |
|
2635 |
LastSearchWasReplace :=replaceBooleanHolder value. |
|
2636 |
LastSearchReplacedString := replaceTextHolder value. |
|
2637 |
||
2638 |
pattern := patternHolder value. |
|
2639 |
pattern notEmptyOrNil ifTrue:[ |
|
2640 |
searchAction := |
|
2641 |
[ |
|
2642 |
self searchUsingSpec:( |
|
2643 |
self class searchSpec new |
|
2644 |
pattern:pattern |
|
2645 |
ignoreCase:lastSearchIgnoredCase |
|
2646 |
match: lastSearchWasMatch |
|
2647 |
regexMatch:matchWithRegexHolder value |
|
2648 |
variable: searchVariableHolder value |
|
2649 |
fullWord: searchFullWordHolder value |
|
2650 |
forward:fwd |
|
2651 |
atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value |
|
6428 | 2652 |
wrapAtEnd:wrapAtEndHolder value; |
2653 |
atEndOfLineOnly:searchAtEndOfLineOnlyHolder value). |
|
5791 | 2654 |
] |
2655 |
] |
|
2656 |
]. |
|
2657 |
||
2658 |
replaceBooleanHolder value ifTrue:[ |
|
2659 |
|selStart replacement replaceAction| |
|
2660 |
||
2661 |
replacement := replaceTextHolder value. |
|
2662 |
isVariableSearch ifTrue:[ |
|
2663 |
"/ must replace from the end towards beginning, |
|
2664 |
"/ because syntax-elements do not update their position, when |
|
2665 |
"/ the text is changed (in replace). |
|
2666 |
||
2667 |
selectedVariable := selectedVariable lastElementInChain. |
|
2668 |
self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop. |
|
2669 |
searchAction := |
|
2670 |
[ |
|
2671 |
selectedVariable := selectedVariable previousElement. |
|
2672 |
selectedVariable notNil ifTrue:[ |
|
2673 |
self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop. |
|
2674 |
]. |
|
2675 |
"/ self searchVariableWithSyntaxElement:selectedVariable forward:false |
|
2676 |
]. |
|
2677 |
]. |
|
2678 |
||
2679 |
replaceAction := [ self replace:replacement ]. "/ not implemented here, but in subclasses |
|
2680 |
replacePreserveCaseBooleanHolder value ifTrue:[ |
|
2681 |
replaceAction := [ |
|
2682 |
self selectionAsString isUppercaseFirst ifTrue:[ |
|
2683 |
self replace:replacement asUppercaseFirst |
|
2684 |
] ifFalse:[ |
|
2685 |
self replace:replacement asLowercaseFirst |
|
2686 |
] |
|
2687 |
]. |
|
2688 |
]. |
|
2689 |
||
2690 |
selStart := self characterPositionOfSelection. |
|
2691 |
||
2692 |
replaceAction value. |
|
2693 |
searchAction value. |
|
2694 |
||
2695 |
replaceAllBooleanHolder value ifTrue:[ |
|
2696 |
[self characterPositionOfSelection ~= selStart] whileTrue:[ |
|
2697 |
selStart := self characterPositionOfSelection. |
|
2698 |
replaceAction value. |
|
2699 |
searchAction value. |
|
2700 |
] |
|
2701 |
] |
|
2702 |
] ifFalse:[ |
|
6378 | 2703 |
|selStart| |
2704 |
||
2705 |
selStart := self characterPositionOfSelection. |
|
5791 | 2706 |
searchAction value. |
6378 | 2707 |
last ifTrue:[ |
2708 |
[ |
|
2709 |
self characterPositionOfSelection ~= selStart] whileTrue:[ |
|
2710 |
selStart := self characterPositionOfSelection. |
|
2711 |
searchAction value. |
|
2712 |
]. |
|
2713 |
]. |
|
5791 | 2714 |
]. |
4399 | 2715 |
]. |
2716 |
||
2717 |
bindings := IdentityDictionary new. |
|
2718 |
bindings at:#searchPattern put:patternHolder. |
|
2719 |
modal ifTrue:[ |
|
5791 | 2720 |
bindings |
6378 | 2721 |
at:#lastAction |
2722 |
put:[ |
|
2723 |
replaceAllBooleanHolder value ifTrue:[ |
|
2724 |
fwd := #last. searchBox doAccept. |
|
2725 |
searchBox doAccept. |
|
2726 |
] ifFalse:[ |
|
2727 |
doSearch value:#last |
|
2728 |
] |
|
2729 |
]. |
|
2730 |
bindings |
|
5791 | 2731 |
at:#nextAction |
2732 |
put:[ |
|
2733 |
replaceAllBooleanHolder value ifTrue:[ |
|
2734 |
searchBox doAccept. |
|
2735 |
] ifFalse:[ |
|
2736 |
doSearch value:true |
|
2737 |
] |
|
2738 |
]. |
|
2739 |
bindings |
|
2740 |
at:#prevAction |
|
2741 |
put:[ |
|
2742 |
replaceAllBooleanHolder value ifTrue:[ |
|
2743 |
fwd := false. searchBox doAccept. |
|
2744 |
] ifFalse:[ |
|
2745 |
doSearch value:false |
|
2746 |
] |
|
2747 |
]. |
|
4399 | 2748 |
] ifFalse:[ |
5791 | 2749 |
bindings at:#nextAction put:[doSearch value:true.]. |
2750 |
bindings at:#prevAction put:[doSearch value:false.]. |
|
4399 | 2751 |
]. |
2752 |
bindings at:#caseSensitive put:caseHolder. |
|
2753 |
bindings at:#match put:matchHolder. |
|
5543 | 2754 |
bindings at:#matchWithRegex put:matchWithRegexHolder. |
5547 | 2755 |
Regex::RxMatcher isNil ifTrue:[ |
5791 | 2756 |
bindings at:#matchWithRegexVisible put:false. |
5547 | 2757 |
] ifFalse:[ |
5791 | 2758 |
bindings at:#matchWithRegexVisible put:matchHolder |
5547 | 2759 |
]. |
4399 | 2760 |
bindings at:#patternList put:LastSearchPatterns. |
2761 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2762 |
self supportsSyntaxElements ifFalse:[ |
5791 | 2763 |
bindings at:#searchVariableVisible put:false. |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2764 |
] ifTrue:[ |
5791 | 2765 |
bindings at:#searchVariableVisible put:true. |
2766 |
selectedVariable := self syntaxElementForSelectedVariable. |
|
2767 |
bindings at:#searchVariableEnabled put:(selectedVariable notNil). |
|
2768 |
selectedVariable notNil ifTrue:[ |
|
2769 |
bindings |
|
2770 |
at:#stringWithVariableUnderCursorHolder |
|
2771 |
put:(resources string:'Variable ("%1")' with:selectedVariable name). |
|
2772 |
"/ searchVariableHolder value:true. |
|
2773 |
] ifFalse:[ |
|
2774 |
bindings |
|
2775 |
at:#stringWithVariableUnderCursorHolder |
|
2776 |
put:(resources string:'Variable (none selected)'). |
|
2777 |
]. |
|
4399 | 2778 |
]. |
2779 |
bindings at:#searchVariable put:searchVariableHolder. |
|
4485 | 2780 |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2781 |
bindings at:#searchFullWord put:searchFullWordHolder. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2782 |
bindings at:#searchFullWordEnabled put:true. |
5077 | 2783 |
bindings at:#searchAtBeginOfLineOnly put:searchAtBeginOfLineOnlyHolder. |
6428 | 2784 |
bindings at:#searchAtEndOfLineOnly put:searchAtEndOfLineOnlyHolder. |
5547 | 2785 |
bindings at:#wrapAtEndOfTextHolder put:wrapAtEndHolder. |
5757 | 2786 |
bindings at:#selectLinesHolder put:selectLinesHolder. |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
2787 |
|
6428 | 2788 |
bindings at:#atEndOfLineOnlyEnabled put:(BlockValue forLogicalNot:matchHolder). |
2789 |
||
4485 | 2790 |
bindings at:#replaceEnabled put:replaceBooleanEnabledHolder. |
2791 |
bindings at:#replaceBoolean put:replaceBooleanHolder. |
|
5554 | 2792 |
bindings at:#replaceAllBoolean put:replaceAllBooleanHolder. |
5556 | 2793 |
bindings at:#replacePreserveCaseBoolean put:replacePreserveCaseBooleanHolder. |
4485 | 2794 |
bindings at:#replaceTextHolder put:replaceTextHolder. |
5555 | 2795 |
|
6256 | 2796 |
bindings at:#helpSpec put:self class helpSpec. |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
2797 |
|
5555 | 2798 |
updateReturnKeyBehavior := |
5791 | 2799 |
[ |
2800 |
|lbl returnAction| |
|
2801 |
||
2802 |
"/ when replacing, do not close box on return |
|
2803 |
replaceBooleanHolder value ifTrue:[ |
|
2804 |
lbl := 'Close'. |
|
2805 |
returnAction := searchAction. |
|
2806 |
] ifFalse:[ |
|
2807 |
lbl := 'Cancel'. |
|
2808 |
returnAction := nil. |
|
2809 |
]. |
|
2810 |
(bldr componentAt:#cancelButton) label:(resources string:lbl). |
|
2811 |
searchBox window keyboardProcessor returnAction:returnAction. |
|
2812 |
]. |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
2813 |
|
5010 | 2814 |
replaceBooleanHolder onChangeEvaluate: |
5791 | 2815 |
[ |
2816 |
replaceBooleanHolder value ifTrue:[ |
|
2817 |
(bldr componentAt:#ReplaceEntryField) requestFocus |
|
2818 |
] ifFalse:[ |
|
2819 |
(bldr componentAt:#patternComboBox) requestFocus |
|
2820 |
]. |
|
2821 |
updateReturnKeyBehavior value. |
|
2822 |
]. |
|
5555 | 2823 |
|
4399 | 2824 |
modal ifTrue:[ |
5791 | 2825 |
searchBox := SimpleDialog new. |
4399 | 2826 |
] ifFalse:[ |
5791 | 2827 |
searchBox := ApplicationModel new. |
2828 |
searchBox createBuilder. |
|
2829 |
bindings at:#cancel put:[ searchBox closeRequest ]. |
|
4399 | 2830 |
]. |
2831 |
searchBox resources:(self resources). |
|
2832 |
||
2833 |
bldr := searchBox builder. |
|
2834 |
bldr addBindings:bindings. |
|
6256 | 2835 |
bldr aspectAt:#helpSpec put:(self class helpSpec). |
4399 | 2836 |
searchBox allButOpenFrom:(self class searchDialogSpec). |
2837 |
||
6324 | 2838 |
replaceChecked ifTrue:[ |
2839 |
bldr window label:'String search & replace'. |
|
2840 |
bldr keyboardProcessor componentWithInitialFocus:(bldr componentAt:#ReplaceEntryField). |
|
2841 |
]. |
|
2842 |
||
4399 | 2843 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
6378 | 2844 |
(bldr componentAt:#lastButton) cursor:(Cursor thumbsUp). |
4399 | 2845 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
2846 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
2847 |
||
2848 |
modal ifTrue:[ |
|
5791 | 2849 |
updateReturnKeyBehavior value. |
2850 |
searchBox openDialogAtPointer. |
|
2851 |
searchBox accepted ifTrue:[ doSearch value:fwd ]. |
|
4399 | 2852 |
] ifFalse:[ |
5791 | 2853 |
(bldr componentAt:#nextButton) isReturnButton:false. |
2854 |
(bldr componentAt:#cancelButton) |
|
2855 |
label:(resources string:'Close'); |
|
2856 |
action:[searchBox closeRequest]. |
|
2857 |
"/ searchBox masterApplication:self application. |
|
2858 |
self topView beMaster. |
|
2859 |
searchBox window |
|
2860 |
beSlave; |
|
2861 |
openInGroup:(self windowGroup); |
|
2862 |
waitUntilVisible; |
|
2863 |
assignKeyboardFocusToFirstKeyboardConsumer. |
|
2864 |
searchBox window keyboardProcessor |
|
2865 |
addAccelerator:#Return action:(bindings at:#nextAction); |
|
2866 |
addAccelerator:#Escape action:#closeRequest. |
|
2867 |
"/ remember this box for me. |
|
2868 |
self objectAttributeAt:#currentModelessSearchBox put:searchBox. |
|
4399 | 2869 |
] |
2870 |
||
6324 | 2871 |
"Created: / 22-05-2018 / 15:47:29 / Claus Gittinger" |
6553 | 2872 |
"Modified: / 01-03-2019 / 16:14:14 / Claus Gittinger" |
4399 | 2873 |
! |
2874 |
||
6358 | 2875 |
openWebBrowserOnIt |
2876 |
"open a webBrowser on the selected url" |
|
2877 |
||
2878 |
|urlString| |
|
2879 |
||
6373 | 2880 |
urlString := self selectionAsString withoutSeparators. |
2881 |
OperatingSystem |
|
2882 |
openApplicationForDocument:urlString |
|
2883 |
operation:#open |
|
2884 |
mimeType:'text/html'. |
|
6358 | 2885 |
|
2886 |
"Created: / 21-06-2018 / 17:15:27 / Claus Gittinger" |
|
6373 | 2887 |
"Modified (format): / 06-07-2018 / 07:29:19 / Claus Gittinger" |
6358 | 2888 |
! |
2889 |
||
6202 | 2890 |
openWorkspaceWithIt |
2891 |
"open a workspace containing the selected text" |
|
2892 |
||
2893 |
|text| |
|
2894 |
||
2895 |
text := self selectionAsString. |
|
2896 |
WorkspaceApplication openWith:text selected:true |
|
2897 |
||
2898 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
|
2899 |
! |
|
2900 |
||
5757 | 2901 |
replace:someText |
2902 |
"replace the selection by someText. I am readonly, so this is a no-op here. |
|
2903 |
Subclasses may redefine me." |
|
2904 |
||
2905 |
^ self. |
|
2906 |
! |
|
2907 |
||
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2908 |
save |
4500 | 2909 |
"save contents into a file |
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2910 |
- ask user for filename using a fileSelectionBox." |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2911 |
|
3201 | 2912 |
saveAction value |
248 | 2913 |
! |
2914 |
||
2915 |
saveAs:fileName |
|
5113 | 2916 |
"save the contents into a file named fileName. |
2917 |
On error return false otherwise return true" |
|
4500 | 2918 |
|
2488 | 2919 |
^ self saveAs:fileName doAppend:false |
2920 |
! |
|
2921 |
||
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2922 |
saveAs:aFilename doAppend:doAppend |
2488 | 2923 |
"save the contents into a file named fileName; |
5113 | 2924 |
if doAppend is true, the view's contents is appended to the existing |
2834 | 2925 |
contents - otherwise, it overwrites any previous file contents. |
5113 | 2926 |
On error return false otherwise return true" |
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2927 |
|
4534 | 2928 |
^ self saveAs:aFilename doAppend:doAppend compressTabs:true |
2929 |
! |
|
2930 |
||
2931 |
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs |
|
2932 |
"save the contents into a file named fileName; |
|
5113 | 2933 |
if doAppend is true, the view's contents is appended to the existing |
4534 | 2934 |
contents - otherwise, it overwrites any previous file contents. |
5113 | 2935 |
On error return false otherwise return true" |
2936 |
||
2937 |
^ self saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:nil |
|
2938 |
! |
|
2939 |
||
2940 |
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:eolMode |
|
2941 |
"save the contents into a file named fileName; |
|
2942 |
if doAppend is true, the view's contents is appended to the existing |
|
2943 |
contents - otherwise, it overwrites any previous file contents. |
|
2944 |
eolMode is one of #cr, #nl or #crlf. |
|
2945 |
On error return false otherwise return true." |
|
4534 | 2946 |
|
3426 | 2947 |
|filename msg| |
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2948 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2949 |
filename := aFilename asFilename. |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2950 |
|
4437 | 2951 |
self withWriteCursorDo:[ |
5791 | 2952 |
|aStream| |
2953 |
||
2954 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[ |
|
2955 |
msg := resources |
|
2956 |
stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)' |
|
2957 |
with:filename name. |
|
2958 |
] ifTrue:[ |
|
2959 |
[ |
|
2960 |
doAppend ifTrue:[ |
|
2961 |
aStream := filename appendingWriteStream. |
|
2962 |
] ifFalse:[ |
|
2963 |
UserPreferences current generateBackupFileWhenSaving ifTrue:[ |
|
2964 |
filename exists ifTrue:[ |
|
6084 | 2965 |
filename moveTo:filename asBackupFilename. |
5791 | 2966 |
]. |
2967 |
]. |
|
2968 |
aStream := filename newReadWriteStream. |
|
2969 |
]. |
|
2970 |
aStream eolMode:eolMode. |
|
2971 |
self fileOutContentsOn:aStream compressTabs:compressTabs encoding:externalEncoding. |
|
2972 |
aStream syncData; close. |
|
2973 |
contentsWasSaved := true. |
|
2974 |
defaultFileNameForFileDialog := filename. |
|
2975 |
] on:FileStream openErrorSignal do:[:ex| |
|
2976 |
msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)' |
|
2977 |
with:filename name |
|
2978 |
with:FileStream lastErrorString. |
|
2979 |
]. |
|
2980 |
]. |
|
2834 | 2981 |
]. |
3426 | 2982 |
|
2983 |
msg notNil ifTrue:[ |
|
5791 | 2984 |
Dialog warn:msg. |
2985 |
^ false |
|
3426 | 2986 |
]. |
2834 | 2987 |
^ true |
916
4201c9c2a4f0
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
2988 |
|
4437 | 2989 |
"Modified: / 27-07-2012 / 09:45:13 / cg" |
6084 | 2990 |
"Modified: / 09-02-2017 / 13:30:41 / stefan" |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2991 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2992 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2993 |
search |
4500 | 2994 |
"search for a string - show a box to enter searchpattern |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2995 |
- 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
|
2996 |
|
4399 | 2997 |
self openSearchBoxAndSearch |
3318 | 2998 |
|
2999 |
"Modified: / 11-07-2006 / 11:18:38 / fm" |
|
4399 | 3000 |
"Modified: / 08-03-2012 / 14:03:10 / cg" |
3318 | 3001 |
! |
3002 |
||
4500 | 3003 |
search:patternArg ignoreCase:ign forward:fwd |
3577 | 3004 |
"search for a string without matching" |
3005 |
||
4500 | 3006 |
self search:patternArg ignoreCase:ign match: false forward:fwd |
3577 | 3007 |
! |
3008 |
||
4500 | 3009 |
search:patternArg ignoreCase:ign match: match forward:fwd |
3318 | 3010 |
|pattern| |
3011 |
||
3012 |
pattern := patternArg string. |
|
3013 |
pattern notEmpty ifTrue:[ |
|
5791 | 3014 |
self rememberSearchPattern:pattern. |
3015 |
"/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign. |
|
3016 |
"/ LastSearchWasMatch := match. |
|
3017 |
fwd ifFalse:[ |
|
3018 |
lastSearchDirection := #backward. |
|
3019 |
self searchBwd:pattern ignoreCase:ign match: match. " backward search with match is not yet available " |
|
3020 |
] ifTrue:[ |
|
3021 |
lastSearchDirection := #forward. |
|
3022 |
self searchFwd:pattern ignoreCase:ign match: match. |
|
3023 |
] |
|
3318 | 3024 |
] |
3025 |
||
3026 |
"Created: / 11-07-2006 / 11:18:04 / fm" |
|
4408 | 3027 |
"Modified: / 23-03-2012 / 12:12:07 / cg" |
4399 | 3028 |
! |
3029 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3030 |
searchUsingSpec:aSearchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3031 |
self rememberSearchPattern:(aSearchSpec pattern). |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3032 |
"/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3033 |
"/ LastSearchWasMatch := match. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3034 |
aSearchSpec forward ifFalse:[ |
5791 | 3035 |
lastSearchDirection := #backward. |
3036 |
self searchBwdUsingSpec:aSearchSpec |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3037 |
] ifTrue:[ |
5791 | 3038 |
lastSearchDirection := #forward. |
3039 |
self searchFwdUsingSpec:aSearchSpec |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3040 |
] |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3041 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3042 |
"Created: / 11-07-2006 / 11:18:04 / fm" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3043 |
"Modified: / 23-03-2012 / 12:12:07 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3044 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3045 |
|
4399 | 3046 |
searchVariableVisible |
3047 |
"search variable option in searchbox visible? |
|
3048 |
(only true for codeview2's textview)" |
|
3049 |
||
3050 |
^ false |
|
3051 |
||
3052 |
"Created: / 08-03-2012 / 14:01:24 / cg" |
|
3053 |
! |
|
3054 |
||
3055 |
searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd |
|
4485 | 3056 |
"this only works for CodeView2::TextView, which supports syntaxElements. |
3057 |
Finds the next occurrence of a syntax element (typically, a variable)" |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3058 |
|
4409 | 3059 |
|el el2| |
4399 | 3060 |
|
3061 |
lastSearchWasVariableSearch := true. |
|
4500 | 3062 |
el := fwd |
5791 | 3063 |
ifTrue:[syntaxElementForVariable nextElement] |
3064 |
ifFalse:[syntaxElementForVariable previousElement]. |
|
4399 | 3065 |
|
3066 |
el notNil ifTrue:[ |
|
5791 | 3067 |
"bug workaround" |
3068 |
(el start = syntaxElementForVariable start) ifTrue:[ |
|
3069 |
el2 := fwd |
|
3070 |
ifTrue:[el nextElement] |
|
3071 |
ifFalse:[el previousElement]. |
|
3072 |
el2 notNil ifTrue:[ |
|
3073 |
el := el2 |
|
3074 |
] |
|
3075 |
]. |
|
4399 | 3076 |
]. |
3077 |
el notNil ifTrue:[ |
|
5791 | 3078 |
self selectFromCharacterPosition:el start to:el stop. |
3079 |
self makeLineVisible:(self lineOfCharacterPosition:el start). |
|
4399 | 3080 |
] ifFalse:[ |
5791 | 3081 |
self showNotFound |
4399 | 3082 |
]. |
3083 |
||
3084 |
"Created: / 08-03-2012 / 14:08:20 / cg" |
|
3085 |
! |
|
3086 |
||
3087 |
syntaxElementForSelectedVariable |
|
3088 |
"for a better search; ignored here, but redefined in CodeView2" |
|
3089 |
||
3090 |
^ nil |
|
3091 |
||
3092 |
"Created: / 08-03-2012 / 14:20:27 / cg" |
|
3093 |
! |
|
3094 |
||
3095 |
syntaxElementForVariableUnderCursor |
|
3096 |
"for a better search; ignored here, but redefined in CodeView2" |
|
3097 |
||
3098 |
^ nil |
|
3099 |
||
3100 |
"Created: / 08-03-2012 / 12:45:26 / cg" |
|
248 | 3101 |
! ! |
3102 |
||
5120 | 3103 |
!TextView methodsFor:'native widget support'! |
3104 |
||
3105 |
nativeWindowType |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3106 |
"return a symbol describing my native window type |
5543 | 3107 |
(may be used internally by the device as a native window creation hint, |
3108 |
if the device supports native windows)" |
|
5120 | 3109 |
|
3110 |
^ #TextView |
|
3111 |
||
3112 |
"Created: 2.5.1997 / 14:41:00 / cg" |
|
3113 |
! ! |
|
3114 |
||
248 | 3115 |
!TextView methodsFor:'private'! |
3116 |
||
2596 | 3117 |
currentSelectionBgColor |
3118 |
^ selectionBgColor |
|
3119 |
! |
|
3120 |
||
3121 |
currentSelectionFgColor |
|
3122 |
^ selectionFgColor |
|
3123 |
! |
|
3124 |
||
248 | 3125 |
fileOutContentsOn:aStream |
3126 |
"save contents on a stream, replacing leading spaces by tab-characters." |
|
3127 |
||
4500 | 3128 |
self |
5791 | 3129 |
fileOutContentsOn:aStream |
3130 |
compressTabs:true |
|
248 | 3131 |
! |
3132 |
||
3133 |
fileOutContentsOn:aStream compressTabs:compressTabs |
|
3134 |
"save contents on a stream. If compressTabs is true, |
|
3135 |
leading spaces will be replaced by tab-characters in the output." |
|
3136 |
||
4500 | 3137 |
self |
5791 | 3138 |
fileOutContentsOn:aStream |
3139 |
compressTabs:compressTabs |
|
3140 |
encoding:nil |
|
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
3141 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
3142 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
3143 |
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
|
3144 |
"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
|
3145 |
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
|
3146 |
|
2877 | 3147 |
|startNr nLines string encoder| |
3148 |
||
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3149 |
self removeTrailingWhitespace. |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3150 |
|
5658 | 3151 |
"/ This is now obsolete, as we are always using unicode internally. |
3152 |
"/ so the following line should be changed to encoderToEncodeFrom:unicode to:xxx. |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3153 |
encoder := CharacterEncoder encoderToEncodeFrom:gc characterEncoding into:encodingSymOrNil. |
4455
febe97112d50
changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents:
4450
diff
changeset
|
3154 |
encoder isNullEncoder ifTrue:[ |
5791 | 3155 |
(list contains:[:lineOrNil| |
3156 |
|s| |
|
3157 |
lineOrNil notNil |
|
3158 |
and:[(s := lineOrNil string string) isWideString |
|
3159 |
and:[s asSingleByteStringIfPossible isWideString]] |
|
3160 |
] |
|
3161 |
) ifTrue:[ |
|
3162 |
(Dialog confirm:'The text contains non-8bit characters. Encode as UTF8?') ifFalse:[ |
|
3163 |
^ self |
|
3164 |
] |
|
3165 |
]. |
|
3166 |
encoder := CharacterEncoder encoderToEncodeFrom:#unicode into:#utf8 |
|
4455
febe97112d50
changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents:
4450
diff
changeset
|
3167 |
]. |
2916 | 3168 |
|
758 | 3169 |
aStream isFileStream ifTrue:[ |
5791 | 3170 |
"on some systems, writing linewise is very slow (via NFS) |
3171 |
therefore we convert to a string and write it in big chunks. |
|
3172 |
To avoid creating huge strings, we do it in blocks of 1000 lines, |
|
3173 |
limiting temporary string creation to about 50-80k. |
|
3174 |
" |
|
3175 |
startNr := 1. |
|
3176 |
nLines := list size. |
|
3177 |
(aStream eolMode notNil |
|
3178 |
and:[aStream eolMode ~= #nl]) ifTrue:[ |
|
3179 |
"/ must do it lineWise ... |
|
3180 |
list do:[:line | |
|
3181 |
line notNil ifTrue:[ |
|
3182 |
encoder encodeString:line withTabs on:aStream |
|
3183 |
]. |
|
3184 |
aStream cr |
|
3185 |
]. |
|
3186 |
] ifFalse:[ |
|
3187 |
[startNr <= nLines] whileTrue:[ |
|
3188 |
string := list |
|
3189 |
asStringWithCRsFrom:startNr |
|
3190 |
to:((startNr + 1000) min:nLines) |
|
3191 |
compressTabs:compressTabs. |
|
3192 |
encoder encodeString:string string on:aStream. |
|
3193 |
startNr := startNr + 1000 + 1. |
|
3194 |
]. |
|
3195 |
]. |
|
758 | 3196 |
] ifFalse:[ |
5791 | 3197 |
list do:[:aLine | |
3198 |
aLine notNil ifTrue:[ |
|
3199 |
encoder encodeString:aLine on:aStream. |
|
3200 |
]. |
|
3201 |
aStream cr. |
|
3202 |
] |
|
758 | 3203 |
] |
248 | 3204 |
|
758 | 3205 |
"Modified: 8.6.1996 / 11:50:46 / cg" |
248 | 3206 |
! |
3207 |
||
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3208 |
getFontParameters |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3209 |
"get some info of the used font. They are cached since we use them often .. |
4779 | 3210 |
This is redefined here, to use the font's maxHeight/maxAscent for |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3211 |
line separation. This is required, to allow for proper handling of |
4779 | 3212 |
national characters, such as A-diaresis ..." |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3213 |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3214 |
|italicFont boldFont font| |
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3215 |
|
5820 | 3216 |
font := gc deviceFont. |
5443 | 3217 |
"/ do we really need this info now? |
3218 |
"/ on unix, it seems to work with the next two lines commented; |
|
3219 |
"/ should probably check on windows too |
|
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
3220 |
italicFont := font asItalic onDevice:device. |
3304
bd0991615b04
When computing font parameters, now consider the bold font, too.
Stefan Vogel <sv@exept.de>
parents:
3298
diff
changeset
|
3221 |
boldFont := font asBold onDevice:device. |
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
3222 |
|
5443 | 3223 |
fontHeight := font height. |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3224 |
fontAscent := font ascent. |
5443 | 3225 |
fontWidth := font width. |
3226 |
fontIsFixedWidth := font isFixedWidth. |
|
3227 |
||
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3228 |
"/ fA := font maxAscent. |
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3229 |
italicFont notNil ifTrue:[ |
5791 | 3230 |
fontHeight := fontHeight max:(italicFont height). |
3231 |
fontAscent := fontAscent max:(italicFont ascent). |
|
3232 |
fontIsFixedWidth := fontIsFixedWidth and:[ italicFont isFixedWidth ] |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3233 |
]. |
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3234 |
boldFont notNil ifTrue:[ |
5791 | 3235 |
fontHeight := fontHeight max:(boldFont height). |
3236 |
fontAscent := fontAscent max:(boldFont ascent). |
|
3237 |
fontIsFixedWidth := fontIsFixedWidth and:[ boldFont isFixedWidth ] |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
3238 |
]. |
5443 | 3239 |
|
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3240 |
includesNonStrings == true ifTrue:[ |
5791 | 3241 |
"/ for now, we do not support variable height entries ... |
3242 |
fontHeight := fontHeight max:(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
|
3243 |
]. |
4579 | 3244 |
fontHeight := fontHeight + lineSpacing. |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3245 |
|
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3246 |
"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
|
3247 |
"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
|
3248 |
! |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
3249 |
|
5374 | 3250 |
highlightLineSpacing |
3251 |
"true if the spacing between lines is to be drawn with selected color, |
|
3252 |
false if it remains white. |
|
3253 |
false for selection in list views; true for edit/text views" |
|
3254 |
||
3255 |
^ true |
|
3256 |
! |
|
3257 |
||
6459 | 3258 |
isBeginOfIgnoredBlock:ch |
3259 |
"answer true, if the charcter is the start of a comment or string constant" |
|
3260 |
||
3261 |
^ (parenthesisSpecification at:#ignore ifAbsent:#($' $")) includes:ch. |
|
3262 |
||
3263 |
"Created: / 22-10-2018 / 10:52:40 / Stefan Vogel" |
|
3264 |
! |
|
3265 |
||
3605 | 3266 |
isClosingParenthesis:ch |
3267 |
((parenthesisSpecification at:#close) includes:ch) ifTrue:[^ true]. |
|
4368 | 3268 |
^ ')]}' includes:ch |
3269 |
||
3270 |
"Modified: / 12-02-2012 / 08:37:01 / cg" |
|
3605 | 3271 |
! |
3272 |
||
3273 |
isOpeningParenthesis:ch |
|
3274 |
((parenthesisSpecification at:#open) includes:ch) ifTrue:[^ true]. |
|
4368 | 3275 |
^ '([{' includes:ch |
3276 |
||
3277 |
"Modified: / 12-02-2012 / 08:37:11 / cg" |
|
3605 | 3278 |
! |
3279 |
||
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3280 |
rememberSearchPattern:pattern |
2691 | 3281 |
|nRemembered patternString| |
3282 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3283 |
self clearSearchAction. |
2813
ec8e83691849
forget searchAction, when a new pattern-search is done
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
3284 |
|
2691 | 3285 |
patternString := pattern string. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3286 |
|
3270
e3ed37e15f9d
oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents:
3258
diff
changeset
|
3287 |
nRemembered := NumRememberedSearchPatterns ? 20. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3288 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3289 |
LastSearchPatterns isNil ifTrue:[ |
5791 | 3290 |
LastSearchPatterns := OrderedCollection new. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3291 |
]. |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3292 |
"/ move to top or addFirst |
4409 | 3293 |
(LastSearchPatterns includes:patternString) ifTrue:[ |
5791 | 3294 |
LastSearchPatterns remove:patternString. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3295 |
] ifFalse:[ |
5791 | 3296 |
LastSearchPatterns size > nRemembered ifTrue:[ |
3297 |
LastSearchPatterns removeLast |
|
3298 |
] |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3299 |
]. |
4409 | 3300 |
LastSearchPatterns addFirst:patternString. |
3301 |
||
3302 |
"Modified: / 23-03-2012 / 13:59:09 / cg" |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3303 |
! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
3304 |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3305 |
removeTrailingWhitespace |
3001 | 3306 |
list isNil ifTrue:[^self]. |
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3307 |
list keysAndValuesDo:[:lineNR :line | |
5791 | 3308 |
|l| |
3309 |
||
3310 |
line notNil ifTrue:[ |
|
3311 |
l := line withoutTrailingSeparators. |
|
3312 |
list at:lineNR put:l. |
|
3313 |
] |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3314 |
]. |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3315 |
! |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
3316 |
|
4009 | 3317 |
resetVariablesBeforeNewSearch |
3318 |
"clear the autosearch action, when the first pattern is searched for" |
|
3319 |
||
3320 |
searchAction := nil. |
|
3321 |
! |
|
3322 |
||
248 | 3323 |
scrollSelectDown |
6294 | 3324 |
"auto scroll downwards while selecting |
3325 |
(i.e. when the mouse is down, and moved out of the window to the bottom) |
|
3326 |
scroll and reinstall timed-block. |
|
3327 |
Adjust the selectionStartLine" |
|
248 | 3328 |
|
3329 |
|prevEndLine| |
|
3330 |
||
6294 | 3331 |
"just to make certain, that we actually have a selection..." |
248 | 3332 |
selectionEndLine isNil ifTrue:[^ self]. |
3333 |
||
6343 | 3334 |
self scrollDownLines:1. |
248 | 3335 |
|
3336 |
"make new selection immediately visible" |
|
3337 |
prevEndLine := selectionEndLine. |
|
3338 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
3339 |
selectionEndCol := 0. |
|
3340 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
5791 | 3341 |
self redrawLine:lineNr |
248 | 3342 |
]. |
5235 | 3343 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 3344 |
self selectionChanged. |
6343 | 3345 |
|
3346 |
"Modified: / 13-06-2018 / 23:43:28 / Claus Gittinger" |
|
248 | 3347 |
! |
3348 |
||
3349 |
scrollSelectLeft |
|
6294 | 3350 |
"auto scroll to the left while selecting |
3351 |
(i.e. when the mouse is down, and moved out of the window to the left) |
|
3352 |
scroll and reinstall timed-block. |
|
3353 |
Adjust the selectionStartColumn." |
|
248 | 3354 |
|
3355 |
|prevStartLine| |
|
3356 |
||
6294 | 3357 |
"just to make certain, that we actually have a selection..." |
248 | 3358 |
selectionStartLine isNil ifTrue:[^ self]. |
3359 |
selectionStartCol isNil ifTrue:[^ self]. |
|
3360 |
||
3361 |
"make new selection immediately visible" |
|
3362 |
prevStartLine := selectionStartLine. |
|
3363 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
6340 | 3364 |
true "false" ifTrue:[ |
3365 |
self selectionChanged. self repairDamage. |
|
3366 |
self scrollLeft. self repairDamage. |
|
3367 |
] ifFalse:[ |
|
3368 |
self scrollLeft. |
|
3369 |
self selectionChanged. |
|
3370 |
]. |
|
248 | 3371 |
|
5236 | 3372 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
6340 | 3373 |
|
3374 |
"Modified: / 13-06-2018 / 22:54:24 / Claus Gittinger" |
|
248 | 3375 |
! |
3376 |
||
3377 |
scrollSelectRight |
|
6294 | 3378 |
"auto scroll to the right while selecting |
3379 |
(i.e. when the mouse is down, and moved out of the window to the right) |
|
3380 |
scroll and reinstall timed-block. |
|
3381 |
Adjust the selectionEndColumn." |
|
248 | 3382 |
|
4156 | 3383 |
|prevEndCol firstVisibleCol endLine| |
248 | 3384 |
|
6294 | 3385 |
"just to make certain, that we actually have a selection..." |
248 | 3386 |
selectionEndCol isNil ifTrue:[^ self]. |
4169 | 3387 |
selectionEndLine isNil ifTrue:[^ self]. |
248 | 3388 |
|
3389 |
prevEndCol := selectionEndCol. |
|
4156 | 3390 |
selectionEndCol := (selectionEndCol + 1) min:(self listAt:selectionEndLine) size. |
3391 |
||
3392 |
endLine := self listLineToVisibleLine:selectionEndLine. |
|
3393 |
endLine notNil ifTrue:[ |
|
5791 | 3394 |
firstVisibleCol := self colOfX:1 inVisibleLine:endLine. |
3395 |
selectionEndCol < firstVisibleCol ifTrue:[ |
|
3396 |
"/ scrolling faster than selection advances... |
|
3397 |
selectionEndCol := firstVisibleCol |
|
3398 |
]. |
|
4156 | 3399 |
]. |
3400 |
||
6475 | 3401 |
self selectionChanged. "/ false ifTrue:[ self repairDamage ]. |
3402 |
self scrollRight. "/ false ifTrue:[ self repairDamage ]. |
|
3403 |
self invalidate. |
|
5236 | 3404 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4156 | 3405 |
|
3406 |
"Modified: / 05-08-2010 / 21:25:56 / cg" |
|
6475 | 3407 |
"Modified: / 29-10-2018 / 09:39:54 / Claus Gittinger" |
248 | 3408 |
! |
3409 |
||
3410 |
scrollSelectUp |
|
6294 | 3411 |
"auto scroll upwards while selecting |
3412 |
(i.e. when the mouse is down, and moved out of the window to the top) |
|
3413 |
scroll and reinstall timed-block. |
|
3414 |
Adjust the selectionStartLine" |
|
248 | 3415 |
|
3416 |
|prevStartLine| |
|
3417 |
||
6294 | 3418 |
"just to make certain, that we actually have a selection..." |
248 | 3419 |
selectionStartLine isNil ifTrue:[^ self]. |
3420 |
||
3421 |
self scrollUp. |
|
3422 |
||
3423 |
"make new selection immediately visible" |
|
3424 |
prevStartLine := selectionStartLine. |
|
3425 |
selectionStartLine := firstLineShown. |
|
3426 |
selectionStartCol := 1. |
|
3427 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
5791 | 3428 |
self redrawLine:lineNr |
248 | 3429 |
]. |
5236 | 3430 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 3431 |
self selectionChanged. |
248 | 3432 |
! |
3433 |
||
3434 |
stopScrollSelect |
|
3435 |
"stop auto scroll; deinstall timed-block" |
|
3436 |
||
3437 |
autoScrollBlock notNil ifTrue:[ |
|
5791 | 3438 |
Processor removeTimedBlock:autoScrollBlock. |
3439 |
self compressMotionEvents:true. |
|
3440 |
autoScrollBlock := nil. |
|
3441 |
autoScrollDeltaT := nil |
|
248 | 3442 |
] |
3443 |
! |
|
3444 |
||
5120 | 3445 |
textChanged |
3446 |
self isNativeWidget ifTrue:[ |
|
5791 | 3447 |
gc drawableId notNil ifTrue:[ |
3448 |
device changeText:self contents in:gc drawableId |
|
3449 |
] |
|
5120 | 3450 |
]. |
3451 |
super textChanged |
|
3452 |
! |
|
3453 |
||
248 | 3454 |
widthForScrollBetween:firstLine and:lastLine |
3455 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
3456 |
||
3457 |
selectionStartLine notNil ifTrue:[ |
|
5791 | 3458 |
"/ if there is a selection which covers multiple lines, |
3459 |
"/ we have to scroll the whole width (to include the selection-rectangle) |
|
3460 |
||
3461 |
(lastLine < selectionStartLine) ifFalse:[ |
|
3462 |
(firstLine > selectionEndLine) ifFalse:[ |
|
3463 |
^ width |
|
3464 |
] |
|
3465 |
]. |
|
248 | 3466 |
]. |
3467 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
3468 |
! ! |
|
3469 |
||
997 | 3470 |
!TextView methodsFor:'queries'! |
3471 |
||
4063 | 3472 |
hasSearchActionSelection |
3473 |
"Here we fake the use of typeOfSelection which is really in EditTextView" |
|
3474 |
||
3475 |
^ false |
|
3476 |
! |
|
3477 |
||
997 | 3478 |
specClass |
1380 | 3479 |
"redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)" |
3480 |
||
997 | 3481 |
self class == TextView ifTrue:[^ TextEditorSpec]. |
1046 | 3482 |
^ super specClass |
997 | 3483 |
|
1380 | 3484 |
"Modified: / 31.10.1997 / 19:48:35 / cg" |
997 | 3485 |
! ! |
3486 |
||
248 | 3487 |
!TextView methodsFor:'redrawing'! |
3488 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3489 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3490 |
"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
|
3491 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3492 |
(leftMargin ~~ 0) ifTrue:[ |
5791 | 3493 |
viewOrigin x <= margin ifTrue:[ |
6059 | 3494 |
gc paint:color. |
6286 | 3495 |
gc fillRectangleX:(margin-viewOrigin x) y:(self yOfVisibleLine:visLine)-(lineSpacing//2) |
6059 | 3496 |
width:leftMargin height:fontHeight |
5791 | 3497 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3498 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3499 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3500 |
"Created: 6.3.1996 / 14:22:55 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3501 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3502 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3503 |
drawSelectedFromVisibleLine:startVisLineNr to:endVisLineNr |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3504 |
startVisLineNr to:endVisLineNr do:[:visLine | |
5791 | 3505 |
self drawVisibleLineSelected:visLine |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3506 |
] |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3507 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3508 |
|
4500 | 3509 |
drawVisibleLineSelected:visLineNr |
3510 |
self |
|
5791 | 3511 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
3512 |
inVisible:visLineNr |
|
3513 |
with:self currentSelectionFgColor and:self currentSelectionBgColor |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3514 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3515 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3516 |
drawVisibleLineSelected:visLineNr col:col |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3517 |
self |
5791 | 3518 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
3519 |
inVisible:visLineNr |
|
3520 |
col:col |
|
3521 |
with:self currentSelectionFgColor and:self currentSelectionBgColor |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3522 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3523 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3524 |
drawVisibleLineSelected:visLineNr from:selectionStartCol |
4500 | 3525 |
self |
5791 | 3526 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
3527 |
inVisible:visLineNr |
|
3528 |
from:selectionStartCol |
|
3529 |
with:self currentSelectionFgColor and:self currentSelectionBgColor. |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3530 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3531 |
|
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
3532 |
drawVisibleLineSelected:visLineNr from:startCol to:endCol |
4500 | 3533 |
self |
5791 | 3534 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
3535 |
inVisible:visLineNr |
|
3536 |
from:startCol to:endCol |
|
3537 |
with:self currentSelectionFgColor and:self currentSelectionBgColor. |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3538 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3539 |
|
248 | 3540 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
3541 |
"redraw a visible line range" |
|
3542 |
||
3543 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
3544 |
||
3545 |
shown ifFalse:[^ self]. |
|
3546 |
||
3547 |
end := endVisLineNr. |
|
3548 |
(end > nLinesShown) ifTrue:[ |
|
5791 | 3549 |
end := nLinesShown |
248 | 3550 |
]. |
3551 |
||
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
3552 |
selectionEndLine isNil ifTrue:[ |
5791 | 3553 |
selectionStartLine := nil |
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
3554 |
]. |
2735 | 3555 |
|
248 | 3556 |
selectionStartLine isNil ifTrue:[ |
5791 | 3557 |
specialCare := false |
248 | 3558 |
] ifFalse:[ |
5791 | 3559 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
3560 |
(startLine > selectionEndLine) ifTrue:[ |
|
3561 |
specialCare := false |
|
3562 |
] ifFalse:[ |
|
3563 |
endLine := self visibleLineToAbsoluteLine:end. |
|
3564 |
(endLine < selectionStartLine) ifTrue:[ |
|
3565 |
specialCare := false |
|
3566 |
] ifFalse:[ |
|
3567 |
specialCare := true |
|
3568 |
] |
|
3569 |
] |
|
248 | 3570 |
]. |
3571 |
||
3572 |
"easy: nothing is selected" |
|
3573 |
specialCare ifFalse:[ |
|
5791 | 3574 |
super redrawFromVisibleLine:startVisLineNr to:end. |
3575 |
^ self |
|
248 | 3576 |
]. |
3577 |
||
3578 |
"easy: all is selected" |
|
3579 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
5791 | 3580 |
self drawSelectedFromVisibleLine:startVisLineNr to:end. |
3581 |
^ self |
|
248 | 3582 |
]. |
3583 |
||
3584 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
5791 | 3585 |
"draw unselected top part" |
3586 |
||
3587 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
3588 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
3589 |
||
3590 |
"and first partial selected line" |
|
3591 |
self redrawVisibleLine:selVisStart. |
|
3592 |
||
3593 |
"rest starts after this one" |
|
3594 |
line1 := selVisStart + 1 |
|
248 | 3595 |
] ifFalse:[ |
5791 | 3596 |
line1 := 1 |
248 | 3597 |
]. |
3598 |
||
3599 |
(line1 > end) ifTrue:[^ self]. |
|
3600 |
(line1 < startVisLineNr) ifTrue:[ |
|
5791 | 3601 |
line1 := startVisLineNr |
248 | 3602 |
]. |
3603 |
||
3604 |
"draw middle part of selection" |
|
3605 |
||
3606 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
5791 | 3607 |
line2 := nLinesShown |
248 | 3608 |
] ifFalse:[ |
5791 | 3609 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
248 | 3610 |
]. |
3611 |
(line2 > end) ifTrue:[ |
|
5791 | 3612 |
line2 := end |
248 | 3613 |
]. |
3614 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3615 |
self drawSelectedFromVisibleLine:line1 to:line2. |
248 | 3616 |
|
3617 |
(line2 >= end) ifTrue:[^ self]. |
|
3618 |
||
3619 |
"last line of selection" |
|
3620 |
self redrawVisibleLine:(line2 + 1). |
|
3621 |
||
3622 |
((line2 + 2) <= end) ifTrue:[ |
|
5791 | 3623 |
super redrawFromVisibleLine:(line2 + 2) to:end |
248 | 3624 |
] |
3625 |
! |
|
3626 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3627 |
redrawVisibleLine:visLineNr |
248 | 3628 |
"redraw visible line lineNr" |
3629 |
||
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
3630 |
|line| |
248 | 3631 |
|
4528 | 3632 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3633 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
5791 | 3634 |
line := self visibleLineToAbsoluteLine:visLineNr. |
3635 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3636 |
(line == selectionStartLine) ifTrue:[ |
|
3637 |
(line == selectionEndLine) ifTrue:[ |
|
3638 |
"it's part-of-single-line selection" |
|
3639 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3640 |
(selectionStartCol > 1) ifTrue:[ |
|
3641 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3642 |
]. |
|
3643 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol. |
|
3644 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3645 |
^ self |
|
3646 |
]. |
|
3647 |
||
3648 |
"it's the first line of a multi-line selection" |
|
3649 |
(selectionStartCol ~~ 1) ifTrue:[ |
|
3650 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3651 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3652 |
] ifFalse:[ |
|
3653 |
viewOrigin x == 0 ifTrue:[ |
|
3654 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3655 |
] |
|
3656 |
]. |
|
3657 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol. |
|
3658 |
^ self |
|
3659 |
]. |
|
3660 |
||
3661 |
(line == selectionEndLine) ifTrue:[ |
|
3662 |
"it's the last line of a multi-line selection" |
|
3663 |
(selectionEndCol == 0) ifTrue:[ |
|
3664 |
^ super redrawVisibleLine:visLineNr |
|
3665 |
]. |
|
3666 |
||
3667 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3668 |
self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol. |
|
3669 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3670 |
^ self |
|
3671 |
]. |
|
3672 |
||
3673 |
"it's a full line in a multi-line selection" |
|
3674 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3675 |
self drawVisibleLineSelected:visLineNr. |
|
3676 |
^ self |
|
3677 |
] |
|
248 | 3678 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3679 |
super redrawVisibleLine:visLineNr |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3680 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3681 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 3682 |
! |
3683 |
||
3684 |
redrawVisibleLine:visLine col:col |
|
633 | 3685 |
"redraw single character at col in visible line lineNr." |
248 | 3686 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3687 |
|line| |
633 | 3688 |
|
3689 |
"/ |
|
3690 |
"/ care for selection |
|
3691 |
"/ |
|
4528 | 3692 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3693 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
5791 | 3694 |
line := self visibleLineToAbsoluteLine:visLine. |
3695 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3696 |
((line == selectionStartLine) |
|
3697 |
and: [col < selectionStartCol]) ifFalse:[ |
|
3698 |
((line == selectionEndLine) |
|
3699 |
and: [col > selectionEndCol]) ifFalse:[ |
|
3700 |
"its in the selection" |
|
3701 |
self drawVisibleLineSelected:visLine col:col. |
|
3702 |
^ self. |
|
3703 |
] |
|
3704 |
] |
|
3705 |
] |
|
248 | 3706 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3707 |
self drawVisibleLine:visLine col:col with:fgColor and:bgColor |
1496 | 3708 |
|
3709 |
"Modified: / 22.4.1998 / 08:53:05 / cg" |
|
248 | 3710 |
! |
3711 |
||
3712 |
redrawVisibleLine:visLine from:startCol |
|
3713 |
"redraw visible line lineNr from startCol to end of line" |
|
3714 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3715 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3716 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3717 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3718 |
col == 0 ifTrue:[ |
5791 | 3719 |
col := 1. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3720 |
]. |
248 | 3721 |
|
2778
223915a2d6a4
kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
3722 |
(selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[ |
5791 | 3723 |
line := self visibleLineToAbsoluteLine:visLine. |
3724 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3725 |
((line == selectionStartLine) |
|
3726 |
or:[line == selectionEndLine]) ifTrue:[ |
|
3727 |
"since I'm lazy, redraw full line" |
|
3728 |
self redrawVisibleLine:visLine. |
|
3729 |
^ self |
|
3730 |
]. |
|
3731 |
"the line is fully within the selection" |
|
3732 |
self drawVisibleLineSelected:visLine from:col. |
|
3733 |
^ self |
|
3734 |
] |
|
248 | 3735 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3736 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3737 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3738 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 3739 |
! |
3740 |
||
3741 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
3742 |
"redraw visible line lineNr from startCol to endCol" |
|
3743 |
||
3744 |
|line allOut allIn leftCol rightCol| |
|
3745 |
||
3746 |
line := self visibleLineToAbsoluteLine:visLine. |
|
3747 |
||
3748 |
allIn := false. |
|
3749 |
allOut := false. |
|
4528 | 3750 |
(selectionStartLine isNil or:[selectionEndLine isNil |
3751 |
or:[selectionStartCol isNil or:[selectionEndCol isNil]]]) ifTrue:[ |
|
5791 | 3752 |
allOut := true |
248 | 3753 |
] ifFalse:[ |
5791 | 3754 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
3755 |
allOut := true |
|
3756 |
] ifTrue:[ |
|
3757 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
3758 |
((endCol < selectionStartCol) |
|
3759 |
or:[startCol > selectionEndCol]) ifTrue:[ |
|
3760 |
allOut := true |
|
3761 |
] ifFalse:[ |
|
3762 |
((startCol >= selectionStartCol) |
|
3763 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
|
3764 |
allIn := true |
|
3765 |
] |
|
3766 |
] |
|
3767 |
] ifFalse:[ |
|
3768 |
(line == selectionStartLine) ifTrue:[ |
|
3769 |
(endCol < selectionStartCol) ifTrue:[ |
|
3770 |
allOut := true |
|
3771 |
] ifFalse:[ |
|
3772 |
(startCol >= selectionStartCol) ifTrue:[ |
|
3773 |
allIn := true |
|
3774 |
] |
|
3775 |
] |
|
3776 |
] ifFalse:[ |
|
3777 |
(line == selectionEndLine) ifTrue:[ |
|
3778 |
(startCol > selectionEndCol) ifTrue:[ |
|
3779 |
allOut := true |
|
3780 |
] ifFalse:[ |
|
3781 |
(endCol <= selectionEndCol) ifTrue:[ |
|
3782 |
allIn := true |
|
3783 |
] |
|
3784 |
] |
|
3785 |
] ifFalse:[ |
|
3786 |
allIn := true |
|
3787 |
] |
|
3788 |
] |
|
3789 |
] |
|
3790 |
] |
|
248 | 3791 |
]. |
3792 |
allOut ifTrue:[ |
|
5791 | 3793 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
3794 |
^ self |
|
248 | 3795 |
]. |
3796 |
||
3797 |
allIn ifTrue:[ |
|
5791 | 3798 |
self drawVisibleLineSelected:visLine from:startCol to:endCol |
248 | 3799 |
] ifFalse:[ |
5791 | 3800 |
"redraw part before selection" |
3801 |
((line == selectionStartLine) |
|
3802 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
|
3803 |
super redrawVisibleLine:visLine from:startCol |
|
3804 |
to:(selectionStartCol - 1). |
|
3805 |
leftCol := selectionStartCol |
|
3806 |
] ifFalse:[ |
|
3807 |
leftCol := startCol |
|
3808 |
]. |
|
3809 |
"redraw selected part" |
|
3810 |
(selectionEndLine > line) ifTrue:[ |
|
3811 |
rightCol := endCol |
|
3812 |
] ifFalse:[ |
|
3813 |
rightCol := selectionEndCol min:endCol |
|
3814 |
]. |
|
3815 |
self drawVisibleLineSelected:visLine from:leftCol to:rightCol. |
|
3816 |
||
3817 |
"redraw part after selection" |
|
3818 |
(rightCol < endCol) ifTrue:[ |
|
3819 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
|
3820 |
] |
|
248 | 3821 |
]. |
3822 |
||
3823 |
"special care for first and last line of selection: |
|
3824 |
must handle margin also" |
|
3825 |
||
3826 |
((line == selectionEndLine) |
|
3827 |
and:[(startCol == 1) |
|
3828 |
and:[selectionStartLine < selectionEndLine]]) |
|
3829 |
ifTrue:[ |
|
5791 | 3830 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
248 | 3831 |
]. |
3832 |
||
3833 |
((line == selectionStartLine) |
|
3834 |
and:[(startCol == 1) |
|
3835 |
and:[selectionStartLine < selectionEndLine]]) |
|
3836 |
ifTrue:[ |
|
5791 | 3837 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
4602 | 3838 |
]. |
3839 |
||
3840 |
((line > selectionStartLine) |
|
3841 |
and:[(startCol == 1) |
|
3842 |
and:[selectionStartLine < selectionEndLine |
|
3843 |
and:[line < selectionEndLine]]]) |
|
3844 |
ifTrue:[ |
|
5791 | 3845 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
248 | 3846 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3847 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3848 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 3849 |
! ! |
3850 |
||
3851 |
!TextView methodsFor:'searching'! |
|
3852 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3853 |
clearSearchAction |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3854 |
searchAction := nil. |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3855 |
! |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3856 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3857 |
scanFor:aCharacter fromLine:startLine col:startCol forward:forward |
5791 | 3858 |
ifFound:foundBlock |
3859 |
ifNotFound:notFoundBlock |
|
4500 | 3860 |
"search for a character in the direction given by forward. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3861 |
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
|
3862 |
|
4500 | 3863 |
|lineString |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3864 |
line "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3865 |
col "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3866 |
delta "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3867 |
endCol "{ Class: SmallInteger }" |
4500 | 3868 |
cc |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3869 |
maxLine "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3870 |
| |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3871 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3872 |
col := startCol. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3873 |
line := startLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3874 |
forward ifTrue:[ |
5791 | 3875 |
delta := 1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3876 |
] ifFalse:[ |
5791 | 3877 |
delta := -1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3878 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3879 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3880 |
lineString := list at:line. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3881 |
maxLine := list size. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3882 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3883 |
col := col + delta. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3884 |
[true] whileTrue:[ |
5791 | 3885 |
lineString notNil ifTrue:[ |
3886 |
forward ifTrue:[ |
|
3887 |
endCol := lineString size. |
|
3888 |
] ifFalse:[ |
|
3889 |
endCol := 1 |
|
3890 |
]. |
|
3891 |
||
3892 |
col to:endCol by:delta do:[:rCol | |
|
3893 |
cc := lineString at:rCol. |
|
3894 |
cc == aCharacter ifTrue:[ |
|
3895 |
^ foundBlock value:line value:rCol. |
|
3896 |
] |
|
3897 |
]. |
|
3898 |
]. |
|
3899 |
line := line + delta. |
|
3900 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
|
3901 |
^ notFoundBlock value |
|
3902 |
]. |
|
3903 |
lineString := list at:line. |
|
3904 |
forward ifTrue:[ |
|
3905 |
col := 1 |
|
3906 |
] ifFalse:[ |
|
3907 |
col := lineString size |
|
3908 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3909 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3910 |
"not reached" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3911 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3912 |
"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
|
3913 |
"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
|
3914 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3915 |
|
3802 | 3916 |
searchAction |
3917 |
^ searchAction |
|
3918 |
! |
|
3919 |
||
2807 | 3920 |
searchAction:aSearcherOrSearchBlock |
3921 |
searchAction := aSearcherOrSearchBlock |
|
3922 |
! |
|
3923 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3924 |
searchAgainInSameDirection |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3925 |
"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
|
3926 |
|
3577 | 3927 |
|ign match| |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3928 |
|
3981 | 3929 |
searchBarActionBlock notNil ifTrue:[ |
5791 | 3930 |
searchBarActionBlock value:#forward value:self. |
3931 |
^ self |
|
3581 | 3932 |
]. |
3933 |
||
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3934 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 3935 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
3936 |
||
3937 |
self setSearchPatternWithMatchEscapes: match. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3938 |
lastSearchPattern notNil ifTrue:[ |
5791 | 3939 |
lastSearchDirection == #backward ifTrue:[ |
3940 |
self |
|
3941 |
searchBwd:lastSearchPattern |
|
3942 |
ignoreCase:ign |
|
3943 |
match: match |
|
3944 |
] ifFalse:[ |
|
3945 |
self |
|
3946 |
searchFwd:lastSearchPattern |
|
3947 |
ignoreCase:ign |
|
3948 |
match: match |
|
3949 |
] |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3950 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3951 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3952 |
"Created: / 03-05-1999 / 15:02:16 / cg" |
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3953 |
"Modified: / 21-09-2006 / 16:47:57 / cg" |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3954 |
! |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3955 |
|
248 | 3956 |
searchBwd |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3957 |
"search backward (for the same thing again) |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3958 |
If found, position cursor" |
248 | 3959 |
|
4399 | 3960 |
|ign selectedVariable| |
1353 | 3961 |
|
2811 | 3962 |
searchAction notNil ifTrue:[ |
5791 | 3963 |
"/autosearch is cleared whenever there is search with user selection |
3964 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4178 | 3965 |
]. |
3966 |
||
3967 |
searchAction notNil ifTrue:[ |
|
5791 | 3968 |
"/confusing: this is for autosearch of variables (browse variable uses, for example) |
3969 |
self searchUsingSearchAction:#backward. |
|
3970 |
^ self. |
|
2807 | 3971 |
]. |
3981 | 3972 |
searchBarActionBlock notNil ifTrue:[ |
5791 | 3973 |
searchBarActionBlock value:#backward value:self. |
3974 |
^ self |
|
3581 | 3975 |
]. |
4399 | 3976 |
lastSearchWasVariableSearch ifTrue:[ |
5791 | 3977 |
selectedVariable := self syntaxElementForSelectedVariable. |
3978 |
selectedVariable notNil ifTrue:[ |
|
3979 |
self searchVariableWithSyntaxElement:selectedVariable forward:false. |
|
3980 |
^ self. |
|
3981 |
]. |
|
3982 |
lastSearchWasVariableSearch := false. |
|
4399 | 3983 |
]. |
2807 | 3984 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3985 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
1353 | 3986 |
|
3577 | 3987 |
self setSearchPatternWithMatchEscapes: false. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3988 |
lastSearchPattern isNil ifTrue:[ |
6553 | 3989 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
5791 | 3990 |
lastSearchPattern := LastSearchPatterns first |
3991 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3992 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3993 |
|
1326 | 3994 |
lastSearchPattern notNil ifTrue:[ |
5791 | 3995 |
lastSearchDirection := #backward. |
3996 |
self rememberSearchPattern:lastSearchPattern. |
|
3997 |
self |
|
3998 |
searchBwd:lastSearchPattern |
|
3999 |
ignoreCase:ign |
|
248 | 4000 |
] |
1326 | 4001 |
|
4399 | 4002 |
"Modified: / 08-03-2012 / 14:26:25 / cg" |
6553 | 4003 |
"Modified: / 01-03-2019 / 16:14:21 / Claus Gittinger" |
248 | 4004 |
! |
4005 |
||
4006 |
searchBwd:pattern |
|
4007 |
"do a backward search" |
|
4008 |
||
4009 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4010 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4011 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4012 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4013 |
"Modified: / 21-09-2006 / 16:48:29 / cg" |
248 | 4014 |
! |
4015 |
||
4016 |
searchBwd:pattern ifAbsent:aBlock |
|
4017 |
"do a backward search" |
|
4018 |
||
4500 | 4019 |
self |
5791 | 4020 |
searchBwdUsingSpec:(ListView::SearchSpec new |
4021 |
pattern:pattern) |
|
4022 |
ifAbsent:aBlock |
|
1326 | 4023 |
|
4024 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
4025 |
! |
|
4026 |
||
4027 |
searchBwd:pattern ignoreCase:ign |
|
4028 |
"do a backward search" |
|
4029 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4030 |
self |
5791 | 4031 |
searchBwd:pattern |
4032 |
ignoreCase:ign |
|
4033 |
ifAbsent:[ |
|
4034 |
self sensor compressKeyPressEventsWithKey:#FindPrev. |
|
4035 |
self showNotFound |
|
4036 |
]. |
|
4408 | 4037 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4038 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4039 |
|
4408 | 4040 |
"Created: / 13-09-1997 / 06:18:00 / cg" |
4041 |
"Modified: / 23-03-2012 / 12:10:25 / cg" |
|
1326 | 4042 |
! |
4043 |
||
4044 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
4045 |
"do a backward search" |
|
4046 |
||
4500 | 4047 |
self |
5791 | 4048 |
searchBwdUsingSpec:(ListView::SearchSpec new |
4049 |
pattern:pattern |
|
4050 |
ignoreCase:ign) |
|
4051 |
ifAbsent:aBlock |
|
1326 | 4052 |
|
4053 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
4054 |
"Created: 13.9.1997 / 06:18:41 / cg" |
|
248 | 4055 |
! |
4056 |
||
3577 | 4057 |
searchBwd:pattern ignoreCase:ign match: match |
4058 |
"do a backward search. |
|
4059 |
match pattern functionality is not yet available for backward search" |
|
4060 |
||
4408 | 4061 |
"/ lastSearchWasMatch := match. |
3577 | 4062 |
self searchBwd:pattern ignoreCase:ign. |
4408 | 4063 |
|
4064 |
"Modified: / 23-03-2012 / 12:12:44 / cg" |
|
3577 | 4065 |
! |
4066 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4067 |
searchBwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4068 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4069 |
|
4500 | 4070 |
self |
5791 | 4071 |
searchBwdUsingSpec:searchSpec |
4072 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4073 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4074 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4075 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4076 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4077 |
"Modified: / 21-09-2006 / 16:48:29 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4078 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4079 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4080 |
searchBwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4081 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4082 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4083 |
|pos startLine startCol| |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4084 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4085 |
pos := self startPositionForSearchBackward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4086 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4087 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4088 |
|
4500 | 4089 |
self |
5791 | 4090 |
searchBackwardUsingSpec:searchSpec |
4091 |
startingAtLine:startLine col:startCol |
|
4092 |
ifFound:[:line :col :endColOrNil| |
|
4093 |
self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil |
|
4094 |
] |
|
4095 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4096 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4097 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4098 |
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4099 |
"select characters enclosed by matching parenthesis if one is under startLine/Col" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4100 |
|
4500 | 4101 |
self |
5791 | 4102 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4103 |
ifFound:[:line :col | |
|
4104 |
self selectFromLine:startLine col:startCol |
|
4105 |
toLine:line col:col] |
|
4106 |
ifNotFound:[self showNotFound] |
|
6264 | 4107 |
onError:[self beepInEditor] |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4108 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4109 |
"Modified: 9.10.1997 / 12:57:34 / cg" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4110 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4111 |
|
248 | 4112 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
5791 | 4113 |
ifFound:foundBlock |
4114 |
ifNotFound:notFoundBlock |
|
4115 |
onError:failBlock |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4116 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4117 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
6099 | 4118 |
Search for the corresponding character is done forward if it's an opening, |
4119 |
backwards if it's a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4120 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4121 |
If there is a nesting error, evaluate failBlock." |
248 | 4122 |
|
4123 |
^ self |
|
5791 | 4124 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4125 |
ifFound:foundBlock |
|
4126 |
ifNotFound:notFoundBlock |
|
4127 |
onError:failBlock |
|
4128 |
ignoring:(parenthesisSpecification at:#ignore ifAbsent:#()) "/ #( $' $" '$[' '$]' '${' '$)' ) |
|
3478 | 4129 |
|
4130 |
"Modified: / 12-04-2007 / 11:24:24 / cg" |
|
6099 | 4131 |
"Modified (comment): / 13-02-2017 / 20:32:20 / cg" |
248 | 4132 |
! |
4133 |
||
4134 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
5791 | 4135 |
ifFound:foundBlock |
4136 |
ifNotFound:notFoundBlock |
|
4137 |
onError:failBlock |
|
4138 |
ignoring:ignoreSet |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4139 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4140 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
6099 | 4141 |
Search for the corresponding character is done forward if it's an opening, |
4142 |
backwards if it's a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4143 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4144 |
If there is a nesting error, evaluate failBlock." |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4145 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4146 |
^ self |
5791 | 4147 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4148 |
ifFound:foundBlock |
|
4149 |
ifNotFound:notFoundBlock |
|
4150 |
onError:failBlock |
|
4151 |
openingCharacters: (parenthesisSpecification at:#open) "/ #( $( $[ ${ "$> $<") |
|
4152 |
closingCharacters: (parenthesisSpecification at:#close) "/ #( $) $] $} "$> $<") |
|
4153 |
ignoredCharacters: ignoreSet |
|
4154 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/ |
|
4500 | 4155 |
|
4156 |
"/ |i direction lineString |
|
4157 |
"/ parChar charSet closingChar |
|
4158 |
"/ ignoring |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4159 |
"/ line "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4160 |
"/ col "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4161 |
"/ delta "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4162 |
"/ endCol "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4163 |
"/ runCol "{ Class: SmallInteger }" |
4500 | 4164 |
"/ cc prevCC nextCC incSet decSet |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4165 |
"/ nesting "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4166 |
"/ maxLine "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4167 |
"/ ign skip anySet| |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4168 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4169 |
"/ charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4170 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4171 |
"/ parChar := self characterAtLine:startLine col:startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4172 |
"/ i := charSet indexOf:parChar. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4173 |
"/ i == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4174 |
"/ ^ failBlock value "not a parenthesis" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4175 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4176 |
"/ direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4177 |
"/ closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4178 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4179 |
"/ col := startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4180 |
"/ line := startLine. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4181 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4182 |
"/ delta := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4183 |
"/ incSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4184 |
"/ decSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4185 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4186 |
"/ delta := -1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4187 |
"/ incSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4188 |
"/ decSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4189 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4190 |
"/ anySet := Set new. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4191 |
"/ anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4192 |
"/ anySet := (anySet select:[:c | c isCharacter]) asString. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4193 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4194 |
"/ nesting := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4195 |
"/ ignoring := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4196 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4197 |
"/ maxLine := list size. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4198 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4199 |
"/ col := col + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4200 |
"/ [nesting ~~ 0] whileTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4201 |
"/ (lineString notNil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4202 |
"/ and:[lineString includesAny:anySet]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4203 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4204 |
"/ endCol := lineString size. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4205 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4206 |
"/ endCol := 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4207 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4208 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4209 |
"/ col to:endCol by:delta do:[:rCol | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4210 |
"/ runCol := rCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4211 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4212 |
"/ cc := lineString at:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4213 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4214 |
"/ nextCC := lineString at:runCol+1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4215 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4216 |
"/ nextCC := nil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4217 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4218 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4219 |
"/ prevCC := lineString at:runCol-1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4220 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4221 |
"/ prevCC := nil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4222 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4223 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4224 |
"/ ign := skip := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4225 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4226 |
"/ "/ check for comments. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4227 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4228 |
"/ ((cc == $" and:[nextCC == $/]) |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4229 |
"/ or:[prevCC == $$ ]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4230 |
"/ "/ do nothing |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4231 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4232 |
"/ skip := true. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4233 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4234 |
"/ ignoreSet do:[:ignore | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4235 |
"/ ignore == cc ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4236 |
"/ ign := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4237 |
"/ ] ifFalse:[ |
4500 | 4238 |
"/ ignore isString ifTrue:[ |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4239 |
"/ cc == (ignore at:2) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4240 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4241 |
"/ (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4242 |
"/ skip := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4243 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4244 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4245 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4246 |
"/ cc == (ignore at:1) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4247 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4248 |
"/ (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4249 |
"/ skip := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4250 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4251 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4252 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4253 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4254 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4255 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4256 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4257 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4258 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4259 |
"/ ign ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4260 |
"/ ignoring := ignoring not |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4261 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4262 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4263 |
"/ ignoring ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4264 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4265 |
"/ (incSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4266 |
"/ nesting := nesting + 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4267 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4268 |
"/ (decSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4269 |
"/ nesting := nesting - 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4270 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4271 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4272 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4273 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4274 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4275 |
"/ nesting == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4276 |
"/ "check if legal" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4277 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4278 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4279 |
"/ cc == closingChar ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4280 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4281 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4282 |
"/ ^ foundBlock value:line value:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4283 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4284 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4285 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4286 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4287 |
"/ line := line + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4288 |
"/ (line < 1 or:[line > maxLine]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4289 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4290 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4291 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4292 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4293 |
"/ col := 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4294 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4295 |
"/ col := lineString size |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4296 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4297 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4298 |
"/ ^ notFoundBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4299 |
|
3478 | 4300 |
"Modified: / 12-04-2007 / 11:25:36 / cg" |
6099 | 4301 |
"Modified (comment): / 13-02-2017 / 20:32:30 / cg" |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4302 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4303 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4304 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
5791 | 4305 |
ifFound:foundBlock |
4306 |
ifNotFound:notFoundBlock |
|
4307 |
onError:failBlock |
|
4308 |
openingCharacters:openingCharacters |
|
4309 |
closingCharacters:closingCharacters |
|
4310 |
ignoredCharacters:ignoreSet |
|
4311 |
specialEOLComment:eolCommentSequence |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4312 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4313 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
6099 | 4314 |
Search for the corresponding character is done forward if it's an opening, |
4315 |
backwards if it's a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4316 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4317 |
If there is a nesting error, evaluate failBlock." |
248 | 4318 |
|
4500 | 4319 |
|i direction lineString |
6459 | 4320 |
parChar closingChar |
4500 | 4321 |
ignoring |
6459 | 4322 |
lineNr "{ Class: SmallInteger }" |
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
4323 |
col "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
4324 |
delta "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
4325 |
endCol "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
4326 |
runCol "{ Class: SmallInteger }" |
4500 | 4327 |
cc prevCC nextCC incSet decSet |
6456 | 4328 |
nesting |
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
4329 |
maxLine "{ Class: SmallInteger }" |
6459 | 4330 |
isIgnoreChar skip anySet |
6456 | 4331 |
eol1 eol2 inLineComment idx| |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4332 |
|
2772
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
4333 |
self assert:(openingCharacters size == closingCharacters size). |
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
4334 |
|
248 | 4335 |
parChar := self characterAtLine:startLine col:startCol. |
6459 | 4336 |
i := (openingCharacters , closingCharacters) indexOf:parChar. |
248 | 4337 |
i == 0 ifTrue:[ |
6459 | 4338 |
(ignoreSet includes:parChar) ifTrue:[ |
4339 |
"/ seaching for matching ' or " - always forward |
|
4340 |
direction := #fwd. |
|
4341 |
closingChar := parChar. |
|
4342 |
] ifFalse:[ |
|
4343 |
^ failBlock value "not a parenthesis" |
|
4344 |
]. |
|
4345 |
] ifFalse:[ |
|
4346 |
direction := (i <= openingCharacters size) ifTrue:[#fwd] ifFalse:[#bwd]. |
|
4347 |
closingChar := (closingCharacters , openingCharacters) at:i. |
|
248 | 4348 |
]. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4349 |
|
6456 | 4350 |
"nesting is a Stack containing {expected char . line number of found char} tuples" |
4351 |
nesting := Stack new. |
|
4352 |
nesting push:{closingChar. startLine}. |
|
4353 |
||
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4354 |
eol1 := eolCommentSequence at:1 ifAbsent:nil. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4355 |
eol2 := eolCommentSequence at:2 ifAbsent:nil. |
248 | 4356 |
|
4357 |
col := startCol. |
|
6459 | 4358 |
lineNr := startLine. |
248 | 4359 |
direction == #fwd ifTrue:[ |
5791 | 4360 |
delta := 1. |
4361 |
incSet := openingCharacters. |
|
4362 |
decSet := closingCharacters. |
|
248 | 4363 |
] ifFalse:[ |
5791 | 4364 |
delta := -1. |
4365 |
incSet := closingCharacters. |
|
4366 |
decSet := openingCharacters. |
|
248 | 4367 |
]. |
1454 | 4368 |
anySet := Set new. |
4369 |
anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
4370 |
anySet := (anySet select:[:c | c isCharacter]) asString. |
|
248 | 4371 |
|
6459 | 4372 |
ignoring := 0. |
4373 |
lineString := list at:lineNr. |
|
248 | 4374 |
maxLine := list size. |
4375 |
||
4376 |
col := col + delta. |
|
6456 | 4377 |
[nesting notEmpty] whileTrue:[ |
4378 |
(lineString notNil and:[lineString includesAny:anySet]) ifTrue:[ |
|
4379 |
inLineComment := false. |
|
5791 | 4380 |
direction == #fwd ifTrue:[ |
4381 |
endCol := lineString size. |
|
4382 |
] ifFalse:[ |
|
4383 |
endCol := 1 |
|
4384 |
]. |
|
4385 |
||
4386 |
col to:endCol by:delta do:[:rCol | |
|
4387 |
runCol := rCol. |
|
4388 |
cc := lineString at:runCol. |
|
4389 |
runCol < lineString size ifTrue:[ |
|
4390 |
nextCC := lineString at:runCol+1 |
|
4391 |
] ifFalse:[ |
|
4392 |
nextCC := nil |
|
4393 |
]. |
|
4394 |
runCol > 1 ifTrue:[ |
|
4395 |
prevCC := lineString at:runCol-1 |
|
4396 |
] ifFalse:[ |
|
4397 |
prevCC := nil |
|
4398 |
]. |
|
4399 |
||
6459 | 4400 |
isIgnoreChar := skip := false. |
5791 | 4401 |
|
6456 | 4402 |
(cc == eol1 and:[nextCC == eol2]) ifTrue:[ |
4403 |
"/ check for comments, do not search for a matching '"' in a "/ comment. |
|
6460 | 4404 |
direction == #fwd ifTrue:[ |
4405 |
inLineComment := skip := true. |
|
4406 |
] ifFalse:[ |
|
4407 |
[nesting notEmpty and:[nesting top second = lineNr]] whileTrue:[ |
|
4408 |
"while doing backward searching we have found a line comment |
|
4409 |
containing a opening/closing char" |
|
4410 |
nesting pop. |
|
4411 |
]. |
|
6456 | 4412 |
]. |
4413 |
] ifFalse:[prevCC == $$ ifTrue:[ |
|
4414 |
"/ do not search for a matching peer for $( or $[... |
|
5791 | 4415 |
skip := true. |
4416 |
] ifFalse:[ |
|
6459 | 4417 |
"if we started the search with an ignoreChar, do not ignore the same char" |
4418 |
cc ~= parChar ifTrue:[ |
|
4419 |
ignoreSet do:[:eachCharToIgnore | |
|
4420 |
eachCharToIgnore == cc ifTrue:[ |
|
4421 |
isIgnoreChar := true |
|
4422 |
] ifFalse:[ |
|
4423 |
eachCharToIgnore isString ifTrue:[ |
|
4424 |
cc == (eachCharToIgnore at:2) ifTrue:[ |
|
4425 |
runCol > 1 ifTrue:[ |
|
4426 |
(lineString at:(runCol-1)) == (eachCharToIgnore at:1) ifTrue:[ |
|
5791 | 4427 |
skip := true |
4428 |
] |
|
4429 |
] |
|
6459 | 4430 |
] ifFalse:[ |
4431 |
(cc == (eachCharToIgnore at:1) |
|
4432 |
and:[runCol < lineString size |
|
4433 |
and:[(lineString at:(runCol+1)) == (eachCharToIgnore at:2)]]) ifTrue:[ |
|
4434 |
skip := true |
|
4435 |
] |
|
4436 |
]. |
|
5791 | 4437 |
] |
4438 |
] |
|
4439 |
] |
|
6459 | 4440 |
]. |
6456 | 4441 |
]]. |
4442 |
||
6459 | 4443 |
(inLineComment not & isIgnoreChar) ifTrue:[ |
6475 | 4444 |
"/ Ãf in a line comment, single ' and " may occur. |
6459 | 4445 |
"/ ignoring ~~ 0 means, that we ignore non-matching peers. |
4446 |
(ignoring ~~ 0 and:[nesting top first = cc]) ifTrue:[ |
|
4447 |
ignoring := ignoring - 1. |
|
4448 |
nesting pop. |
|
6456 | 4449 |
] ifFalse:[ |
6459 | 4450 |
nesting push:{cc . lineNr}. |
4451 |
ignoring := ignoring + 1. |
|
6456 | 4452 |
]. |
5791 | 4453 |
]. |
4454 |
||
6459 | 4455 |
((ignoring ~~ 0) | skip | inLineComment) ifFalse:[ |
4456 |
((idx := incSet indexOf:cc) ~~ 0) ifTrue:[ |
|
4457 |
nesting push:{(decSet at:idx). lineNr}. |
|
6456 | 4458 |
] ifFalse:[ |
4459 |
(decSet includes:cc) ifTrue:[ |
|
4460 |
nesting pop first ~= cc ifTrue:[ |
|
4461 |
^ failBlock value. |
|
4462 |
]. |
|
6459 | 4463 |
] ifFalse:[ |
4464 |
"/ check for ' or " |
|
6467 | 4465 |
((ignoreSet includes:cc) |
4466 |
and:[nesting notEmpty |
|
4467 |
and:[nesting top first = cc]]) ifTrue:[ |
|
6459 | 4468 |
nesting pop. |
4469 |
]. |
|
4470 |
]. |
|
5791 | 4471 |
] |
4472 |
]. |
|
4473 |
||
6456 | 4474 |
nesting isEmpty ifTrue:[ |
5791 | 4475 |
skip ifFalse:[ |
6459 | 4476 |
^ foundBlock value:lineNr value:runCol. |
5791 | 4477 |
] |
6456 | 4478 |
]. |
5791 | 4479 |
]. |
4480 |
]. |
|
6459 | 4481 |
lineNr := lineNr + delta. |
4482 |
(lineNr < 1 or:[lineNr > maxLine]) ifTrue:[ |
|
5791 | 4483 |
^ failBlock value |
4484 |
]. |
|
6459 | 4485 |
lineString := list at:lineNr. |
5791 | 4486 |
direction == #fwd ifTrue:[ |
4487 |
col := 1 |
|
4488 |
] ifFalse:[ |
|
4489 |
col := lineString size |
|
4490 |
] |
|
248 | 4491 |
]. |
4492 |
^ notFoundBlock value |
|
4493 |
||
6099 | 4494 |
"Modified: / 15-10-1996 / 12:22:30 / cg" |
4495 |
"Modified (comment): / 13-02-2017 / 20:32:43 / cg" |
|
6460 | 4496 |
"Modified: / 22-10-2018 / 20:56:48 / Stefan Vogel" |
6467 | 4497 |
"Modified: / 25-10-2018 / 21:25:57 / Claus Gittinger" |
248 | 4498 |
! |
4499 |
||
4500 |
searchFwd |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4501 |
"search forward for the same pattern or selection again" |
248 | 4502 |
|
4399 | 4503 |
|ign match variable| |
1353 | 4504 |
|
2811 | 4505 |
searchAction notNil ifTrue:[ |
5791 | 4506 |
"/ autosearch is cleared whenever there is search with user selection |
4507 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4177 | 4508 |
]. |
4509 |
||
4510 |
searchAction notNil ifTrue:[ |
|
5791 | 4511 |
"/ confusing: this is for autosearch of variables (browse variable uses, for example) |
4512 |
self searchUsingSearchAction:#forward. |
|
4513 |
^ self. |
|
2807 | 4514 |
]. |
3981 | 4515 |
searchBarActionBlock notNil ifTrue:[ |
5791 | 4516 |
searchBarActionBlock value:#forward value:self. |
4517 |
^ self |
|
3581 | 4518 |
]. |
4399 | 4519 |
lastSearchWasVariableSearch ifTrue:[ |
5791 | 4520 |
variable := self syntaxElementForSelectedVariable. |
4521 |
variable notNil ifTrue:[ |
|
4522 |
self searchVariableWithSyntaxElement:variable forward:true. |
|
4523 |
^ self. |
|
4524 |
]. |
|
4525 |
lastSearchWasVariableSearch := false. |
|
4399 | 4526 |
]. |
3581 | 4527 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4528 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 4529 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
1353 | 4530 |
|
248 | 4531 |
selectStyle == #wordLeft ifTrue:[ |
5791 | 4532 |
" |
4533 |
remove the space from the selection |
|
4534 |
" |
|
4535 |
selectionStartCol := selectionStartCol + 1. |
|
4536 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
|
4537 |
selectStyle := #word. |
|
4538 |
self selectionChanged. |
|
248 | 4539 |
]. |
3577 | 4540 |
self setSearchPatternWithMatchEscapes: match. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4541 |
|
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4542 |
lastSearchPattern isNil ifTrue:[ |
6553 | 4543 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
5791 | 4544 |
lastSearchPattern := LastSearchPatterns first |
4545 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4546 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4547 |
|
1326 | 4548 |
lastSearchPattern notNil ifTrue:[ |
5791 | 4549 |
self rememberSearchPattern:lastSearchPattern. |
4550 |
lastSearchDirection := #forward. |
|
4551 |
self |
|
4552 |
searchFwd:lastSearchPattern |
|
4553 |
ignoreCase:ign |
|
4554 |
match: match |
|
248 | 4555 |
] |
1326 | 4556 |
|
4399 | 4557 |
"Modified: / 08-03-2012 / 14:25:42 / cg" |
6553 | 4558 |
"Modified: / 01-03-2019 / 16:14:26 / Claus Gittinger" |
248 | 4559 |
! |
4560 |
||
4561 |
searchFwd:pattern |
|
4562 |
"do a forward search" |
|
4563 |
||
4564 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4565 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4566 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4567 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4568 |
"Modified: / 21-09-2006 / 16:52:04 / cg" |
248 | 4569 |
! |
4570 |
||
4571 |
searchFwd:pattern ifAbsent:aBlock |
|
4572 |
"do a forward search" |
|
4573 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4574 |
self |
5791 | 4575 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4576 |
pattern:pattern) |
|
4577 |
ifAbsent:aBlock |
|
1326 | 4578 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4579 |
"Modified: / 21-09-2006 / 16:51:28 / cg" |
1326 | 4580 |
! |
4581 |
||
4582 |
searchFwd:pattern ignoreCase:ign |
|
4583 |
"do a forward search" |
|
4584 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4585 |
self |
5791 | 4586 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4587 |
pattern:pattern |
|
4588 |
ignoreCase:ign) |
|
4589 |
ifAbsent:[ |
|
4590 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4591 |
self showNotFound |
|
4592 |
]. |
|
4408 | 4593 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4594 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4595 |
|
4408 | 4596 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4597 |
"Modified: / 23-03-2012 / 12:09:59 / cg" |
|
1326 | 4598 |
! |
4599 |
||
4600 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
4601 |
"do a forward search" |
|
4602 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4603 |
self |
5791 | 4604 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4605 |
pattern:pattern |
|
4606 |
ignoreCase:ign) |
|
4607 |
ifAbsent:aBlock |
|
1326 | 4608 |
|
4609 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4610 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
248 | 4611 |
! |
4612 |
||
3577 | 4613 |
searchFwd:pattern ignoreCase:ign match: match |
4614 |
"do a forward search" |
|
4615 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4616 |
self |
5791 | 4617 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4618 |
pattern:pattern |
|
4619 |
ignoreCase:ign |
|
4620 |
match:match) |
|
4621 |
ifAbsent:[ |
|
4622 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4623 |
self showNotFound |
|
4624 |
]. |
|
4408 | 4625 |
"/ lastSearchIgnoredCase := ign. |
4626 |
"/ lastSearchWasMatch := match. |
|
3577 | 4627 |
lastSearchPattern := pattern string |
4628 |
||
4408 | 4629 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4630 |
"Modified: / 23-03-2012 / 12:12:47 / cg" |
|
3577 | 4631 |
! |
4632 |
||
4633 |
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock |
|
4634 |
"do a forward search" |
|
4635 |
||
4500 | 4636 |
self |
5791 | 4637 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4638 |
pattern:pattern |
|
4639 |
ignoreCase:ign |
|
4640 |
match:match) |
|
4641 |
ifAbsent:aBlock |
|
3581 | 4642 |
|
4643 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4644 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
4645 |
! |
|
4646 |
||
4647 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
4648 |
"do a forward search" |
|
4649 |
||
4500 | 4650 |
self |
5791 | 4651 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4652 |
pattern:pattern |
|
4653 |
ignoreCase:ign |
|
4654 |
match:match) |
|
4655 |
startingAtLine:startLine col:startCol |
|
4656 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4657 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4658 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4659 |
searchFwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4660 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4661 |
|
4500 | 4662 |
self |
5791 | 4663 |
searchFwdUsingSpec:searchSpec |
4664 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4665 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4666 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4667 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4668 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4669 |
"Modified: / 21-09-2006 / 16:52:04 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4670 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4671 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4672 |
searchFwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4673 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4674 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4675 |
|pos startLine startCol| |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4676 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4677 |
pos := self startPositionForSearchForward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4678 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4679 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4680 |
|
4500 | 4681 |
self |
5791 | 4682 |
searchFwdUsingSpec:searchSpec |
4683 |
startingAtLine:startLine col:startCol |
|
4684 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4685 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4686 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4687 |
"Created: 13.9.1997 / 06:18:27 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4688 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4689 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4690 |
searchFwdUsingSpec:searchSpec startingAtLine:startLine col:startCol ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4691 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4692 |
|
4500 | 4693 |
self |
5791 | 4694 |
searchForwardUsingSpec:searchSpec |
4695 |
startingAtLine:startLine col:startCol |
|
4696 |
ifFound:[:line :col :endColOrNil| |
|
4697 |
self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil |
|
4698 |
] |
|
4699 |
ifAbsent:aBlock |
|
3577 | 4700 |
! |
4701 |
||
248 | 4702 |
searchPattern |
4703 |
"return the last search pattern" |
|
4704 |
||
1326 | 4705 |
^ lastSearchPattern |
248 | 4706 |
! |
4707 |
||
2807 | 4708 |
searchUsingSearchAction:direction |
5714 | 4709 |
"search using a searchaction which has been given by someone else. |
4710 |
Typically, this is the embedding browser, which has provided an action for |
|
4711 |
a language aware search (as opposed to a naive string search)" |
|
4712 |
||
4500 | 4713 |
self |
5791 | 4714 |
searchUsingSearchAction:direction |
4715 |
ifAbsent:[ |
|
4716 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4717 |
self showNotFound |
|
4718 |
] |
|
2816 | 4719 |
! |
4720 |
||
4721 |
searchUsingSearchAction:direction ifAbsent:notFoundAction |
|
5714 | 4722 |
"search using a searchaction which has been given by someone else. |
4723 |
Typically, this is the embedding browser, which has provided an action for |
|
4724 |
a language aware search (as opposed to a naive string search)" |
|
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
4725 |
|
2807 | 4726 |
|pos startLine startCol| |
4727 |
||
4500 | 4728 |
pos := direction == #backward |
5791 | 4729 |
ifTrue:[self startPositionForSearchBackward] |
4730 |
ifFalse:[self startPositionForSearchForward]. |
|
2807 | 4731 |
startLine := pos y. |
4732 |
startCol := pos x. |
|
4733 |
||
4734 |
searchAction notNil ifTrue:[ |
|
5791 | 4735 |
searchAction |
4736 |
value:direction |
|
4737 |
value:startLine |
|
4738 |
value:startCol |
|
4739 |
value:[:line :col | self selectFromLine:line toLine:line] |
|
4740 |
value:notFoundAction. |
|
4741 |
self hasSelection ifTrue: [ |
|
4742 |
self changeTypeOfSelectionTo: #searchAction. |
|
4743 |
]. |
|
2807 | 4744 |
]. |
4745 |
! |
|
4746 |
||
248 | 4747 |
setSearchPattern |
4748 |
"set the searchpattern from the selection if there is one" |
|
4749 |
||
3577 | 4750 |
self setSearchPatternWithMatchEscapes: false. |
248 | 4751 |
! |
4752 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4753 |
setSearchPattern:aStringOrNil |
248 | 4754 |
"set the searchpattern for future searches" |
4755 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4756 |
aStringOrNil isEmptyOrNil ifTrue:[ |
5791 | 4757 |
lastSearchPattern := nil. |
248 | 4758 |
] ifFalse:[ |
5791 | 4759 |
"/ not withoutSeparators: may want to search for spaces... |
4760 |
lastSearchPattern := aStringOrNil asString "withoutSeparators" string. |
|
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4761 |
]. |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4762 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4763 |
"Modified: / 6.3.1999 / 23:47:36 / cg" |
248 | 4764 |
! |
4765 |
||
2200 | 4766 |
setSearchPattern:aString ignoreCase:aBoolean |
4767 |
"set the searchpattern and caseIgnore for future searches" |
|
4768 |
||
4769 |
self setSearchPattern:aString. |
|
4770 |
lastSearchIgnoredCase := aBoolean. |
|
4771 |
! |
|
4772 |
||
5713 | 4773 |
setSearchPattern:aString ignoreCase:ignoreCaseBoolean match:matchBoolean |
4774 |
"set the searchpattern and caseIgnore for future searches" |
|
4775 |
||
4776 |
self setSearchPattern:aString. |
|
4777 |
lastSearchIgnoredCase := ignoreCaseBoolean. |
|
4778 |
lastSearchWasMatch := matchBoolean. |
|
4779 |
! |
|
4780 |
||
3577 | 4781 |
setSearchPatternWithMatchEscapes: match |
4782 |
"set the searchpattern from the selection if there is one" |
|
4783 |
||
4784 |
|sel searchPattern | |
|
4785 |
||
4786 |
"/ clickPos isNil ifTrue:[^ self]. |
|
4787 |
||
4788 |
sel := self selection. |
|
4789 |
sel notNil ifTrue:[ |
|
5791 | 4790 |
searchPattern := sel asString. |
4791 |
match ifTrue:[searchPattern := searchPattern withMatchEscapes]. |
|
4792 |
self setSearchPattern:searchPattern. |
|
3577 | 4793 |
] |
4794 |
||
4795 |
"Modified: / 6.3.1999 / 23:48:04 / cg" |
|
4796 |
! |
|
4797 |
||
248 | 4798 |
showMatch:pattern atLine:line col:col |
5716 | 4799 |
<resource: #obsolete> |
248 | 4800 |
"after a search, highlight the matched pattern. |
4801 |
The code below needs a rewrite to take care of match-characters |
|
4802 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4803 |
||
5716 | 4804 |
self showMatch:pattern isMatch:true atLine:line col:col endCol:nil |
4120 | 4805 |
! |
4806 |
||
4807 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
|
5716 | 4808 |
<resource: #obsolete> |
4809 |
"after a search, highlight the matched pattern." |
|
4810 |
||
4811 |
self showMatch:pattern isMatch:isMatch atLine:line col:col endCol:nil |
|
4812 |
! |
|
4813 |
||
4814 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
|
4120 | 4815 |
"after a search, highlight the matched pattern. |
4816 |
The code below needs a rewrite to take care of match-characters |
|
4817 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4818 |
||
5716 | 4819 |
|endCol realPattern| |
4820 |
||
4821 |
(endCol := encColOrNil) isNil ifTrue:[ |
|
5791 | 4822 |
"/ a hack. |
4823 |
realPattern := pattern. |
|
4824 |
isMatch ifTrue: [ |
|
4825 |
(realPattern startsWith:$*) ifTrue:[ |
|
4826 |
realPattern := realPattern copyButFirst |
|
4827 |
]. |
|
4828 |
(realPattern endsWith:$*) ifTrue:[ |
|
4829 |
realPattern := realPattern copyButLast |
|
4830 |
]. |
|
4831 |
]. |
|
4832 |
endCol := (col + realPattern size - 1). |
|
248 | 4833 |
]. |
4834 |
||
5716 | 4835 |
self selectFromLine:line col:col toLine:line col:endCol. |
248 | 4836 |
self makeLineVisible:line |
4837 |
! |
|
4838 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4839 |
startPositionForSearchBackward |
2822 | 4840 |
^ self startPositionForSearchBackwardBasedOnSelection |
4841 |
! |
|
4842 |
||
4843 |
startPositionForSearchBackwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4844 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4845 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4846 |
selectionStartLine notNil ifTrue:[ |
5791 | 4847 |
startLine := selectionStartLine. |
4848 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4849 |
] ifFalse:[ |
5791 | 4850 |
startLine := 1. |
4851 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4852 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4853 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4854 |
^ startCol @ startLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4855 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4856 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4857 |
startPositionForSearchForward |
2822 | 4858 |
^ self startPositionForSearchForwardBasedOnSelection |
4859 |
! |
|
4860 |
||
4861 |
startPositionForSearchForwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4862 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4863 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4864 |
selectionStartLine notNil ifTrue:[ |
5791 | 4865 |
startLine := selectionStartLine. |
4866 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4867 |
] ifFalse:[ |
5791 | 4868 |
startLine := 1. |
4869 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4870 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4871 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4872 |
^ startCol @ startLine |
248 | 4873 |
! ! |
4874 |
||
4875 |
!TextView methodsFor:'selections'! |
|
4876 |
||
2604
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4877 |
changeTypeOfSelectionTo:newType |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4878 |
"ignored here - but redefined in subclasses which |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4879 |
differentiate between pasted- and user-selections" |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4880 |
! |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4881 |
|
458 | 4882 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4883 |
|l t| |
458 | 4884 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4885 |
selectionStartLine notNil ifTrue:[ |
5791 | 4886 |
expandingTop == true ifTrue:[ |
4887 |
l := selectionStartLine. |
|
4888 |
selectionStartLine := selectionStartLine + 1. |
|
4889 |
(selectionStartLine > clickLine |
|
4890 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
|
4891 |
ifTrue:[ |
|
4892 |
t := selectionStartLine. |
|
4893 |
selectionStartLine := selectionEndLine. |
|
4894 |
selectionEndLine := t. |
|
4895 |
t := selectionStartCol. |
|
4896 |
selectionStartCol := selectionEndCol. |
|
4897 |
selectionEndCol := t. |
|
4898 |
expandingTop := false |
|
4899 |
]. |
|
4900 |
] ifFalse:[ |
|
4901 |
l := selectionEndLine. |
|
4902 |
selectionEndLine := selectionEndLine + 1. |
|
4903 |
]. |
|
4500 | 4904 |
"/ self redrawLine:l. |
2442 | 4905 |
"/ self redrawLine:l+1. |
5791 | 4906 |
self validateNewSelection. |
4907 |
self setPrimarySelection. |
|
4908 |
self selectionChanged. |
|
4909 |
self redrawFromLine:l to:l+1. |
|
4910 |
self makeSelectionVisible. |
|
458 | 4911 |
]. |
4912 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4913 |
"Created: / 01-03-1996 / 23:35:08 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4914 |
"Modified: / 18-03-1996 / 17:18:15 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4915 |
"Modified: / 17-04-2012 / 21:01:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4916 |
! |
4917 |
||
4918 |
expandSelectionLeft |
|
502 | 4919 |
|c l t c1 c2| |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4920 |
|
458 | 4921 |
selectionStartLine notNil ifTrue:[ |
5791 | 4922 |
expandingTop == true ifTrue:[ |
4923 |
selectionStartCol == 0 ifTrue:[^ self]. |
|
4924 |
l := selectionStartLine. |
|
4925 |
selectionStartCol := (selectionStartCol - 1) max:1. |
|
4926 |
c := selectionStartCol. |
|
4927 |
] ifFalse:[ |
|
4928 |
l := selectionEndLine. |
|
4929 |
selectionEndCol := (selectionEndCol - 1) max:0. |
|
4930 |
c := selectionEndCol. |
|
4931 |
selectionEndLine == selectionStartLine ifTrue:[ |
|
4932 |
selectionEndCol <= selectionStartCol ifTrue:[ |
|
4933 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4934 |
selectionEndCol := t. |
|
4935 |
expandingTop := true. |
|
4936 |
c := selectionStartCol. |
|
4937 |
] |
|
4938 |
]. |
|
4939 |
]. |
|
4940 |
c1 := c. |
|
4941 |
c2 := c1 + 1. |
|
4942 |
c1 == 0 ifTrue:[ |
|
4943 |
c1 := 1 |
|
4944 |
]. |
|
4945 |
self validateNewSelection. |
|
4946 |
self setPrimarySelection. |
|
4947 |
self selectionChanged. |
|
4948 |
self redrawLine:l from:c1 to:c2. |
|
4949 |
self makeSelectionVisible. |
|
458 | 4950 |
]. |
4951 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4952 |
"Modified: / 18-03-1996 / 17:05:46 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4953 |
"Modified: / 17-04-2012 / 21:01:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4954 |
! |
4955 |
||
4956 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4957 |
|l c t| |
458 | 4958 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4959 |
selectionStartLine notNil ifTrue:[ |
5791 | 4960 |
expandingTop == true ifTrue:[ |
4961 |
l := selectionStartLine. |
|
4962 |
c := selectionStartCol. |
|
4963 |
selectionStartCol := selectionStartCol + 1. |
|
4964 |
l == selectionEndLine ifTrue:[ |
|
4965 |
c >= selectionEndCol ifTrue:[ |
|
4966 |
expandingTop := false. |
|
4967 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4968 |
selectionEndCol := t. |
|
4969 |
c := selectionStartCol. |
|
4970 |
] |
|
4971 |
] |
|
4972 |
] ifFalse:[ |
|
4973 |
l := selectionEndLine. |
|
4974 |
c := selectionEndCol. |
|
4975 |
selectionEndCol := selectionEndCol + 1. |
|
4976 |
]. |
|
4977 |
||
4978 |
self validateNewSelection. |
|
4979 |
self setPrimarySelection. |
|
4980 |
self selectionChanged. |
|
4981 |
self redrawLine:l from:(c max:1) to:c+1. |
|
4982 |
self makeSelectionVisible. |
|
458 | 4983 |
]. |
4984 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4985 |
"Created: / 01-03-1996 / 23:33:17 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4986 |
"Modified: / 06-03-1996 / 13:54:10 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4987 |
"Modified: / 17-04-2012 / 21:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4988 |
! |
4989 |
||
4990 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4991 |
|l t| |
458 | 4992 |
|
4993 |
selectionStartLine notNil ifTrue:[ |
|
5791 | 4994 |
expandingTop == true ifTrue:[ |
4995 |
selectionStartLine := (selectionStartLine - 1) max:1. |
|
4996 |
l := selectionStartLine. |
|
4997 |
] ifFalse:[ |
|
4998 |
selectionEndLine := (selectionEndLine - 1) max:0. |
|
4999 |
||
5000 |
l := selectionEndLine. |
|
5001 |
(selectionEndLine < clickLine |
|
6454 | 5002 |
or:[(selectionEndLine == clickLine |
5003 |
and:[clickCol notNil |
|
5004 |
and:[selectionEndCol < clickCol]])] |
|
5005 |
) ifTrue:[ |
|
5791 | 5006 |
t := selectionStartLine. |
5007 |
selectionStartLine := selectionEndLine. |
|
5008 |
selectionEndLine := t. |
|
5009 |
t := selectionStartCol. |
|
5010 |
selectionStartCol := selectionEndCol. |
|
5011 |
selectionEndCol := t. |
|
5012 |
l := selectionStartLine. |
|
5013 |
expandingTop := true |
|
5014 |
]. |
|
5015 |
]. |
|
5016 |
self validateNewSelection. |
|
5017 |
self setPrimarySelection. |
|
5018 |
self selectionChanged. |
|
5019 |
"/ self redrawLine:l. |
|
5020 |
"/ self redrawLine:l+1. |
|
5021 |
self redrawFromLine:l to:l+1. |
|
5022 |
self makeSelectionVisible. |
|
458 | 5023 |
]. |
5024 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5025 |
"Modified: / 06-03-1996 / 14:12:06 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5026 |
"Modified: / 17-04-2012 / 21:01:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 5027 |
! |
5028 |
||
248 | 5029 |
hasSelection |
6261 | 5030 |
"return true, if there is a text selection" |
248 | 5031 |
|
5032 |
^ selectionStartLine notNil |
|
5033 |
! |
|
5034 |
||
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5035 |
hasSelectionForCopy |
6282 | 5036 |
"return true, if there is a selection which can be copied |
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5037 |
(the same as #hasSelection, except for editfields in password-mode)" |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5038 |
|
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5039 |
^ self hasSelection |
6282 | 5040 |
|
5041 |
"Modified (comment): / 29-01-2018 / 14:42:52 / mawalch" |
|
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5042 |
! |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
5043 |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5044 |
hasSelectionWithinSingleLine |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5045 |
"return true, if there is a selection and it is within a line" |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5046 |
|
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5047 |
^ selectionStartLine notNil |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5048 |
and:[ selectionStartLine == selectionEndLine ] |
3315 | 5049 |
|
5050 |
"Modified: / 04-07-2006 / 18:42:59 / fm" |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5051 |
! |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
5052 |
|
5004 | 5053 |
hasSingleFullLineSelected |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
5054 |
^ (selectionStartLine notNil |
5004 | 5055 |
and:[selectionEndLine notNil |
5789
a6db617369e9
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
5786
diff
changeset
|
5056 |
and:[selectionEndLine == (selectionStartLine+1) |
5004 | 5057 |
and:[selectionStartCol == 1 |
5058 |
and:[selectionEndCol == 0 |
|
5059 |
]]]]) |
|
5060 |
! |
|
5061 |
||
2588 | 5062 |
isInSelection:line col:aColNr |
5063 |
"returns true, if the line, and column is in the selection |
|
5064 |
" |
|
3438 | 5065 |
selectionStartLine isNil ifTrue:[^ false]. |
5066 |
selectionEndLine isNil ifTrue:[^ false]. |
|
2588 | 5067 |
|
5068 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
|
5791 | 5069 |
^ false |
2588 | 5070 |
]. |
5071 |
||
5072 |
line == selectionStartLine ifTrue:[ |
|
5791 | 5073 |
aColNr < selectionStartCol ifTrue:[^ false] |
2588 | 5074 |
]. |
5075 |
||
5076 |
line == selectionEndLine ifTrue:[ |
|
5791 | 5077 |
(selectionEndCol ~~ 0 and:[selectionEndCol < aColNr]) ifTrue:[^ false] |
2588 | 5078 |
]. |
5079 |
^ true |
|
5080 |
! |
|
5081 |
||
248 | 5082 |
makeSelectionVisible |
5083 |
"scroll to make the selection visible" |
|
5084 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
5085 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
5086 |
|
248 | 5087 |
selectionStartLine notNil ifTrue:[ |
5791 | 5088 |
expandingTop == true ifTrue:[ |
5089 |
line := selectionStartLine. |
|
5090 |
col := selectionStartCol. |
|
5091 |
] ifFalse:[ |
|
5092 |
line := selectionEndLine. |
|
5093 |
col := selectionEndCol. |
|
5094 |
]. |
|
5095 |
self makeLineVisible:line. |
|
5096 |
self makeColVisible:col inLine:line. |
|
248 | 5097 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
5098 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
5099 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 5100 |
! |
5101 |
||
5102 |
selectAll |
|
5103 |
"select the whole text" |
|
5104 |
||
5105 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
5106 |
! |
|
5107 |
||
4140
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5108 |
selectFromCharacterPosition:pos1 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5109 |
"compute line/col from the character position and select the text up to the end" |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5110 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5111 |
|line1 col1 line2 col2| |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5112 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5113 |
line1 := self lineOfCharacterPosition:pos1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5114 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5115 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5116 |
line2 := (list size + 1). |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5117 |
col2 := 0. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5118 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5119 |
! |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
5120 |
|
248 | 5121 |
selectFromCharacterPosition:pos1 to:pos2 |
5122 |
"compute line/col from character positions and select the text" |
|
5123 |
||
5124 |
|line1 col1 line2 col2| |
|
5125 |
||
4554 | 5126 |
pos1 > pos2 ifTrue:[ |
5791 | 5127 |
^ self unselect |
4554 | 5128 |
]. |
248 | 5129 |
line1 := self lineOfCharacterPosition:pos1. |
5130 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
4554 | 5131 |
col1 < 1 ifTrue:[ col1 := 1 ]. |
5132 |
||
248 | 5133 |
line2 := self lineOfCharacterPosition:pos2. |
5134 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
4554 | 5135 |
col2 < 1 ifTrue:[ col2 := 1 ]. |
248 | 5136 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
5137 |
! |
|
5138 |
||
5139 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
5140 |
"select a piece of text and redraw that area" |
|
5141 |
||
5046 | 5142 |
((selectionStartLine = startLine) |
5143 |
and:[ (selectionStartCol = startCol) |
|
5144 |
and:[ (selectionEndLine = endLine) |
|
5145 |
and:[ (selectionEndCol = endCol) ]]]) ifTrue:[^ self ]. |
|
5146 |
||
248 | 5147 |
self unselect. |
5148 |
startLine notNil ifTrue:[ |
|
5791 | 5149 |
"new:" |
5150 |
endLine < startLine ifTrue:[ |
|
5151 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
|
5152 |
]. |
|
5153 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
|
5154 |
endCol ~~ 0 ifTrue:[ |
|
5155 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
|
5156 |
]. |
|
5157 |
^ self |
|
5158 |
]. |
|
248 | 5159 |
|
5160 |
" old: |
|
5791 | 5161 |
endLine < startLine ifTrue:[^ self]. |
5162 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
|
248 | 5163 |
" |
5791 | 5164 |
selectionStartLine := startLine. |
5165 |
selectionStartCol := startCol. |
|
5166 |
selectionEndLine := endLine. |
|
5167 |
selectionEndCol := endCol. |
|
5168 |
self validateNewSelection. |
|
5169 |
self setPrimarySelection. |
|
5170 |
self selectionChanged. |
|
5171 |
||
5172 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
5173 |
self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol |
|
5174 |
] ifFalse:[ |
|
5175 |
selectionStartLine to:selectionEndLine do:[:lineNr | |
|
5176 |
self redrawLine:lineNr |
|
5177 |
] |
|
5178 |
]. |
|
5179 |
selectStyle := nil. |
|
248 | 5180 |
] |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5181 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5182 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5183 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5184 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5185 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5186 |
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
|
5187 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5188 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5189 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5190 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5191 |
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
|
5192 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5193 |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5194 |
"Modified: / 02-01-1997 / 13:32:25 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5195 |
"Modified: / 17-04-2012 / 21:00:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5196 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5197 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5198 |
selectFromLine:startLine toLine:endLine |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5199 |
"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
|
5200 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5201 |
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
|
5202 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5203 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5204 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5205 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5206 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5207 |
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
|
5208 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5209 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5210 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5211 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5212 |
v selectFromLine:2 toLine:10 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5213 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5214 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5215 |
"Modified: 29.4.1996 / 12:23:46 / cg" |
248 | 5216 |
! |
5217 |
||
5218 |
selectLine:selectLine |
|
5219 |
"select one line and redraw it" |
|
5220 |
||
5221 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
5222 |
wordStartCol := selectionStartCol. |
|
5223 |
wordEndCol := selectionEndCol. |
|
5224 |
wordStartLine := selectionStartLine. |
|
5225 |
wordEndLine := selectionEndLine. |
|
5226 |
selectStyle := #line |
|
5227 |
! |
|
5228 |
||
5229 |
selectLineAtY:y |
|
5230 |
"select the line at given y-(view-)coordinate" |
|
5231 |
||
2413 | 5232 |
|selectLine| |
5233 |
||
5234 |
selectLine := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y). |
|
248 | 5235 |
selectLine notNil ifTrue:[ |
5791 | 5236 |
self selectLine:selectLine |
248 | 5237 |
] |
5238 |
! |
|
5239 |
||
5240 |
selectLineWhereCharacterPosition:pos |
|
5241 |
"select the line, where characterPosition pos is living. |
|
5242 |
The argument pos starts at 1 from the start of the text |
|
4500 | 5243 |
and counts characters (i.e. can be used to convert from |
248 | 5244 |
character position within a string to line-position in view)." |
5245 |
||
5246 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
5247 |
! |
|
5248 |
||
5249 |
selectWordAtLine:line col:col |
|
5250 |
"select the word at given line/col" |
|
5251 |
||
4500 | 5252 |
self |
5791 | 5253 |
wordAtLine:line col:col do:[ |
5254 |
:beginLine :beginCol :endLine :endCol :style | |
|
5255 |
||
5256 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5257 |
selectStyle := style |
|
5258 |
] |
|
504 | 5259 |
|
5260 |
"Modified: 18.3.1996 / 17:30:38 / cg" |
|
248 | 5261 |
! |
5262 |
||
5263 |
selectWordAtX:x y:y |
|
5264 |
"select the word at given x/y-(view-)coordinate" |
|
5265 |
||
5266 |
|selectVisibleLine selectLine selectCol| |
|
5267 |
||
5268 |
selectStyle := nil. |
|
5269 |
selectVisibleLine := self visibleLineOfY:y. |
|
5270 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
5271 |
selectLine notNil ifTrue:[ |
|
5791 | 5272 |
selectCol := self colOfX:x inVisibleLine:selectVisibleLine. |
5273 |
self selectWordAtLine:selectLine col:selectCol |
|
248 | 5274 |
] |
1661
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
5275 |
|
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
5276 |
"Modified: / 8.9.1998 / 21:22:46 / cg" |
248 | 5277 |
! |
5278 |
||
3528 | 5279 |
selectedInterval |
5280 |
"return the selection-boundaries as interval" |
|
5281 |
||
5282 |
^ self selectionStartIndex to:(self selectionStopIndex - 1) |
|
5283 |
! |
|
5284 |
||
248 | 5285 |
selection |
5286 |
"return the selection as a collection of (line-)strings. |
|
5287 |
If the selection ends in a full line, the last entry in the returned |
|
5288 |
collection will be an empty string." |
|
5289 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5290 |
|sel| |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5291 |
|
248 | 5292 |
selectionStartLine isNil ifTrue:[^ nil]. |
4466 | 5293 |
sel := self textFromLine:selectionStartLine col:(selectionStartCol max:1) toLine:selectionEndLine col:selectionEndCol. |
5391 | 5294 |
sel notEmptyOrNil ifTrue:[ |
5791 | 5295 |
"/ this is rubbish; we are now always using unicode internally |
6269 | 5296 |
"/ and many more conversions would be needed at many places... |
5297 |
gc characterEncoding ~~ #'iso10646-1' ifTrue:[ |
|
5791 | 5298 |
sel := sel encodeFrom:gc characterEncoding into:#'iso10646-1' |
5299 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5300 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5301 |
^ sel |
2158
1fbe3297506f
generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
2120
diff
changeset
|
5302 |
|
4361
646cd7c5513e
comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
5303 |
"Modified (comment): / 25-01-2012 / 00:29:09 / cg" |
6269 | 5304 |
"Modified: / 19-01-2018 / 12:22:31 / stefan" |
248 | 5305 |
! |
5306 |
||
2217 | 5307 |
selectionAsString |
5308 |
"return the selection as a String (i.e. without emphasis)" |
|
5309 |
||
2693 | 5310 |
|sel| |
2217 | 5311 |
|
5312 |
(sel := self selection) isNil ifTrue:[^ nil]. |
|
2419 | 5313 |
sel := sel collect:[:each| each isNil ifTrue:[nil] ifFalse:[each string]]. |
2217 | 5314 |
^ (sel asStringWithCRsFrom:1 to:(sel size) compressTabs:false withCR:false) string |
5315 |
! |
|
5316 |
||
4101 | 5317 |
selectionChanged |
5658 | 5318 |
"can be redefined for notification or special actions. |
5319 |
If you do, do not forget to do a super selectionChanged" |
|
5320 |
||
5321 |
self changed:#selection. |
|
5322 |
"/ self selectionHolder value:{ selectionStartCol @ selectionStartLine . |
|
5323 |
"/ selectionEndCol @ selectionEndLine } |
|
4101 | 5324 |
! |
5325 |
||
248 | 5326 |
selectionEndCol |
5327 |
^ selectionEndCol |
|
5328 |
! |
|
5329 |
||
5330 |
selectionEndLine |
|
5331 |
^ selectionEndLine |
|
5332 |
! |
|
5333 |
||
5334 |
selectionStartCol |
|
5335 |
^ selectionStartCol |
|
5336 |
! |
|
5337 |
||
5338 |
selectionStartLine |
|
5339 |
^ selectionStartLine |
|
5340 |
! |
|
5341 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5342 |
setPrimarySelection |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5343 |
"can be redefined for notification or special actions" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5344 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5345 |
device notNil ifTrue:[ |
6312 | 5346 |
"On X11, be nice and set the PRIMARY selection; |
5347 |
this can be pasted with the middle button into an xpterm. |
|
5791 | 5348 |
(#setPrimaryText:ownerView: is void in DeviceWorkstation)" |
6312 | 5349 |
device setPrimaryText:(self selectionAsString) ownerView: self. |
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5350 |
]. |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5351 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5352 |
"Created: / 17-04-2012 / 20:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5353 |
! |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
5354 |
|
3308 | 5355 |
st80SelectMode |
3459 | 5356 |
st80SelectMode notNil ifTrue:[^ st80SelectMode]. |
5357 |
^ self class st80SelectMode |
|
3308 | 5358 |
|
5359 |
"Created: / 03-07-2006 / 16:30:59 / cg" |
|
5360 |
! |
|
5361 |
||
3459 | 5362 |
st80SelectMode:aBoolean |
5363 |
st80SelectMode := aBoolean |
|
5364 |
! |
|
5365 |
||
248 | 5366 |
unselect |
5367 |
"unselect - if there was a selection redraw that area" |
|
5368 |
||
5369 |
|startLine endLine startVisLine endVisLine| |
|
5370 |
||
5371 |
selectionStartLine notNil ifTrue:[ |
|
5791 | 5372 |
startLine := selectionStartLine. |
5373 |
endLine := selectionEndLine. |
|
5374 |
||
5375 |
self unselectWithoutRedraw. |
|
5376 |
||
5377 |
"/ if the selection is not visible, we are done |
|
5378 |
||
5379 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
|
5380 |
endLine < firstLineShown ifTrue:[^ self]. |
|
5381 |
||
5382 |
startLine < firstLineShown ifTrue:[ |
|
5383 |
startVisLine := 1 |
|
5384 |
] ifFalse:[ |
|
5385 |
startVisLine := self listLineToVisibleLine:startLine |
|
5386 |
]. |
|
5387 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
|
5388 |
endVisLine := nLinesShown |
|
5389 |
] ifFalse:[ |
|
5390 |
endVisLine := self listLineToVisibleLine:endLine |
|
5391 |
]. |
|
5392 |
||
6099 | 5393 |
"/ if it's only part of a line, just redraw what has to be |
5791 | 5394 |
|
5395 |
(startLine == endLine) ifTrue:[ |
|
5396 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
|
5397 |
] ifFalse:[ |
|
5398 |
self redrawFromVisibleLine:startVisLine to:endVisLine |
|
5399 |
]. |
|
248 | 5400 |
]. |
5401 |
selectStyle := nil |
|
503 | 5402 |
|
6099 | 5403 |
"Modified: / 29-05-1996 / 14:54:11 / cg" |
5404 |
"Modified (comment): / 13-02-2017 / 20:32:49 / cg" |
|
248 | 5405 |
! |
5406 |
||
5407 |
unselectWithoutRedraw |
|
5408 |
"forget selection but do not redraw the selection area |
|
5409 |
- 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
|
5410 |
known to be invisible (however, redraw knows about that anyway)." |
248 | 5411 |
|
2735 | 5412 |
selectionStartLine := selectionEndLine := nil. |
4101 | 5413 |
self selectionChanged. |
248 | 5414 |
! |
5415 |
||
5416 |
validateNewSelection |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5417 |
"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
|
5418 |
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
|
5419 |
may redefine it to limit the selection to a single line, or whatever." |
248 | 5420 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5421 |
^ self |
504 | 5422 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
5423 |
"Modified: 29.4.1996 / 12:32:08 / cg" |
5378 | 5424 |
! |
5425 |
||
5426 |
withSelectionForeground:hilightFg background:hilightBg do:aBlock |
|
5427 |
"evaluate aBlock while the selection is shown highlighted with colors passed as args." |
|
5428 |
||
5429 |
|oldFg oldBg| |
|
5430 |
||
5431 |
" |
|
5432 |
change color of selection & hide cursor |
|
5433 |
" |
|
5434 |
oldFg := selectionFgColor. |
|
5435 |
oldBg := selectionBgColor. |
|
5436 |
selectionBgColor := hilightBg. |
|
5437 |
selectionFgColor := hilightFg. |
|
5438 |
||
5439 |
expandingTop := true. "/ hack to make the top of the selection visible |
|
5440 |
self makeSelectionVisible. |
|
5441 |
selectionStartLine notNil ifTrue:[ |
|
5791 | 5442 |
selectionEndLine notNil ifTrue:[ |
5443 |
self redrawFromLine:selectionStartLine to:selectionEndLine. |
|
5444 |
]. |
|
5378 | 5445 |
]. |
5446 |
self flush. |
|
5447 |
||
5448 |
aBlock ensure:[ |
|
5791 | 5449 |
" |
5450 |
undo selection color change and show cursor again |
|
5451 |
" |
|
5452 |
selectionFgColor := oldFg. |
|
5453 |
selectionBgColor := oldBg. |
|
5378 | 5454 |
]. |
248 | 5455 |
! ! |
5456 |
||
4310 | 5457 |
!TextView methodsFor:'testing'! |
5458 |
||
5459 |
isTextView |
|
5460 |
"I am showing text" |
|
5461 |
||
5462 |
^ true |
|
5463 |
! ! |
|
5464 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
5465 |
!TextView class methodsFor:'documentation'! |
248 | 5466 |
|
5467 |
version |
|
5374 | 5468 |
^ '$Header$' |
3964 | 5469 |
! |
5470 |
||
5471 |
version_CVS |
|
5374 | 5472 |
^ '$Header$' |
248 | 5473 |
! ! |
2630
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
5474 |
|
4485 | 5475 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
5476 |
TextView initialize! |