mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Allow modifying the current selection using Ctrl+Shift+arrow. Fixes #1855942 [[Enhancements] Comments and select text with keyboard](https://bugs.launchpad.net/calibre/+bug/1855942)
This commit is contained in:
parent
431d55dbca
commit
b13f5d6a0c
@ -106,11 +106,16 @@ class IframeBoss:
|
||||
'get_current_cfi': self.get_current_cfi,
|
||||
'set_forward_keypresses': self.set_forward_keypresses,
|
||||
'set_reference_mode': self.set_reference_mode,
|
||||
'modify_selection': self.modify_selection,
|
||||
}
|
||||
self.comm = IframeClient(handlers)
|
||||
self.last_window_ypos = 0
|
||||
self.length_before = None
|
||||
|
||||
def modify_selection(self, data):
|
||||
sel = window.getSelection()
|
||||
sel.modify('extend', data.direction, data.granularity)
|
||||
|
||||
def set_forward_keypresses(self, data):
|
||||
self.forward_keypresses = data.forward
|
||||
|
||||
|
@ -246,6 +246,18 @@ def shortcuts_definition():
|
||||
_('Search for next occurrence of selected text'),
|
||||
),
|
||||
|
||||
'extend_selection_by_word': desc(
|
||||
v"['Ctrl+Shift+ArrowRight']",
|
||||
'ui',
|
||||
_('Alter the current selection forward by a word'),
|
||||
),
|
||||
|
||||
'shrink_selection_by_word': desc(
|
||||
v"['Ctrl+Shift+ArrowLeft']",
|
||||
'ui',
|
||||
_('Alter the current selection backwards by a word'),
|
||||
),
|
||||
|
||||
'show_chrome': desc(
|
||||
v"['Escape', 'ContextMenu']",
|
||||
'ui',
|
||||
|
@ -405,7 +405,10 @@ class View:
|
||||
self.overlay.show_metadata()
|
||||
elif data.name is 'goto_location':
|
||||
self.overlay.show_ask_for_location()
|
||||
|
||||
elif data.name is 'shrink_selection_by_word':
|
||||
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='word')
|
||||
elif data.name is 'extend_selection_by_word':
|
||||
self.iframe_wrapper.send_message('modify_selection', direction='forward', granularity='word')
|
||||
|
||||
def on_selection_change(self, data):
|
||||
self.currently_showing.selected_text = data.text
|
||||
|
Loading…
x
Reference in New Issue
Block a user