Add new command: select_all_or_input_text.

master
Andy Stewart 6 years ago
parent d9c0a03eec
commit d42fcdeeda
  1. 17
      core/browser.py
  2. 5
      core/js/select_input_text.js
  3. 1
      eaf.el

@ -73,6 +73,9 @@ class BrowserView(QWebEngineView):
with open(os.path.join(os.path.dirname(__file__), "js", "clear_focus.js"), "r") as f:
self.clear_focus_js = f.read()
with open(os.path.join(os.path.dirname(__file__), "js", "select_input_text.js"), "r") as f:
self.select_input_text_js = f.read()
def filter_url(self, url):
parsed = urlparse(url)
qd = parse_qs(parsed.query, keep_blank_values=True)
@ -253,6 +256,14 @@ class BrowserView(QWebEngineView):
def redo_action(self):
self.triggerPageAction(self.web_page.Redo)
def select_all(self):
# We need window focus before select all text.
self.web_page.executeJavaScript("window.focus()")
self.triggerPageAction(self.web_page.SelectAll)
def select_input_text(self):
self.web_page.executeJavaScript(self.select_input_text_js)
def get_url(self):
return self.web_page.executeJavaScript("window.location.href;")
@ -670,5 +681,11 @@ class BrowserBuffer(Buffer):
else:
self.goto_right_tab.emit()
def select_all_or_input_text(self):
if self.is_focus():
self.buffer_widget.select_input_text()
else:
self.buffer_widget.select_all()
def clear_focus(self):
self.buffer_widget.clear_focus()

@ -0,0 +1,5 @@
(function() {
const activeElement = document.activeElement;
activeElement.focus();
activeElement.select();
})();

@ -256,6 +256,7 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
("g" . "insert_or_scroll_to_begin")
("x" . "insert_or_close_buffer")
("G" . "insert_or_scroll_to_bottom")
("C-a" . "select_all_or_input_text")
("M-u" . "clear_focus")
("<f5>" . "refresh_page"))
"The keybinding of EAF Browser."

Loading…
Cancel
Save