Command cleanup
This commit is contained in:
parent
0f943f747c
commit
844e536fff
@ -139,8 +139,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def tab_close(self, count=None):
|
def tab_close(self, count=None):
|
||||||
"""Close the current/[count]th tab.
|
"""Close the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :tab-close.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: The tab index to close, or None
|
count: The tab index to close, or None
|
||||||
|
|
||||||
@ -158,8 +156,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def openurl(self, url, count=None):
|
def openurl(self, url, count=None):
|
||||||
"""Open a URL in the current/[count]th tab.
|
"""Open a URL in the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :open.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
url: The URL to open.
|
url: The URL to open.
|
||||||
count: The tab index to open the URL in, or None.
|
count: The tab index to open the URL in, or None.
|
||||||
@ -180,8 +176,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def reloadpage(self, count=None):
|
def reloadpage(self, count=None):
|
||||||
"""Reload the current/[count]th tab.
|
"""Reload the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :reload.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: The tab index to reload, or None.
|
count: The tab index to reload, or None.
|
||||||
"""
|
"""
|
||||||
@ -193,8 +187,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def stop(self, count=None):
|
def stop(self, count=None):
|
||||||
"""Stop loading in the current/[count]th tab.
|
"""Stop loading in the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :stop.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: The tab index to stop, or None.
|
count: The tab index to stop, or None.
|
||||||
"""
|
"""
|
||||||
@ -206,8 +198,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def print_preview(self, count=None):
|
def print_preview(self, count=None):
|
||||||
"""Preview printing of the current/[count]th tab.
|
"""Preview printing of the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :print-preview.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: The tab index to print, or None.
|
count: The tab index to print, or None.
|
||||||
"""
|
"""
|
||||||
@ -221,8 +211,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def printpage(self, count=None):
|
def printpage(self, count=None):
|
||||||
"""Print the current/[count]th tab.
|
"""Print the current/[count]th tab.
|
||||||
|
|
||||||
Command handler for :print.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: The tab index to print, or None.
|
count: The tab index to print, or None.
|
||||||
"""
|
"""
|
||||||
@ -238,8 +226,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def back(self, count=1):
|
def back(self, count=1):
|
||||||
"""Go back in the history of the current tab.
|
"""Go back in the history of the current tab.
|
||||||
|
|
||||||
Command handler for :back.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: How many pages to go back.
|
count: How many pages to go back.
|
||||||
"""
|
"""
|
||||||
@ -250,8 +236,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def forward(self, count=1):
|
def forward(self, count=1):
|
||||||
"""Go forward in the history of the current tab.
|
"""Go forward in the history of the current tab.
|
||||||
|
|
||||||
Command handler for :forward.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: How many pages to go forward.
|
count: How many pages to go forward.
|
||||||
"""
|
"""
|
||||||
@ -262,8 +246,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def hint(self, groupstr='all', targetstr='normal'):
|
def hint(self, groupstr='all', targetstr='normal'):
|
||||||
"""Start hinting.
|
"""Start hinting.
|
||||||
|
|
||||||
Command handler for :hint.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
groupstr: The hinting mode to use.
|
groupstr: The hinting mode to use.
|
||||||
targetstr: Where to open the links.
|
targetstr: Where to open the links.
|
||||||
@ -311,8 +293,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def scroll(self, dx, dy, count=1):
|
def scroll(self, dx, dy, count=1):
|
||||||
"""Scroll the current tab by count * dx/dy.
|
"""Scroll the current tab by count * dx/dy.
|
||||||
|
|
||||||
Command handler for :scroll.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dx: How much to scroll in x-direction.
|
dx: How much to scroll in x-direction.
|
||||||
dy: How much to scroll in x-direction.
|
dy: How much to scroll in x-direction.
|
||||||
@ -324,26 +304,20 @@ class CurCommandDispatcher(QObject):
|
|||||||
cmdutils.check_overflow(dy, 'int')
|
cmdutils.check_overflow(dy, 'int')
|
||||||
self._tabs.currentWidget().page_.currentFrame().scroll(dx, dy)
|
self._tabs.currentWidget().page_.currentFrame().scroll(dx, dy)
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='scroll-perc-x',
|
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
|
||||||
hide=True)
|
def scroll_perc_x(self, perc=None, count=None):
|
||||||
def scroll_percent_x(self, perc=None, count=None):
|
|
||||||
"""Scroll the current tab to a specific percent of the page (horiz).
|
"""Scroll the current tab to a specific percent of the page (horiz).
|
||||||
|
|
||||||
Command handler for :scroll_perc_x.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
perc: Percentage to scroll.
|
perc: Percentage to scroll.
|
||||||
count: Percentage to scroll.
|
count: Percentage to scroll.
|
||||||
"""
|
"""
|
||||||
self._scroll_percent(perc, count, Qt.Horizontal)
|
self._scroll_percent(perc, count, Qt.Horizontal)
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='scroll-perc-y',
|
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
|
||||||
hide=True)
|
def scroll_perc_y(self, perc=None, count=None):
|
||||||
def scroll_percent_y(self, perc=None, count=None):
|
|
||||||
"""Scroll the current tab to a specific percent of the page (vert).
|
"""Scroll the current tab to a specific percent of the page (vert).
|
||||||
|
|
||||||
Command handler for :scroll_perc_y
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
perc: Percentage to scroll.
|
perc: Percentage to scroll.
|
||||||
count: Percentage to scroll.
|
count: Percentage to scroll.
|
||||||
@ -371,24 +345,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def yank(self, sel=False):
|
def yank(self, sel=False):
|
||||||
"""Yank the current URL to the clipboard or primary selection.
|
"""Yank the current URL to the clipboard or primary selection.
|
||||||
|
|
||||||
Command handler for :yank.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
sel: True to use primary selection, False to use clipboard
|
|
||||||
"""
|
|
||||||
clip = QApplication.clipboard()
|
|
||||||
url = urlutils.urlstring(self._tabs.currentWidget().url())
|
|
||||||
mode = QClipboard.Selection if sel else QClipboard.Clipboard
|
|
||||||
clip.setText(url, mode)
|
|
||||||
message.info("URL yanked to {}".format("primary selection" if sel
|
|
||||||
else "clipboard"))
|
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
|
||||||
def yank_title(self, sel=False):
|
|
||||||
"""Yank the current title to the clipboard or primary selection.
|
|
||||||
|
|
||||||
Command handler for :yank-title.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sel: True to use primary selection, False to use clipboard
|
sel: True to use primary selection, False to use clipboard
|
||||||
"""
|
"""
|
||||||
@ -419,8 +375,8 @@ class CurCommandDispatcher(QObject):
|
|||||||
tab = self._tabs.currentWidget()
|
tab = self._tabs.currentWidget()
|
||||||
tab.zoom(-count)
|
tab.zoom(-count)
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='zoom')
|
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||||
def zoom_perc(self, zoom=None, count=None):
|
def zoom(self, zoom=None, count=None):
|
||||||
"""Set the zoom level for the current tab to [count] or 100 percent.
|
"""Set the zoom level for the current tab to [count] or 100 percent.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -469,23 +425,18 @@ class CurCommandDispatcher(QObject):
|
|||||||
url = urlutils.urlstring(self._tabs.currentWidget().url())
|
url = urlutils.urlstring(self._tabs.currentWidget().url())
|
||||||
message.set_cmd_text(':open-tab-bg ' + url)
|
message.set_cmd_text(':open-tab-bg ' + url)
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='undo')
|
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||||
def undo_close(self):
|
def undo(self):
|
||||||
"""Re-open a closed tab (optionally skipping [count] tabs).
|
"""Re-open a closed tab (optionally skipping [count] tabs)."""
|
||||||
|
|
||||||
Command handler for :undo.
|
|
||||||
"""
|
|
||||||
if self._tabs.url_stack:
|
if self._tabs.url_stack:
|
||||||
self.tabopen(self._tabs.url_stack.pop())
|
self.tabopen(self._tabs.url_stack.pop())
|
||||||
else:
|
else:
|
||||||
raise CommandError("Nothing to undo!")
|
raise CommandError("Nothing to undo!")
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='tab-prev')
|
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||||
def switch_prev(self, count=1):
|
def tab_prev(self, count=1):
|
||||||
"""Switch to the previous tab, or skip [count] tabs.
|
"""Switch to the previous tab, or skip [count] tabs.
|
||||||
|
|
||||||
Command handler for :tab-prev.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: How many tabs to switch back.
|
count: How many tabs to switch back.
|
||||||
"""
|
"""
|
||||||
@ -497,12 +448,10 @@ class CurCommandDispatcher(QObject):
|
|||||||
else:
|
else:
|
||||||
raise CommandError("First tab")
|
raise CommandError("First tab")
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', name='tab-next')
|
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||||
def switch_next(self, count=1):
|
def tab_next(self, count=1):
|
||||||
"""Switch to the next tab, or skip [count] tabs.
|
"""Switch to the next tab, or skip [count] tabs.
|
||||||
|
|
||||||
Command handler for :tab-next.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: How many tabs to switch forward.
|
count: How many tabs to switch forward.
|
||||||
"""
|
"""
|
||||||
@ -518,8 +467,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def paste(self, sel=False, tab=False):
|
def paste(self, sel=False, tab=False):
|
||||||
"""Open a page from the clipboard.
|
"""Open a page from the clipboard.
|
||||||
|
|
||||||
Command handler for :paste.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sel: True to use primary selection, False to use clipboard
|
sel: True to use primary selection, False to use clipboard
|
||||||
tab: True to open in a new tab.
|
tab: True to open in a new tab.
|
||||||
@ -539,8 +486,6 @@ class CurCommandDispatcher(QObject):
|
|||||||
def paste_tab(self, sel=False):
|
def paste_tab(self, sel=False):
|
||||||
"""Open a page from the clipboard in a new tab.
|
"""Open a page from the clipboard in a new tab.
|
||||||
|
|
||||||
Command handler for :paste.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sel: True to use primary selection, False to use clipboard
|
sel: True to use primary selection, False to use clipboard
|
||||||
"""
|
"""
|
||||||
@ -631,8 +576,8 @@ class CurCommandDispatcher(QObject):
|
|||||||
self.openurl(config.get('general', 'startpage')[0])
|
self.openurl(config.get('general', 'startpage')[0])
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow.tabs.cmd', modes=['insert'],
|
@cmdutils.register(instance='mainwindow.tabs.cmd', modes=['insert'],
|
||||||
name='open_editor', hide=True)
|
hide=True)
|
||||||
def editor(self):
|
def open_editor(self):
|
||||||
"""Open an external editor with the current form field.
|
"""Open an external editor with the current form field.
|
||||||
|
|
||||||
We use QProcess rather than subprocess here because it makes it a lot
|
We use QProcess rather than subprocess here because it makes it a lot
|
||||||
|
@ -50,7 +50,7 @@ def log_events(klass):
|
|||||||
return klass
|
return klass
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(name='set-trace', hide=True)
|
@cmdutils.register(hide=True)
|
||||||
def set_trace():
|
def set_trace():
|
||||||
"""Set a tracepoint in the Python debugger that works with Qt.
|
"""Set a tracepoint in the Python debugger that works with Qt.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user