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