mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Also add shortcuts for modifying selection with character granularity
This commit is contained in:
parent
a2650969a9
commit
f4fc7c4259
@ -573,9 +573,9 @@ class SelectionBar:
|
|||||||
self.copy_to_clipboard()
|
self.copy_to_clipboard()
|
||||||
return
|
return
|
||||||
sc_name = shortcut_for_key_event(ev, self.view.keyboard_shortcut_map)
|
sc_name = shortcut_for_key_event(ev, self.view.keyboard_shortcut_map)
|
||||||
if ev.key is 'ArrowRight' and ev.shiftKey:
|
if ev.key is 'ArrowRight' and ev.shiftKey and not ev.altKey:
|
||||||
sc_name = 'extend_selection_by_word'
|
sc_name = 'extend_selection_by_word'
|
||||||
elif ev.key is 'ArrowLeft' and ev.shiftKey:
|
elif ev.key is 'ArrowLeft' and ev.shiftKey and not ev.altKey:
|
||||||
sc_name = 'shrink_selection_by_word'
|
sc_name = 'shrink_selection_by_word'
|
||||||
|
|
||||||
if not sc_name:
|
if not sc_name:
|
||||||
@ -584,6 +584,7 @@ class SelectionBar:
|
|||||||
'toggle_highlights': True,
|
'toggle_highlights': True,
|
||||||
'edit_book': True,
|
'edit_book': True,
|
||||||
'extend_selection_by_word': True, 'shrink_selection_by_word': True,
|
'extend_selection_by_word': True, 'shrink_selection_by_word': True,
|
||||||
|
'extend_selection_by_character': True, 'shrink_selection_by_character': True,
|
||||||
'extend_selection_by_line': True, 'shrink_selection_by_line': True,
|
'extend_selection_by_line': True, 'shrink_selection_by_line': True,
|
||||||
}
|
}
|
||||||
if sc_name is 'show_chrome':
|
if sc_name is 'show_chrome':
|
||||||
|
@ -326,6 +326,18 @@ def common_shortcuts(): # {{{
|
|||||||
_('Alter the current selection backwards by a word'),
|
_('Alter the current selection backwards by a word'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'extend_selection_by_character': desc(
|
||||||
|
v"['Alt+Shift+ArrowRight']",
|
||||||
|
'ui',
|
||||||
|
_('Alter the current selection forward by a character'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'shrink_selection_by_character': desc(
|
||||||
|
v"['Alt+Shift+ArrowLeft']",
|
||||||
|
'ui',
|
||||||
|
_('Alter the current selection backwards by a character'),
|
||||||
|
),
|
||||||
|
|
||||||
'extend_selection_by_line': desc(
|
'extend_selection_by_line': desc(
|
||||||
v"['Ctrl+Shift+ArrowDown', 'Shift+ArrowDown']",
|
v"['Ctrl+Shift+ArrowDown', 'Shift+ArrowDown']",
|
||||||
'ui',
|
'ui',
|
||||||
|
@ -563,6 +563,10 @@ class View:
|
|||||||
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='word')
|
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='word')
|
||||||
elif data.name is 'extend_selection_by_word':
|
elif data.name is 'extend_selection_by_word':
|
||||||
self.iframe_wrapper.send_message('modify_selection', direction='forward', granularity='word')
|
self.iframe_wrapper.send_message('modify_selection', direction='forward', granularity='word')
|
||||||
|
elif data.name is 'shrink_selection_by_character':
|
||||||
|
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='character')
|
||||||
|
elif data.name is 'extend_selection_by_character':
|
||||||
|
self.iframe_wrapper.send_message('modify_selection', direction='forward', granularity='character')
|
||||||
elif data.name is 'shrink_selection_by_line':
|
elif data.name is 'shrink_selection_by_line':
|
||||||
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='line')
|
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity='line')
|
||||||
elif data.name is 'extend_selection_by_line':
|
elif data.name is 'extend_selection_by_line':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user