How to use the qutebrowser.api.cmdutils.argument 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 / components / caretcommands.py View on Github external
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
def move_to_start_of_document(tab: apitypes.Tab) -> None:
    """Move the cursor or selection to the start of the document."""
    tab.caret.move_to_start_of_document()
github qutebrowser / qutebrowser / qutebrowser / components / caretcommands.py View on Github external
@cmdutils.argument('count', value=cmdutils.Value.count)
def move_to_prev_char(tab: apitypes.Tab, count: int = 1) -> None:
    """Move the cursor or selection to the previous char.

    Args:
        count: How many chars to move.
    """
    tab.caret.move_to_prev_char(count)
github qutebrowser / qutebrowser / qutebrowser / completion / completionwidget.py View on Github external
    @cmdutils.argument('which', choices=['next', 'prev', 'next-category',
                                         'prev-category'])
    @cmdutils.argument('history', flag='H')
    def completion_item_focus(self, which, history=False):
        """Shift the focus of the completion menu to another item.

        Args:
            which: 'next', 'prev', 'next-category', or 'prev-category'.
            history: Navigate through command history if no text was typed.
        """
        if history:
            if (self._cmd.text() == ':' or self._cmd.history.is_browsing() or
                    not self._active):
                if which == 'next':
                    self._cmd.command_history_next()
                    return
                elif which == 'prev':
github qutebrowser / qutebrowser / qutebrowser / components / misccommands.py View on Github external
@cmdutils.argument('pdf', flag='f', metavar='file')
def printpage(tab: apitypes.Tab,
              preview: bool = False, *,
              pdf: str = None) -> None:
    """Print the current/[count]th tab.

    Args:
        preview: Show preview instead of printing.
        count: The tab index to print, or None.
        pdf: The file path to write the PDF to.
    """
    if tab is None:
        return

    try:
        if preview:
            _print_preview(tab)
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.argument('count', value=cmdutils.Value.count)
    def forward(self, tab=False, bg=False, window=False, count=1):
        """Go forward in the history of the current tab.

        Args:
            tab: Go forward in a new tab.
            bg: Go forward in a background tab.
            window: Go forward in a new window.
            count: How many pages to go forward.
        """
        self._back_forward(tab, bg, window, count, forward=True)
github qutebrowser / qutebrowser / qutebrowser / components / caretcommands.py View on Github external
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
@cmdutils.argument('count', value=cmdutils.Value.count)
def move_to_start_of_prev_block(tab: apitypes.Tab, count: int = 1) -> None:
    """Move the cursor or selection to the start of previous block.

    Args:
        count: How many blocks to move.
    """
    tab.caret.move_to_start_of_prev_block(count)
github qutebrowser / qutebrowser / qutebrowser / browser / commands.py View on Github external
    @cmdutils.argument('name', completion=miscmodels.quickmark)
    def quickmark_load(self, name, tab=False, bg=False, window=False):
        """Load a quickmark.

        Args:
            name: The name of the quickmark to load.
            tab: Load the quickmark in a new tab.
            bg: Load the quickmark in a new background tab.
            window: Load the quickmark in a new window.
        """
        try:
            url = objreg.get('quickmark-manager').get(name)
        except urlmarks.Error as e:
            raise cmdutils.CommandError(str(e))
        self._open(url, tab, bg, window)
github qutebrowser / qutebrowser / qutebrowser / misc / utilcmds.py View on Github external
@cmdutils.argument('count', value=cmdutils.Value.count)
def run_with_count(count_arg: int, command: str, win_id: int,
                   count: int = 1) -> None:
    """Run a command with the given count.

    If run_with_count itself is run with a count, it multiplies count_arg.

    Args:
        count_arg: The count to pass to the command.
        command: The command to run, with optional args.
        count: The count that run_with_count itself received.
    """
    runners.CommandRunner(win_id).run(command, count_arg * count)
github qutebrowser / qutebrowser / qutebrowser / config / configcommands.py View on Github external
    @cmdutils.argument('value', completion=configmodel.value)
    @cmdutils.argument('win_id', value=cmdutils.Value.win_id)
    @cmdutils.argument('pattern', flag='u')
    def set(self, win_id: int, option: str = None, value: str = None,
            temp: bool = False, print_: bool = False,
            *, pattern: str = None) -> None:
        """Set an option.

        If the option name ends with '?' or no value is provided, the
        value of the option is shown instead.

        Using :set without any arguments opens a page where settings can be
        changed interactively.

        Args:
            option: The name of the option.
            value: The value to set.
github qutebrowser / qutebrowser / qutebrowser / components / caretcommands.py View on Github external
@cmdutils.argument('count', value=cmdutils.Value.count)
def move_to_start_of_next_block(tab: apitypes.Tab, count: int = 1) -> None:
    """Move the cursor or selection to the start of next block.

    Args:
        count: How many blocks to move.
    """
    tab.caret.move_to_start_of_next_block(count)