equal
deleted
inserted
replaced
1 " |
1 " |
2 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
2 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
3 Copyright (C) 2013-2015 Jan Vrany |
3 Copyright (C) 2013-2015 Jan Vrany |
4 Copyright (C) 2014 Claus Gittinger |
4 Copyright (C) 2014 Claus Gittinger |
5 Copyright (C) 2018 Jan Vrany |
5 Copyright (C) 2018 Jan Vrany |
|
6 Copyright (C) 2020 LabWare |
6 |
7 |
7 This library is free software; you can redistribute it and/or |
8 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Lesser General Public |
9 modify it under the terms of the GNU Lesser General Public |
9 License as published by the Free Software Foundation; either |
10 License as published by the Free Software Foundation; either |
10 version 2.1 of the License. |
11 version 2.1 of the License. |
35 " |
36 " |
36 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
37 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
37 Copyright (C) 2013-2015 Jan Vrany |
38 Copyright (C) 2013-2015 Jan Vrany |
38 Copyright (C) 2014 Claus Gittinger |
39 Copyright (C) 2014 Claus Gittinger |
39 Copyright (C) 2018 Jan Vrany |
40 Copyright (C) 2018 Jan Vrany |
|
41 Copyright (C) 2020 LabWare |
40 |
42 |
41 This library is free software; you can redistribute it and/or |
43 This library is free software; you can redistribute it and/or |
42 modify it under the terms of the GNU Lesser General Public |
44 modify it under the terms of the GNU Lesser General Public |
43 License as published by the Free Software Foundation; either |
45 License as published by the Free Software Foundation; either |
44 version 2.1 of the License. |
46 version 2.1 of the License. |
153 ! |
155 ! |
154 |
156 |
155 handleKeyPressTab |
157 handleKeyPressTab |
156 "Tab has been pressed, try to complete longest common prefix" |
158 "Tab has been pressed, try to complete longest common prefix" |
157 |
159 |
158 | first prefix matching longest minlen | |
160 | prefix matching longest minlen | |
159 |
161 |
160 first := completionView list first. |
|
161 prefix := self prefixAlreadyWritten. |
162 prefix := self prefixAlreadyWritten. |
162 matching := OrderedCollection new. |
163 matching := OrderedCollection new. |
163 minlen := SmallInteger maxVal. |
164 minlen := SmallInteger maxVal. |
164 completionView list do:[:po | |
165 completionView list do:[:po | |
165 | s | |
166 | s | |
170 minlen := minlen min: s size. |
171 minlen := minlen min: s size. |
171 ]. |
172 ]. |
172 ]. |
173 ]. |
173 matching isEmpty ifTrue:[ |
174 matching isEmpty ifTrue:[ |
174 completionView flash. |
175 completionView flash. |
175 ^self. |
176 ^ self. |
176 ]. |
177 ]. |
177 matching size == 1 ifTrue:[ |
178 matching size == 1 ifTrue:[ |
178 self complete: matching first key. |
179 self complete: matching first key. |
|
180 ^ self. |
179 ]. |
181 ]. |
180 |
182 |
181 longest := String streamContents:[:s | |
183 longest := String streamContents:[:s | |
182 | i | |
184 | i | |
183 |
185 |
202 ]. |
204 ]. |
203 editView insertStringAtCursor:(longest copyFrom: prefix size + 1). |
205 editView insertStringAtCursor:(longest copyFrom: prefix size + 1). |
204 |
206 |
205 "Created: / 31-03-2014 / 22:55:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
207 "Created: / 31-03-2014 / 22:55:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
206 "Modified: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
208 "Modified: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
209 "Modified: / 12-06-2020 / 22:05:10 / Jan Vrany <jan.vrany@labware.com>" |
207 ! |
210 ! |
208 |
211 |
209 postKeyPress:key |
212 postKeyPress:key |
210 seqno := seqno + 1. |
213 seqno := seqno + 1. |
211 seqno == SmallInteger maxVal ifTrue:[ |
214 seqno == SmallInteger maxVal ifTrue:[ |