summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/hints.py
diff options
context:
space:
mode:
authorJay Kamat <jaygkamat@gmail.com>2019-05-04 18:25:16 -0700
committerJay Kamat <jaygkamat@gmail.com>2019-05-06 00:46:55 -0700
commitad59663c53a632ff31f4f9e1129d8d8c90c907f4 (patch)
treeab06ed6da0c40c2730f1c0cad69fc136a4bcbe8e /qutebrowser/browser/hints.py
parentc388eb677dc9caac35f8c3c31efae3d9b427617f (diff)
downloadqutebrowser-ad59663c53a632ff31f4f9e1129d8d8c90c907f4.tar.gz
qutebrowser-ad59663c53a632ff31f4f9e1129d8d8c90c907f4.zip
Add delete target for hints
Diffstat (limited to 'qutebrowser/browser/hints.py')
-rw-r--r--qutebrowser/browser/hints.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 9278d4f95..375f66cfa 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -41,7 +41,8 @@ from qutebrowser.utils import usertypes, log, qtutils, message, objreg, utils
Target = enum.Enum('Target', ['normal', 'current', 'tab', 'tab_fg', 'tab_bg',
'window', 'yank', 'yank_primary', 'run', 'fill',
- 'hover', 'download', 'userscript', 'spawn'])
+ 'hover', 'download', 'userscript', 'spawn',
+ 'delete'])
class HintingError(Exception):
@@ -147,6 +148,7 @@ class HintContext:
download: Download the link.
userscript: Call a custom userscript.
spawn: Spawn a simple command.
+ delete: Delete the selected element.
to_follow: The link to follow when enter is pressed.
args: Custom arguments for userscript/spawn
rapid: Whether to do rapid hinting.
@@ -327,6 +329,9 @@ class HintActions:
except userscripts.Error as e:
raise HintingError(str(e))
+ def delete(self, elem, _context):
+ elem.delete()
+
def spawn(self, url, context):
"""Spawn a simple command from a hint.
@@ -371,6 +376,7 @@ class HintManager(QObject):
Target.download: "Download hint",
Target.userscript: "Call userscript via hint",
Target.spawn: "Spawn command via hint",
+ Target.delete: "Delete an element",
}
def __init__(self, win_id, tab_id, parent=None):
@@ -888,6 +894,7 @@ class HintManager(QObject):
# _download needs a QWebElement to get the frame.
Target.download: self._actions.download,
Target.userscript: self._actions.call_userscript,
+ Target.delete: self._actions.delete,
}
# Handlers which take a QUrl
url_handlers = {