Case insensitive searching; fixed column sorting
This commit is contained in:
parent
4b658477ea
commit
de4acf1891
15
browser.py
15
browser.py
|
@ -8,7 +8,8 @@ class browserWindow:
|
||||||
topline = 0
|
topline = 0
|
||||||
entries = []
|
entries = []
|
||||||
selected = list()
|
selected = list()
|
||||||
commands = [(' /', 'search'), (' n', 'find next'), (' N', 'find previous'), (' q', 'quit')]
|
commands = [(' /', 'search'), (' n', 'find next'), (' N', 'find previous'),
|
||||||
|
('F6', 'Sort Column'), (' q', 'quit')]
|
||||||
cs = []
|
cs = []
|
||||||
# column definitions are in (label, weight, specified width) triples
|
# column definitions are in (label, weight, specified width) triples
|
||||||
columnDefs = [('something',1,None)]
|
columnDefs = [('something',1,None)]
|
||||||
|
@ -25,9 +26,10 @@ class browserWindow:
|
||||||
self.commands = self.cs+self.commands
|
self.commands = self.cs+self.commands
|
||||||
|
|
||||||
def sortByColumn(self, col):
|
def sortByColumn(self, col):
|
||||||
self.entries.sort(key=lambda k: k.get(col)) # key=dict.get(col))
|
self.entries.sort(key=lambda k: k.get(col,"")) # key=dict.get(col))
|
||||||
self.selected = list(map(lambda x: False, self.selected))
|
self.selected = list(map(lambda x: False, self.selected))
|
||||||
|
|
||||||
|
|
||||||
def updateGeometry(self):
|
def updateGeometry(self):
|
||||||
(self.my,self.mx)=self.w.getmaxyx()
|
(self.my,self.mx)=self.w.getmaxyx()
|
||||||
(y,x) = self.w.getbegyx()
|
(y,x) = self.w.getbegyx()
|
||||||
|
@ -121,12 +123,17 @@ class browserWindow:
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def search(self, string):
|
def search(self, string):
|
||||||
|
case_sensitive = not(string.islower())
|
||||||
|
#sys.stderr.write(str(case_sensitive)+'\n')
|
||||||
i = 0
|
i = 0
|
||||||
found = False
|
found = False
|
||||||
for e in self.entries:
|
for e in self.entries:
|
||||||
for k,v in e.items():
|
for k,v in e.items():
|
||||||
if str(v).find(string) != -1:
|
# we or with found to make sure it is never "unfound"
|
||||||
found = True
|
if case_sensitive:
|
||||||
|
found = str(v).find(string) != -1 or found
|
||||||
|
else:
|
||||||
|
found = str(v).lower().find(string) != -1 or found
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|
|
@ -57,7 +57,7 @@ class helpBar:
|
||||||
string = string[0:len(string)-1]
|
string = string[0:len(string)-1]
|
||||||
self.w.addstr(0,1,string)
|
self.w.addstr(0,1,string)
|
||||||
elif ch>=32 and ch<=126:
|
elif ch>=32 and ch<=126:
|
||||||
char = curses.keyname(ch)
|
char = curses.keyname(ch).decode('utf-8')
|
||||||
string = string + char
|
string = string + char
|
||||||
self.w.addstr(0,1,string)
|
self.w.addstr(0,1,string)
|
||||||
self.w.refresh()
|
self.w.refresh()
|
||||||
|
|
Loading…
Reference in New Issue