Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03bca30

Browse files
author
Just van Rossum
committed
1) added "typingcasesens" keyword arg to constructor, and support for case sensitive typing in lists.
2) minor cleanups (jvr)
1 parent 2a75909 commit 03bca30

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

Mac/Tools/IDE/Wlists.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import Events
77
import Qd
88
import Win
9+
import Lists
910

1011

1112
class List(Wbase.SelectableWidget):
@@ -14,7 +15,7 @@ class List(Wbase.SelectableWidget):
1415

1516
LDEF_ID = 0
1617

17-
def __init__(self, possize, items = None, callback = None, flags = 0, cols = 1):
18+
def __init__(self, possize, items = None, callback = None, flags = 0, cols = 1, typingcasesens=0):
1819
if items is None:
1920
items = []
2021
self.items = items
@@ -25,6 +26,7 @@ def __init__(self, possize, items = None, callback = None, flags = 0, cols = 1):
2526
self._cols = cols
2627
self._callback = callback
2728
self._flags = flags
29+
self.typingcasesens = typingcasesens
2830
self.lasttyping = ""
2931
self.lasttime = Evt.TickCount()
3032
self.timelimit = 30
@@ -89,7 +91,7 @@ def adjust(self, oldbounds):
8991
def close(self):
9092
self._list = None
9193
self._callback = None
92-
self.items[:] = []
94+
self.items = []
9395
Wbase.SelectableWidget.close(self)
9496

9597
def set(self, items):
@@ -137,11 +139,14 @@ def key(self, char, event):
137139
modifiers = 0
138140
if (self.lasttime + self.timelimit) < Evt.TickCount():
139141
self.lasttyping = ""
140-
self.lasttyping = self.lasttyping + string.lower(char)
142+
if self.typingcasesens:
143+
self.lasttyping = self.lasttyping + char
144+
else:
145+
self.lasttyping = self.lasttyping + string.lower(char)
141146
self.lasttime = Evt.TickCount()
142147
i = self.findmatch(self.lasttyping)
143148
newselection = [i]
144-
if modifiers & Events.shiftKey:
149+
if modifiers & Events.shiftKey and not self._list.selFlags & Lists.lOnlyOne:
145150
newselection = newselection + sel
146151
self.setselection(newselection)
147152
self._list.LAutoScroll()
@@ -150,11 +155,14 @@ def key(self, char, event):
150155
def findmatch(self, tag):
151156
lower = string.lower
152157
items = self.items
158+
typingcasesens = self.typingcasesens
153159
taglen = len(tag)
154160
match = '\377' * 100
155161
match_i = -1
156162
for i in range(len(items)):
157-
item = lower(str(items[i]))
163+
item = str(items[i])
164+
if not typingcasesens:
165+
item = lower(item)
158166
if tag <= item < match:
159167
match = item
160168
match_i = i
@@ -179,10 +187,14 @@ def can_copy(self, *args):
179187
def domenu_selectall(self, *args):
180188
self.selectall()
181189

190+
def can_selectall(self, *args):
191+
return not self._list.selFlags & Lists.lOnlyOne
192+
182193
def selectall(self):
183-
self.setselection(range(len(self.items)))
184-
self._list.LAutoScroll()
185-
self.click((-1, -1), 0)
194+
if not self._list.selFlags & Lists.lOnlyOne:
195+
self.setselection(range(len(self.items)))
196+
self._list.LAutoScroll()
197+
self.click((-1, -1), 0)
186198

187199
def getselection(self):
188200
if not self._parent or not self._list:

0 commit comments

Comments
 (0)