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