diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 792c4854f1..9585a72d4c 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -185,11 +185,17 @@ class IframeBoss: def modify_selection(self, data): sel = window.getSelection() - try: - sel.modify('extend', data.direction, data.granularity) - except: - if data.granularity is 'paragraph': - sel.modify('extend', data.direction, 'line') + if data.granularity is 'all': + r = document.createRange() + r.selectNode(document.body) + sel.removeAllRanges() + 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() def initialize(self, data): diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index bc39ebed54..283f0ddea4 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -581,6 +581,7 @@ class SelectionBar: forwarded = { 'toggle_highlights': True, 'edit_book': True, + 'select_all': True, } if sc_name is 'show_chrome': self.clear_selection() diff --git a/src/pyj/read_book/shortcuts.pyj b/src/pyj/read_book/shortcuts.pyj index f7582e3b31..2c955c220d 100644 --- a/src/pyj/read_book/shortcuts.pyj +++ b/src/pyj/read_book/shortcuts.pyj @@ -344,6 +344,12 @@ def common_shortcuts(): # {{{ _('Alter the current selection forward by a line'), ), + 'select_all': desc( + v'["Ctrl+a"]', + 'ui', + _('Select all') + ), + 'shrink_selection_by_line': desc( v"['Shift+ArrowUp']", 'ui', diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index b478707874..db54005da6 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -559,6 +559,8 @@ class View: ui_operations.edit_book(current_spine_item(), self.current_file_progress_frac, self.currently_showing?.selection?.text) elif data.name is 'goto_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_'): self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity=data.name.rpartition('_')[-1]) elif data.name.startsWith('extend_selection_by_'):