Merge pull request #146 from clemera/refresh-page-command

Add refresh command for browser app and prefix app commands like before
master
Mingde Zeng 6 years ago committed by GitHub
commit 6acca6ffcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      core/browser_buffer.py
  2. 22
      eaf.el

@ -91,6 +91,9 @@ class BrowserBuffer(Buffer):
def scroll_to_bottom(self): def scroll_to_bottom(self):
self.eval_js("window.scrollBy(0, document.body.scrollHeight)") self.eval_js("window.scrollBy(0, document.body.scrollHeight)")
def refresh_page(self):
self.eval_js("location.reload()")
def get_bookmark(self): def get_bookmark(self):
return self.buffer_widget.web_page.executeJavaScript("window.location.href;") return self.buffer_widget.web_page.executeJavaScript("window.location.href;")

@ -200,7 +200,8 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
("C-v" . "scroll_up_page") ("C-v" . "scroll_up_page")
("M-v" . "scroll_down_page") ("M-v" . "scroll_down_page")
("M-<" . "scroll_to_begin") ("M-<" . "scroll_to_begin")
("M->" . "scroll_to_bottom")) ("M->" . "scroll_to_bottom")
("<f5>" . "refresh_page"))
"The keybinding of EAF Browser." "The keybinding of EAF Browser."
:type 'cons) :type 'cons)
@ -478,10 +479,6 @@ buffer."
FUN is only called when command SYM is not invoked by KEY." FUN is only called when command SYM is not invoked by KEY."
(defalias sym (lambda nil (defalias sym (lambda nil
"This Lisp function is a placeholder, the actual function will be handled on the Python side.
Use `eaf-execute-app-cmd' if you want to execute this command programmatically.
Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(interactive) (interactive)
;; ensure this is only called from EAF buffer ;; ensure this is only called from EAF buffer
(unless (boundp 'eaf--buffer-id) (unless (boundp 'eaf--buffer-id)
@ -490,9 +487,15 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
;; the case that this command isn't invoked by key-sequence. ;; the case that this command isn't invoked by key-sequence.
(when (and (eq this-command sym) (when (and (eq this-command sym)
(not (equal (this-command-keys-vector) key))) (not (equal (this-command-keys-vector) key)))
(eaf-call "execute_function" eaf--buffer-id fun))))) (eaf-call "execute_function" eaf--buffer-id fun)))
(format
"This Lisp function is a placeholder, the actual function will be handled on the Python side.
Use `eaf-execute-app-cmd' if you want to execute this command programmatically.
Please ONLY use `eaf-bind-key' and use the unprefixed command name (`%s`)
to edit EAF keybindings!" fun)))
(defun eaf-gen-keybinding-map (keybinding) (defun eaf-gen-keybinding-map (keybinding app-name)
"Configure the `eaf-mode-map' from KEYBINDING, one of the eaf-*-keybinding variables." "Configure the `eaf-mode-map' from KEYBINDING, one of the eaf-*-keybinding variables."
(setq eaf-mode-map (setq eaf-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -502,7 +505,8 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(define-key map (kbd single-key) 'eaf-send-key)) (define-key map (kbd single-key) 'eaf-send-key))
(set-keymap-parent map eaf-mode-map*) (set-keymap-parent map eaf-mode-map*)
(cl-loop for (key . fun) in keybinding (cl-loop for (key . fun) in keybinding
do (let ((dummy (intern fun))) do (let ((dummy (intern
(format "eaf-%s-%s" app-name fun))))
(eaf-dummy-function dummy fun key) (eaf-dummy-function dummy fun key)
(define-key map (kbd key) dummy)) (define-key map (kbd key) dummy))
finally return map)))) finally return map))))
@ -513,7 +517,7 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(defun eaf-create-buffer (input-content app-name) (defun eaf-create-buffer (input-content app-name)
"Create an EAF buffer given INPUT-CONTENT and APP-NAME." "Create an EAF buffer given INPUT-CONTENT and APP-NAME."
(eaf-gen-keybinding-map (eaf-get-app-bindings app-name)) (eaf-gen-keybinding-map (eaf-get-app-bindings app-name) app-name)
(let* ((file-or-command-name (substring input-content (string-match "[^/]*/?$" input-content))) (let* ((file-or-command-name (substring input-content (string-match "[^/]*/?$" input-content)))
(eaf-buffer (generate-new-buffer (truncate-string-to-width file-or-command-name eaf-title-length)))) (eaf-buffer (generate-new-buffer (truncate-string-to-width file-or-command-name eaf-title-length))))
(with-current-buffer eaf-buffer (with-current-buffer eaf-buffer

Loading…
Cancel
Save