def test_bad(self):
        int32_max = 2**31 - 1

        with pytest.raises(cmdutils.CommandError,
                           match="Numeric argument is "
                           "too large for internal int representation."):
            cmdutils.check_overflow(int32_max + 1, 'int')
Ejemplo n.º 2
0
def scroll_px(tab: apitypes.Tab, dx: int, dy: int, count: int = 1) -> None:
    """Scroll the current tab by 'count * dx/dy' pixels.

    Args:
        dx: How much to scroll in x-direction.
        dy: How much to scroll in y-direction.
        count: multiplier
    """
    dx *= count
    dy *= count
    cmdutils.check_overflow(dx, 'int')
    cmdutils.check_overflow(dy, 'int')
    tab.scroller.delta(dx, dy)
Ejemplo n.º 3
0
def scroll_px(tab: apitypes.Tab, dx: int, dy: int, count: int = 1) -> None:
    """Scroll the current tab by 'count * dx/dy' pixels.

    Args:
        dx: How much to scroll in x-direction.
        dy: How much to scroll in y-direction.
        count: multiplier
    """
    dx *= count
    dy *= count
    cmdutils.check_overflow(dx, 'int')
    cmdutils.check_overflow(dy, 'int')
    tab.scroller.delta(dx, dy)
Ejemplo n.º 4
0
    def _add_count_tab(self, *, win_id, param, args, kwargs):
        """Add the count_tab widget argument."""
        tabbed_browser = self._get_objreg(
            win_id=win_id, name='tabbed-browser', scope='window')

        if self._count is None:
            tab = tabbed_browser.widget.currentWidget()
        elif 1 <= self._count <= tabbed_browser.widget.count():
            cmdutils.check_overflow(self._count + 1, 'int')
            tab = tabbed_browser.widget.widget(self._count - 1)
        else:
            tab = None

        self._add_special_arg(value=tab, param=param, args=args,
                              kwargs=kwargs)
Ejemplo n.º 5
0
    def _add_count_tab(self, *, win_id, param, args, kwargs):
        """Add the count_tab widget argument."""
        tabbed_browser = self._get_objreg(
            win_id=win_id, name='tabbed-browser', scope='window')

        if self._count is None:
            tab = tabbed_browser.widget.currentWidget()
        elif 1 <= self._count <= tabbed_browser.widget.count():
            cmdutils.check_overflow(self._count + 1, 'int')
            tab = tabbed_browser.widget.widget(self._count - 1)
        else:
            tab = None

        self._add_special_arg(value=tab, param=param, args=args,
                              kwargs=kwargs)
Ejemplo n.º 6
0
 def test_good(self):
     cmdutils.check_overflow(1, 'int')