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