hints kitten: Reverse order of hints
Gives hints at the bottom of the screen smaller numbers. In non-fullscreen usage matches closer to the bottom are more likely to be the ones the user is looking for. Fixes #460
This commit is contained in:
@@ -172,13 +172,13 @@ def find_urls(pat, line):
|
|||||||
yield s, e
|
yield s, e
|
||||||
|
|
||||||
|
|
||||||
def mark(finditer, line, index_map):
|
def mark(finditer, line, all_marks):
|
||||||
marks = []
|
marks = []
|
||||||
for s, e in finditer(line):
|
for s, e in finditer(line):
|
||||||
idx = len(index_map)
|
idx = len(all_marks)
|
||||||
text = line[s:e]
|
text = line[s:e]
|
||||||
marks.append(Mark(idx, s, e, text))
|
marks.append(Mark(idx, s, e, text))
|
||||||
index_map[idx] = marks[-1]
|
all_marks.append(marks[-1])
|
||||||
return line, marks
|
return line, marks
|
||||||
|
|
||||||
|
|
||||||
@@ -216,16 +216,21 @@ def run(args, text):
|
|||||||
else:
|
else:
|
||||||
finditer = partial(regex_finditer, re.compile(args.regex), args.minimum_match_length)
|
finditer = partial(regex_finditer, re.compile(args.regex), args.minimum_match_length)
|
||||||
lines = []
|
lines = []
|
||||||
index_map = {}
|
all_marks = []
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
marked = mark(finditer, line, index_map)
|
marked = mark(finditer, line, all_marks)
|
||||||
lines.append(marked)
|
lines.append(marked)
|
||||||
if not index_map:
|
if not all_marks:
|
||||||
input(_('No {} found, press Enter to abort.').format(
|
input(_('No {} found, press Enter to abort.').format(
|
||||||
'URLs' if args.type == 'url' else 'matches'
|
'URLs' if args.type == 'url' else 'matches'
|
||||||
))
|
))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
largest_index = all_marks[-1].index
|
||||||
|
for m in all_marks:
|
||||||
|
m.index = largest_index - m.index
|
||||||
|
index_map = {m.index: m for m in all_marks}
|
||||||
|
|
||||||
return run_loop(args, lines, index_map)
|
return run_loop(args, lines, index_map)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user