diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 948cc6bb3..3cb69e06d 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -71,6 +71,8 @@ class QuteBrowser(QApplication): self.aboutToQuit.connect(config.config.save) self.mainwindow.tabs.keypress.connect(self.keyparser.handle) self.keyparser.set_cmd_text.connect(self.mainwindow.status.cmd.set_cmd) + self.mainwindow.tabs.set_cmd_text.connect( + self.mainwindow.status.cmd.set_cmd) self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.run) self.mainwindow.status.cmd.got_search.connect(self.searchparser.search) self.mainwindow.status.cmd.got_search_rev.connect( @@ -226,7 +228,9 @@ class QuteBrowser(QApplication): handlers = { 'open': self.mainwindow.tabs.openurl, + 'opencur': self.mainwindow.tabs.opencur, 'tabopen': self.mainwindow.tabs.tabopen, + 'tabopencur': self.mainwindow.tabs.tabopencur, 'quit': self.quit, 'tabclose': self.mainwindow.tabs.cur_close, 'tabprev': self.mainwindow.tabs.switch_prev, diff --git a/qutebrowser/commands/__init__.py b/qutebrowser/commands/__init__.py index 906b25805..f3d7d4148 100644 --- a/qutebrowser/commands/__init__.py +++ b/qutebrowser/commands/__init__.py @@ -31,6 +31,12 @@ class Open(Command): count = True +class OpenCur(Command): + """Fill the statusbar with :open and the current url.""" + nargs = 0 + hide = True + + class TabOpen(Command): """Open a page in a new tab. @@ -41,6 +47,12 @@ class TabOpen(Command): split_args = False +class TabOpenCur(Command): + """Fill the statusbar with :tabopen and the current url.""" + nargs = 0 + hide = True + + class TabClose(Command): """Close the current tab, or tab [count].""" nargs = 0 diff --git a/qutebrowser/utils/config.py b/qutebrowser/utils/config.py index 791983698..baa33fdfd 100644 --- a/qutebrowser/utils/config.py +++ b/qutebrowser/utils/config.py @@ -25,7 +25,9 @@ default_config = """ [keybind] o = open + go = opencur O = tabopen + gO = tabopencur d = tabclose J = tabnext K = tabprev diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index 03d8b5b39..189511c3b 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -40,6 +40,7 @@ class TabbedBrowser(TabWidget): cur_statusbar_message = pyqtSignal(str) # Status bar message # Current tab changed scroll position cur_scroll_perc_changed = pyqtSignal(int, int) + set_cmd_text = pyqtSignal(str) # Set commandline to a given text keypress = pyqtSignal('QKeyEvent') _url_stack = [] # Stack of URLs of closed tabs @@ -76,6 +77,11 @@ class TabbedBrowser(TabWidget): # FIXME sometimes this doesn't load tab.open_tab.connect(self.tabopen) + def tabopencur(self): + """Set the statusbar to :tabopen and the current URL.""" + url = self.currentWidget().url().toString() + self.set_cmd_text.emit(':tabopen ' + url) + def openurl(self, url, count=None): """Open an url in the current/[count]th tab. @@ -86,6 +92,11 @@ class TabbedBrowser(TabWidget): if tab is not None: tab.openurl(url) + def opencur(self): + """Set the statusbar to :open and the current URL.""" + url = self.currentWidget().url().toString() + self.set_cmd_text.emit(':open ' + url) + def undo_close(self): """Undo closing a tab.