author | ca |
Sat, 20 Apr 1996 14:40:11 +0200 | |
changeset 152 | afffa460256a |
parent 136 | e1a32c55876a |
child 158 | 431e38dfc5ab |
permissions | -rw-r--r-- |
12 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 | 3 |
All Rights Reserved |
12 | 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 |
||
136 | 13 |
EditField subclass:#FilenameEditField |
14 |
instanceVariableNames:'directoriesOnly filesOnly directory' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Text' |
|
12 | 18 |
! |
19 |
||
20 |
!FilenameEditField class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 | 25 |
All Rights Reserved |
12 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
24 | 38 |
like a normal editField, but does filename-completion on the last word of |
39 |
the contents, when TAB is pressed. |
|
43 | 40 |
Filename completion ignores regular files if directoriesOnly is true, |
41 |
and ignores directories, if filesOnly is true. Both default to false. |
|
12 | 42 |
" |
43 |
! ! |
|
44 |
||
136 | 45 |
!FilenameEditField methodsFor:'accessing'! |
46 |
||
47 |
directoriesOnly |
|
48 |
"set to expand names for directories only" |
|
49 |
||
50 |
directoriesOnly := true. |
|
51 |
! |
|
52 |
||
53 |
directory |
|
54 |
^ directory |
|
55 |
||
56 |
"Modified: 7.9.1995 / 10:12:40 / claus" |
|
57 |
! |
|
58 |
||
59 |
directory:aFilename |
|
152 | 60 |
aFilename isNil ifTrue:[ |
61 |
directory := Filename currentDirectory |
|
62 |
] ifFalse:[ |
|
63 |
directory := aFilename asFilename |
|
64 |
] |
|
136 | 65 |
"Modified: 7.9.1995 / 10:12:55 / claus" |
66 |
! |
|
67 |
||
68 |
filesOnly |
|
69 |
"set to expand names for files only" |
|
70 |
||
71 |
filesOnly := true. |
|
72 |
! |
|
73 |
||
74 |
initialText:aString selected:aBoolean |
|
75 |
"move the cursor to the end - thats the most interesting part of |
|
76 |
a filename |
|
77 |
" |
|
78 |
||
79 |
super initialText:aString selected:aBoolean. |
|
80 |
self cursorToEndOfLine. |
|
81 |
! |
|
82 |
||
83 |
showsDirectoriesOnly |
|
84 |
"return if expanding names for directories only" |
|
85 |
||
86 |
^ directoriesOnly |
|
87 |
||
88 |
"Modified: 6.9.1995 / 20:35:30 / claus" |
|
89 |
! |
|
90 |
||
91 |
showsFilesOnly |
|
92 |
"return if expanding names for files only" |
|
93 |
||
94 |
^ filesOnly |
|
95 |
||
96 |
"Modified: 6.9.1995 / 20:34:57 / claus" |
|
97 |
! ! |
|
98 |
||
99 |
!FilenameEditField methodsFor:'event handling'! |
|
100 |
||
101 |
keyPress:key x:x y:y |
|
102 |
"handle tab for filename completion. |
|
103 |
Bug: it completes the last word; it should complete the |
|
104 |
word before the cursor." |
|
105 |
||
106 |
<resource: #keyboard ( #Tab #FilenameCompletion ) > |
|
107 |
||
108 |
|s| |
|
109 |
||
110 |
enabled ifTrue:[ |
|
111 |
((key == #Tab) |
|
112 |
or:[key == #FilenameCompletion]) ifTrue:[ |
|
113 |
s := self contents. |
|
114 |
s isNil ifTrue:[ |
|
115 |
s := '' |
|
116 |
] ifFalse:[ |
|
117 |
s := s asString |
|
118 |
]. |
|
119 |
entryCompletionBlock value:s. |
|
120 |
^ self |
|
121 |
] |
|
122 |
]. |
|
123 |
^ super keyPress:key x:x y:y. |
|
124 |
||
125 |
"Modified: 7.3.1996 / 13:16:49 / cg" |
|
126 |
! ! |
|
127 |
||
72 | 128 |
!FilenameEditField methodsFor:'initialization'! |
129 |
||
130 |
initialize |
|
131 |
super initialize. |
|
132 |
directoriesOnly := filesOnly := false. |
|
133 |
directory := '.' asFilename. |
|
134 |
||
78 | 135 |
entryCompletionBlock := [:contents | |
136 |
|newString| |
|
137 |
||
138 |
newString := Filename |
|
139 |
filenameCompletionFor:contents |
|
140 |
directory:directory |
|
141 |
directoriesOnly:directoriesOnly |
|
142 |
filesOnly:filesOnly |
|
143 |
ifMultiple:[:dir | |
|
144 |
self changed:#directory with:dir. |
|
145 |
self flash. |
|
146 |
]. |
|
147 |
self contents:newString. |
|
148 |
self cursorToEndOfLine. |
|
72 | 149 |
]. |
150 |
||
151 |
"Modified: 7.9.1995 / 10:20:46 / claus" |
|
43 | 152 |
! |
153 |
||
34 | 154 |
realize |
113
984d84d796c8
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
155 |
"move the cursor to the end - thats the most interesting part of |
34 | 156 |
a filename |
157 |
" |
|
158 |
super realize. |
|
159 |
self cursorToEndOfLine. |
|
160 |
! ! |
|
161 |
||
136 | 162 |
!FilenameEditField class methodsFor:'documentation'! |
43 | 163 |
|
136 | 164 |
version |
152 | 165 |
^ '$Header: /cvs/stx/stx/libwidg2/FilenameEditField.st,v 1.20 1996-04-20 12:40:11 ca Exp $' |
34 | 166 |
! ! |