Add quick highlight and adjust selection actions for selection bar

This commit is contained in:
Kovid Goyal 2020-07-28 17:32:28 +05:30
parent 53da449b42
commit 7f275c8dc4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 23 additions and 1 deletions

View File

@ -517,6 +517,15 @@ class CreateAnnotation: # {{{
)
self.hide()
def quick_create(self):
s = self.current_highlight_style
style = ''
for k in Object.keys(self.current_highlight_style):
style += f'{k}: {s[k]}; '
self.send_message(
'apply-highlight', style=style, uuid=short_uuid()
)
def on_keydown(self, ev):
ev.stopPropagation(), ev.preventDefault()
if ev.key is 'Enter':

View File

@ -19,7 +19,9 @@ def all_actions():
all_actions.ans = {
'copy': a('copy', _('Copy to clipboard'), 'copy_to_clipboard'),
'lookup': a('library', _('Lookup/search selected word'), 'lookup'),
'highlight': a('highlight', _('Highlight selection'), 'create_highlight'),
'quick_highlight': a('highlight', _('Quick highlight in current style'), 'quick_highlight'),
'highlight': a('highlight', _('Highlight selection in notes mode'), 'create_highlight'),
'selection': a('arrows-h', _('Highlight adjusting selection'), 'adjust_selection'),
'search_net': a('search', _('Search for selection on the net'), 'internet_search'),
'remove_highlight': a('eraser', _('Remove this highlight'), 'remove_highlight', True),
'clear': a('close', _('Clear selection'), 'clear_selection'),
@ -119,6 +121,17 @@ class SelectionBar:
def create_highlight(self):
self.view.initiate_create_annotation(True)
def adjust_selection(self):
self.view.initiate_create_annotation(False)
def quick_highlight(self):
cs = self.view.currently_showing.selection
if cs.text:
if cs.annot_id:
self.view.initiate_create_annotation(True)
else:
self.view.create_annotation.quick_create()
def remove_highlight(self):
annot_id = self.view.currently_showing.selection.annot_id
if annot_id: