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