diff --git a/app/pdf-viewer/buffer.py b/app/pdf-viewer/buffer.py index f252cee..c64130a 100755 --- a/app/pdf-viewer/buffer.py +++ b/app/pdf-viewer/buffer.py @@ -130,6 +130,12 @@ class AppBuffer(Buffer): self.buffer_widget.add_mark_jump_link_tips() self.buffer_widget.send_input_message("EAF PDF Viewer - Jump to Link: ", "jump_link") + def action_quit(self): + if self.buffer_widget.is_mark_search: + self.buffer_widget.cleanup_search() + if self.buffer_widget.is_mark_link: + self.buffer_widget.cleanup_links() + def search_text(self): if self.buffer_widget.search_flag: self.buffer_widget.remove_marked_search_text() diff --git a/core/buffer.py b/core/buffer.py index d985ff1..587af06 100755 --- a/core/buffer.py +++ b/core/buffer.py @@ -239,6 +239,9 @@ class Buffer(QGraphicsScene): def handle_input_message(self, result_type, result_content): pass + def action_quit(self): + pass + def cancel_input_message(self, result_type): pass diff --git a/eaf.el b/eaf.el index b780a5e..4a17246 100644 --- a/eaf.el +++ b/eaf.el @@ -96,10 +96,11 @@ (defvar eaf-mode-map* (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-h m") 'eaf-describe-bindings) - (define-key map [remap describe-bindings] 'eaf-describe-bindings) - (define-key map (kbd "C-c b") 'eaf-open-bookmark) - (define-key map (vector 'remap 'self-insert-command) #'eaf-send-key) + (define-key map (kbd "C-g") #'eaf-keyboard-quit) + (define-key map (kbd "C-h m") #'eaf-describe-bindings) + (define-key map [remap describe-bindings] #'eaf-describe-bindings) + (define-key map (kbd "C-c b") #'eaf-open-bookmark) + (define-key map (vector 'remap #'self-insert-command) #'eaf-send-key) (dolist (single-key '("RET" "DEL" "TAB" "SPC" "" "" "" "" "" "" "" "" "")) (define-key map (kbd single-key) #'eaf-send-key)) map) @@ -642,6 +643,11 @@ to edit EAF keybindings!" fun fun))) (eaf-call "update_buffer_with_url" "app.org-previewer.buffer" (buffer-file-name) "") (message (format "export %s to html" (buffer-file-name)))))) +(defun eaf-keyboard-quit () + "Similar to `keyboard-quit' but signals a ‘quit’ condition to EAF applications." + (interactive) + (eaf-call "action_quit" eaf--buffer-id)) + (defun eaf-send-key () "Directly send key to EAF Python side." (interactive) diff --git a/eaf.py b/eaf.py index a319389..ad42fa3 100755 --- a/eaf.py +++ b/eaf.py @@ -255,6 +255,12 @@ class EAF(dbus.service.Object): self.message_to_emacs("Cannot call function: " + function_name) return "" + @dbus.service.method(EAF_DBUS_NAME, in_signature="s", out_signature="") + def action_quit(self, buffer_id): + if buffer_id in self.buffer_dict: + self.buffer_dict[buffer_id].action_quit() + self.message_to_emacs("Quit") + @dbus.service.method(EAF_DBUS_NAME, in_signature="ss", out_signature="") def send_key(self, buffer_id, event_string): # Send event to buffer when found match buffer.