How to use the qutebrowser.commands.cmdutils.register function in qutebrowser

To help you get started, we’ve selected a few qutebrowser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qutebrowser / qutebrowser / qutebrowser / mainwindow / statusbar / command.py View on Github external
    @cmdutils.register(instance='status-command', hide=True,
                       modes=[usertypes.KeyMode.command], scope='window')
    def command_history_next(self):
        """Go forward in the commandline history."""
        if not self.history.is_browsing():
            return
        try:
            item = self.history.nextitem()
        except cmdhistory.HistoryEndReachedError:
            return
        if item:
            self.set_cmd_text(item)
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', scope='window',
                       maxsplit=0)
    @cmdutils.argument('index', completion=miscmodels.buffer)
    @cmdutils.argument('count', count=True)
    def buffer(self, index=None, count=None):
        """Select tab by index or url/title best match.

        Focuses window if necessary when index is given. If both index and
        count are given, use count.

        With neither index nor count given, open the qute://tabs page.

        Args:
            index: The [win_id/]index of the tab to focus. Or a substring
                   in which case the closest match will be focused.
            count: The tab index to focus, starting with 1.
        """
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', scope='window',
                       maxsplit=0)
    @cmdutils.argument('name', completion=miscmodels.quickmark)
    def quickmark_del(self, name=None):
        """Delete a quickmark.

        Args:
            name: The name of the quickmark to delete. If not given, delete the
                  quickmark for the current page (choosing one arbitrarily
                  if there are more than one).
        """
        quickmark_manager = objreg.get('quickmark-manager')
        if name is None:
            url = self._current_url()
            try:
                name = quickmark_manager.get_by_qurl(url)
            except urlmarks.DoesNotExistError as e:
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret],
                       scope='window')
    @cmdutils.argument('count', count=True)
    def move_to_end_of_prev_block(self, count=1):
        """Move the cursor or selection to the end of previous block.

        Args:
            count: How many blocks to move.
        """
        self._current_widget().caret.move_to_end_of_prev_block(count)
github qutebrowser / qutebrowser / qutebrowser / mainwindow / statusbar / prompter.py View on Github external
    @cmdutils.register(instance='prompter', hide=True, scope='window',
                       modes=[usertypes.KeyMode.prompt], maxsplit=0)
    def prompt_open_download(self, cmdline: str=None):
        """Immediately open a download.

        If no specific command is given, this will use the system's default
        application to open the file.

        Args:
            cmdline: The command which should be used to open the file. A `{}`
                     is expanded to the temporary file name. If no `{}` is
                     present, the filename is automatically appended to the
                     cmdline.
        """
        if self._question.mode != usertypes.PromptMode.download:
            # We just ignore this if we don't have a download question.
            return
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', scope='window')
    @cmdutils.argument('win_id', completion=miscmodels.window)
    @cmdutils.argument('count', count=True)
    def tab_give(self, win_id: int = None, count=None):
        """Give the current tab to a new or existing window if win_id given.

        If no win_id is given, the tab will get detached into a new window.

        Args:
            win_id: The window ID of the window to give the current tab to.
            count: Overrides win_id (index starts at 1 for win_id=0).
        """
        if count is not None:
            win_id = count - 1

        if win_id == self._win_id:
            raise cmdexc.CommandError("Can't give a tab to the same window")
github qutebrowser / qutebrowser / qutebrowser / browser / urlmarks.py View on Github external
    @cmdutils.register(instance='quickmark-manager')
    @cmdutils.argument('win_id', win_id=True)
    def quickmark_add(self, win_id, url, name):
        """Add a new quickmark.

        You can view all saved quickmarks on the
        link:qute://bookmarks[bookmarks page].

        Args:
            win_id: The window ID to display the errors in.
            url: The url to add as quickmark.
            name: The name for the new quickmark.
        """
        # We don't raise cmdexc.CommandError here as this can be called async
        # via prompt_save.
        if not name:
            message.error(win_id, "Can't set mark with empty name!")
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret],
                       scope='window')
    @cmdutils.argument('count', count=True)
    def move_to_start_of_prev_block(self, count=1):
        """Move the cursor or selection to the start of previous block.

        Args:
            count: How many blocks to move.
        """
        self._current_widget().caret.move_to_start_of_prev_block(count)
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', scope='window',
                       maxsplit=0, no_replace_variables=True)
    def spawn(self, cmdline, userscript=False, verbose=False,
              output=False, detach=False):
        """Spawn a command in a shell.

        Args:
            userscript: Run the command as a userscript. You can use an
                        absolute path, or store the userscript in one of those
                        locations:
                            - `~/.local/share/qutebrowser/userscripts`
                              (or `$XDG_DATA_DIR`)
                            - `/usr/share/qutebrowser/userscripts`
            verbose: Show notifications when the command started/exited.
            output: Whether the output should be shown in a new tab.
            detach: Whether the command should be detached from qutebrowser.
            cmdline: The commandline to execute.
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret],
                       scope='window')
    @cmdutils.argument('count', count=True)
    def move_to_prev_word(self, count=1):
        """Move the cursor or selection to the previous word.

        Args:
            count: How many words to move.
        """
        self._current_widget().caret.move_to_prev_word(count)