diff --git a/src/pyj/read_book/create_annotation.pyj b/src/pyj/read_book/create_annotation.pyj index fbc7bd0aa9..bd51a10be0 100644 --- a/src/pyj/read_book/create_annotation.pyj +++ b/src/pyj/read_book/create_annotation.pyj @@ -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': diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index 9a906c20db..71296f4b75 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -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: