From b9d26ee268f9c8ffb67e15aad8a8521fd394c18c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 7 Mar 2018 23:45:19 +0100 Subject: Add an input.insert_mode.auto_enter setting Closes #3143 --- doc/changelog.asciidoc | 4 ++++ doc/help/settings.asciidoc | 9 +++++++++ qutebrowser/browser/mouse.py | 5 +++-- qutebrowser/browser/webelem.py | 5 +++-- qutebrowser/config/configdata.yml | 5 +++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index c526e4430..e0c891a13 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -54,6 +54,10 @@ Added * `tabs.mode_on_change` which replaces `tabs.persist_mode_on_change`. It can now be set to `restore` which remembers input modes (input/passthrough) per tab. + * `input.insert_mode.auto_enter` which makes it possible to disable entering + insert mode automatically when an editable element was clicked. Together + with `input.forward_unbound_keys`, this should allow for emacs-like + "modeless" keybindings. - New `:prompt-yank` command (bound to `Alt-y` by default) to yank URLs referenced in prompts. - The `hostblock_blame` script which was removed in v1.0 was updated for the new diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index bfbb8672e..a428d65bd 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -201,6 +201,7 @@ |<>|Make characters in hint strings uppercase. |<>|Maximum time (in minutes) between two history items for them to be considered being from the same browsing session. |<>|Which unbound keys to forward to the webview in normal mode. +|<>|Enter insert mode if an editable element is clicked. |<>|Leave insert mode if a non-editable element is clicked. |<>|Automatically enter insert mode if an editable element is focused after loading the page. |<>|Switch to insert mode when clicking flash and other plugins. @@ -2400,6 +2401,14 @@ Valid values: Default: +pass:[auto]+ +[[input.insert_mode.auto_enter]] +=== input.insert_mode.auto_enter +Enter insert mode if an editable element is clicked. + +Type: <> + +Default: +pass:[true]+ + [[input.insert_mode.auto_leave]] === input.insert_mode.auto_leave Leave insert mode if a non-editable element is clicked. diff --git a/qutebrowser/browser/mouse.py b/qutebrowser/browser/mouse.py index b0053cbf1..16a7f227e 100644 --- a/qutebrowser/browser/mouse.py +++ b/qutebrowser/browser/mouse.py @@ -151,8 +151,9 @@ class MouseEventFilter(QObject): if elem.is_editable(): log.mouse.debug("Clicked editable element!") - modeman.enter(self._tab.win_id, usertypes.KeyMode.insert, - 'click', only_if_normal=True) + if config.val.input.insert_mode.auto_enter: + modeman.enter(self._tab.win_id, usertypes.KeyMode.insert, + 'click', only_if_normal=True) else: log.mouse.debug("Clicked non-editable element!") if config.val.input.insert_mode.auto_leave: diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index 610b3dadb..dee21c2d6 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -411,8 +411,9 @@ class AbstractWebElement(collections.abc.MutableMapping): elif self.is_editable(strict=True): log.webelem.debug("Clicking via JS focus()") self._click_editable(click_target) - modeman.enter(self._tab.win_id, usertypes.KeyMode.insert, - 'clicking input') + if config.val.input.insert_mode.auto_enter: + modeman.enter(self._tab.win_id, usertypes.KeyMode.insert, + 'clicking input') else: self._click_fake_event(click_target) elif click_target in [usertypes.ClickTarget.tab, diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 92d100744..c5d06bf1d 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -981,6 +981,11 @@ input.insert_mode.auto_load: desc: Automatically enter insert mode if an editable element is focused after loading the page. +input.insert_mode.auto_enter: + default: true + type: Bool + desc: Enter insert mode if an editable element is clicked. + input.insert_mode.auto_leave: default: true type: Bool -- cgit v1.2.3-54-g00ecf