From 0d63e5804fbe3d944ef99a7f81246064cbcef95e Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Sat, 29 Feb 2020 19:49:18 +0800 Subject: [PATCH] Need pass topic to minibuffer when change node topic. --- app/mindmap/buffer.py | 6 +++++- app/mindmap/index.html | 9 +++++++++ core/buffer.py | 6 +++--- eaf.el | 8 ++++---- eaf.py | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/mindmap/buffer.py b/app/mindmap/buffer.py index 154fa77..16fa674 100644 --- a/app/mindmap/buffer.py +++ b/app/mindmap/buffer.py @@ -74,7 +74,11 @@ class AppBuffer(BrowserBuffer): self.send_input_message("Change node background: ", "change_node_background", "file") def update_node_topic(self): - self.send_input_message("Update topic: ", "update_node_topic") + self.send_input_message( + "Update topic: ", + "update_node_topic", + "string", + self.buffer_widget.execute_js("get_node_topic();")) def handle_update_node_topic(self, topic): self.buffer_widget.eval_js("update_node_topic('{}');".format(topic)) diff --git a/app/mindmap/index.html b/app/mindmap/index.html index aca94dd..295b20b 100644 --- a/app/mindmap/index.html +++ b/app/mindmap/index.html @@ -33,6 +33,15 @@ return _jm.get_node("root").topic; } + function get_node_topic() { + var selected_node = _jm.get_selected_node(); // as parent of new node + if (selected_node) { + return selected_node.topic; + } else { + return "" + } + } + function add_sub_node(){ var selected_node = _jm.get_selected_node(); // as parent of new node if(!selected_node) { diff --git a/core/buffer.py b/core/buffer.py index e93ceb8..dbf6ac1 100755 --- a/core/buffer.py +++ b/core/buffer.py @@ -152,7 +152,7 @@ class Buffer(QGraphicsScene): open_url_in_background_tab = QtCore.pyqtSignal(str) translate_text = QtCore.pyqtSignal(str) before_destroy_hook = QtCore.pyqtSignal() - input_message = QtCore.pyqtSignal(str, str, str, str) + input_message = QtCore.pyqtSignal(str, str, str, str, str) close_buffer = QtCore.pyqtSignal(str) message_to_emacs = QtCore.pyqtSignal(str) set_emacs_var = QtCore.pyqtSignal(str, str) @@ -239,8 +239,8 @@ class Buffer(QGraphicsScene): def get_key_event_widgets(self): return [self.buffer_widget] - def send_input_message(self, message, callback_type, input_type="string"): - self.input_message.emit(self.buffer_id, message, callback_type, input_type) + def send_input_message(self, message, callback_type, input_type="string", input_content=""): + self.input_message.emit(self.buffer_id, message, callback_type, input_type, input_content) def handle_input_message(self, result_type, result_content): pass diff --git a/eaf.el b/eaf.el index 5dfe2a8..38a1f5d 100644 --- a/eaf.el +++ b/eaf.el @@ -1130,18 +1130,18 @@ of `eaf--buffer-app-name' inside the EAF buffer." "com.lazycat.eaf" "input_message" #'eaf--input-message) -(defun eaf--input-message (input-buffer-id interactive-string callback-type interactive_type) +(defun eaf--input-message (input-buffer-id interactive-string callback-type interactive_type input_content) "Handles input message INTERACTIVE-STRING on the Python side given INPUT-BUFFER-ID and CALLBACK-TYPE." - (let* ((input-message (eaf-read-input (concat "[EAF/" eaf--buffer-app-name "] " interactive-string) interactive_type))) + (let* ((input-message (eaf-read-input (concat "[EAF/" eaf--buffer-app-name "] " interactive-string) interactive_type input_content))) (if input-message (eaf-call "handle_input_message" input-buffer-id callback-type input-message) (eaf-call "cancel_input_message" input-buffer-id callback-type)))) -(defun eaf-read-input (interactive-string interactive_type) +(defun eaf-read-input (interactive-string interactive_type input_content) "Like `read-string' which read an INTERACTIVE-STRING, but return nil if user execute `keyboard-quit' when input." (condition-case nil (cond ((string-equal interactive_type "string") - (read-string interactive-string)) + (read-string interactive-string input_content)) ((string-equal interactive_type "file") (expand-file-name (read-file-name interactive-string)))) (quit nil))) diff --git a/eaf.py b/eaf.py index b3f88a4..44f566a 100755 --- a/eaf.py +++ b/eaf.py @@ -376,7 +376,7 @@ class EAF(dbus.service.Object): pass @dbus.service.signal(EAF_DBUS_NAME) - def input_message(self, buffer_id, message, callback_type, input_type): + def input_message(self, buffer_id, message, callback_type, input_type, input_content): pass @dbus.service.signal(EAF_DBUS_NAME)