mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Restore the global find next/prev shortcuts as well
This commit is contained in:
parent
0a44c0bccf
commit
34294a9c9e
@ -66,6 +66,7 @@ class SearchOverlay:
|
||||
c.style.alignItems = 'stretch'
|
||||
c.style.overflow = 'hidden'
|
||||
c.addEventListener('keydown', self.onkeydown)
|
||||
c.addEventListener('keyup', self.onkeyup)
|
||||
|
||||
create_top_bar(c, title=_('Search in book'), action=self.hide, icon='close')
|
||||
|
||||
@ -292,11 +293,14 @@ class SearchOverlay:
|
||||
'This search result matches text that is hidden in the book and cannot be displayed'))
|
||||
self.show()
|
||||
|
||||
def result_clicked(self, rnum):
|
||||
sr = Object.assign({}, self.result_map[rnum])
|
||||
def select_search_result_in_book(self, result_num):
|
||||
sr = Object.assign({}, self.result_map[result_num])
|
||||
sr.on_discovery = 0
|
||||
self.make_result_current(rnum)
|
||||
self.view.show_search_result(sr)
|
||||
|
||||
def result_clicked(self, rnum):
|
||||
self.make_result_current(rnum)
|
||||
self.select_search_result_in_book(rnum)
|
||||
self.hide()
|
||||
|
||||
def clear_caches(self, book):
|
||||
@ -323,12 +327,16 @@ class SearchOverlay:
|
||||
rnum = 1
|
||||
self.make_result_current(rnum)
|
||||
self.results_container.focus()
|
||||
cr = self.current_result_container
|
||||
if cr:
|
||||
self.select_search_result_in_book(cr.dataset.resultNum)
|
||||
|
||||
def onkeydown(self, event):
|
||||
def onkeyup(self, event):
|
||||
if event.key is 'Escape' or event.key is 'Esc':
|
||||
self.hide()
|
||||
event.stopPropagation(), event.preventDefault()
|
||||
return
|
||||
|
||||
def onkeydown(self, event):
|
||||
sc_name = shortcut_for_key_event(event, self.view.keyboard_shortcut_map)
|
||||
if sc_name is 'next_match':
|
||||
self.next_match(1)
|
||||
@ -339,6 +347,9 @@ class SearchOverlay:
|
||||
event.stopPropagation(), event.preventDefault()
|
||||
return
|
||||
|
||||
def find_next(self, backwards):
|
||||
self.next_match(-1 if backwards else 1)
|
||||
|
||||
@property
|
||||
def container(self):
|
||||
return document.getElementById(self.CONTAINER_ID)
|
||||
|
@ -89,6 +89,7 @@ class ReadUI:
|
||||
ui_operations.tts = self.tts.bind(self)
|
||||
ui_operations.search_result_discovered = self.view.search_overlay.search_result_discovered
|
||||
ui_operations.search_result_not_found = self.view.search_overlay.search_result_not_found
|
||||
ui_operations.find_next = self.view.search_overlay.find_next
|
||||
ui_operations.open_url = def(url):
|
||||
window.open(url, '_blank')
|
||||
ui_operations.copy_selection = def(text, html):
|
||||
|
@ -517,15 +517,9 @@ class View:
|
||||
elif data.name is 'start_search':
|
||||
self.show_search()
|
||||
elif data.name is 'next_match':
|
||||
if ui_operations.find_next:
|
||||
ui_operations.find_next()
|
||||
else:
|
||||
self.search_overlay.find_next()
|
||||
elif data.name is 'previous_match':
|
||||
if ui_operations.find_next:
|
||||
ui_operations.find_next(True)
|
||||
else:
|
||||
self.search_overlay.find_previous()
|
||||
elif data.name is 'increase_font_size':
|
||||
self.bump_font_size({'increase': True})
|
||||
elif data.name is 'decrease_font_size':
|
||||
|
Loading…
x
Reference in New Issue
Block a user