mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More hints work
This commit is contained in:
parent
5f113ce9dc
commit
168c75d5d1
@ -12,6 +12,11 @@ class Hints:
|
||||
container.style.overflow = 'hidden'
|
||||
container.addEventListener('keydown', self.on_keydown, {'passive': False})
|
||||
container.addEventListener('click', self.container_clicked, {'passive': False})
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
self.hints_map = {}
|
||||
self.current_prefix = ''
|
||||
|
||||
@property
|
||||
def container(self):
|
||||
@ -28,9 +33,11 @@ class Hints:
|
||||
if self.is_visible:
|
||||
self.container.style.display = 'none'
|
||||
self.send_message('hide')
|
||||
self.reset()
|
||||
|
||||
def show(self):
|
||||
if not self.is_visible:
|
||||
self.reset()
|
||||
self.container.style.display = 'block'
|
||||
self.focus()
|
||||
self.send_message('show')
|
||||
@ -47,6 +54,7 @@ class Hints:
|
||||
|
||||
def handle_message(self, msg):
|
||||
if msg.type is 'shown':
|
||||
self.reset()
|
||||
self.hints_map = msg.hints_map
|
||||
|
||||
|
||||
@ -66,7 +74,7 @@ def hint_visible_links(link_attr):
|
||||
h = i + ''
|
||||
a.setAttribute('calibre-hint-render', i.toString(36))
|
||||
a.setAttribute('calibre-hint-value', h)
|
||||
hint_map[h] = a.getAttribute(link_attr)
|
||||
hint_map[h] = {'type': 'link', 'data':a.getAttribute(link_attr)}
|
||||
a.classList.add('calibre-hint-visible')
|
||||
return hint_map
|
||||
|
||||
|
@ -297,6 +297,7 @@ class View:
|
||||
,
|
||||
'annotations': self.on_annotations_message,
|
||||
'tts': self.on_tts_message,
|
||||
'hints': self.on_hints_message,
|
||||
'copy_text_to_clipboard': def(data):
|
||||
ui_operations.copy_selection(data.text, data.html)
|
||||
,
|
||||
|
Loading…
x
Reference in New Issue
Block a user