mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1921572 [[Viewer] Ctrl+A doesn't work when some text is selected](https://bugs.launchpad.net/calibre/+bug/1921572)
This commit is contained in:
parent
57302df132
commit
9673e288be
@ -185,11 +185,17 @@ class IframeBoss:
|
|||||||
|
|
||||||
def modify_selection(self, data):
|
def modify_selection(self, data):
|
||||||
sel = window.getSelection()
|
sel = window.getSelection()
|
||||||
try:
|
if data.granularity is 'all':
|
||||||
sel.modify('extend', data.direction, data.granularity)
|
r = document.createRange()
|
||||||
except:
|
r.selectNode(document.body)
|
||||||
if data.granularity is 'paragraph':
|
sel.removeAllRanges()
|
||||||
sel.modify('extend', data.direction, 'line')
|
sel.addRange(r)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
sel.modify('extend', data.direction, data.granularity)
|
||||||
|
except:
|
||||||
|
if data.granularity is 'paragraph':
|
||||||
|
sel.modify('extend', data.direction, 'line')
|
||||||
self.ensure_selection_visible()
|
self.ensure_selection_visible()
|
||||||
|
|
||||||
def initialize(self, data):
|
def initialize(self, data):
|
||||||
|
@ -581,6 +581,7 @@ class SelectionBar:
|
|||||||
forwarded = {
|
forwarded = {
|
||||||
'toggle_highlights': True,
|
'toggle_highlights': True,
|
||||||
'edit_book': True,
|
'edit_book': True,
|
||||||
|
'select_all': True,
|
||||||
}
|
}
|
||||||
if sc_name is 'show_chrome':
|
if sc_name is 'show_chrome':
|
||||||
self.clear_selection()
|
self.clear_selection()
|
||||||
|
@ -344,6 +344,12 @@ def common_shortcuts(): # {{{
|
|||||||
_('Alter the current selection forward by a line'),
|
_('Alter the current selection forward by a line'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'select_all': desc(
|
||||||
|
v'["Ctrl+a"]',
|
||||||
|
'ui',
|
||||||
|
_('Select all')
|
||||||
|
),
|
||||||
|
|
||||||
'shrink_selection_by_line': desc(
|
'shrink_selection_by_line': desc(
|
||||||
v"['Shift+ArrowUp']",
|
v"['Shift+ArrowUp']",
|
||||||
'ui',
|
'ui',
|
||||||
|
@ -559,6 +559,8 @@ class View:
|
|||||||
ui_operations.edit_book(current_spine_item(), self.current_file_progress_frac, self.currently_showing?.selection?.text)
|
ui_operations.edit_book(current_spine_item(), self.current_file_progress_frac, self.currently_showing?.selection?.text)
|
||||||
elif data.name is 'goto_location':
|
elif data.name is 'goto_location':
|
||||||
self.overlay.show_ask_for_location()
|
self.overlay.show_ask_for_location()
|
||||||
|
elif data.name is 'select_all':
|
||||||
|
self.iframe_wrapper.send_message('modify_selection', granularity='all')
|
||||||
elif data.name.startsWith('shrink_selection_by_'):
|
elif data.name.startsWith('shrink_selection_by_'):
|
||||||
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity=data.name.rpartition('_')[-1])
|
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity=data.name.rpartition('_')[-1])
|
||||||
elif data.name.startsWith('extend_selection_by_'):
|
elif data.name.startsWith('extend_selection_by_'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user