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:
parent
1056ab1b81
commit
52f4e81d59
@ -172,13 +172,13 @@ def find_urls(pat, line):
|
||||
yield s, e
|
||||
|
||||
|
||||
def mark(finditer, line, index_map):
|
||||
def mark(finditer, line, all_marks):
|
||||
marks = []
|
||||
for s, e in finditer(line):
|
||||
idx = len(index_map)
|
||||
idx = len(all_marks)
|
||||
text = line[s:e]
|
||||
marks.append(Mark(idx, s, e, text))
|
||||
index_map[idx] = marks[-1]
|
||||
all_marks.append(marks[-1])
|
||||
return line, marks
|
||||
|
||||
|
||||
@ -216,16 +216,21 @@ def run(args, text):
|
||||
else:
|
||||
finditer = partial(regex_finditer, re.compile(args.regex), args.minimum_match_length)
|
||||
lines = []
|
||||
index_map = {}
|
||||
all_marks = []
|
||||
for line in text.splitlines():
|
||||
marked = mark(finditer, line, index_map)
|
||||
marked = mark(finditer, line, all_marks)
|
||||
lines.append(marked)
|
||||
if not index_map:
|
||||
if not all_marks:
|
||||
input(_('No {} found, press Enter to abort.').format(
|
||||
'URLs' if args.type == 'url' else 'matches'
|
||||
))
|
||||
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)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user