Exemplo n.º 1
0
    def tab_focus(self,
                  index: {'type': (int, 'last')} = None,
                  count: {'special': 'count'} = None):
        """Select the tab given as argument/[count].

        Args:
            index: The tab index to focus, starting with 1. The special value
                   `last` focuses the last focused tab.
            count: The tab index to focus, starting with 1.
        """
        if index == 'last':
            self._tab_focus_last()
            return
        try:
            idx = cmdutils.arg_or_count(index,
                                        count,
                                        default=1,
                                        countzero=self._count())
        except ValueError as e:
            raise cmdexc.CommandError(e)
        cmdutils.check_overflow(idx + 1, 'int')
        if 1 <= idx <= self._count():
            self._set_current_index(idx - 1)
        else:
            raise cmdexc.CommandError(
                "There's no tab with index {}!".format(idx))
Exemplo n.º 2
0
    def zoom(self, zoom=None, count: {'special': 'count'}=None):
        """Set the zoom level for the current tab.

        The zoom can be given as argument or as [count]. If neither of both is
        given, the zoom is set to 100%.

        Args:
            zoom: The zoom percentage to set.
            count: The zoom percentage to set.
        """
        try:
            level = cmdutils.arg_or_count(zoom, count, default=100)
        except ValueError as e:
            raise cmdexc.CommandError(e)
        tab = self._current_widget()
        tab.zoom_perc(level)
Exemplo n.º 3
0
    def zoom(self, zoom=None, count: {'special': 'count'} = None):
        """Set the zoom level for the current tab.

        The zoom can be given as argument or as [count]. If neither of both is
        given, the zoom is set to 100%.

        Args:
            zoom: The zoom percentage to set.
            count: The zoom percentage to set.
        """
        try:
            level = cmdutils.arg_or_count(zoom, count, default=100)
        except ValueError as e:
            raise cmdexc.CommandError(e)
        tab = self._current_widget()
        tab.zoom_perc(level)
Exemplo n.º 4
0
    def zoom(self, zoom: {'type': int}=None, count=None):
        """Set the zoom level for the current tab.

        The zoom can be given as argument or as [count]. If neither of both is
        given, the zoom is set to the default zoom.

        Args:
            zoom: The zoom percentage to set.
            count: The zoom percentage to set.
        """
        try:
            default = config.get('ui', 'default-zoom')
            level = cmdutils.arg_or_count(zoom, count, default=default)
        except ValueError as e:
            raise cmdexc.CommandError(e)
        tab = self._current_widget()
        tab.zoom_perc(level)
Exemplo n.º 5
0
    def zoom(self, zoom: {'type': int} = None, count=None):
        """Set the zoom level for the current tab.

        The zoom can be given as argument or as [count]. If neither of both is
        given, the zoom is set to the default zoom.

        Args:
            zoom: The zoom percentage to set.
            count: The zoom percentage to set.
        """
        try:
            default = config.get('ui', 'default-zoom')
            level = cmdutils.arg_or_count(zoom, count, default=default)
        except ValueError as e:
            raise cmdexc.CommandError(e)
        tab = self._current_widget()
        tab.zoom_perc(level)
Exemplo n.º 6
0
    def tab_focus(self, index: {'type': (int, 'last')}=None, count=None):
        """Select the tab given as argument/[count].

        Args:
            index: The tab index to focus, starting with 1. The special value
                   `last` focuses the last focused tab.
            count: The tab index to focus, starting with 1.
        """
        if index == 'last':
            self._tab_focus_last()
            return
        try:
            idx = cmdutils.arg_or_count(index, count, default=1,
                                        countzero=self._count())
        except ValueError as e:
            raise cmdexc.CommandError(e)
        cmdutils.check_overflow(idx + 1, 'int')
        if 1 <= idx <= self._count():
            self._set_current_index(idx - 1)
        else:
            raise cmdexc.CommandError("There's no tab with index {}!".format(
                idx))
Exemplo n.º 7
0
 def test_default(self):
     assert cmdutils.arg_or_count(None, None, default=2) == 2
Exemplo n.º 8
0
 def test_countzero(self, arg, count, countzero, expected):
     ret = cmdutils.arg_or_count(arg, count, countzero=countzero)
     assert ret == expected
Exemplo n.º 9
0
 def test_normal(self, arg, count):
     assert cmdutils.arg_or_count(arg, count) == 1
Exemplo n.º 10
0
 def test_exceptions(self, arg, count):
     with pytest.raises(ValueError):
         cmdutils.arg_or_count(arg, count)
Exemplo n.º 11
0
 def test_default(self):
     assert cmdutils.arg_or_count(None, None, default=2) == 2
Exemplo n.º 12
0
 def test_countzero(self, arg, count, countzero, expected):
     ret = cmdutils.arg_or_count(arg, count, countzero=countzero)
     assert ret == expected
Exemplo n.º 13
0
 def test_normal(self, arg, count):
     assert cmdutils.arg_or_count(arg, count) == 1
Exemplo n.º 14
0
 def test_exceptions(self, arg, count):
     with pytest.raises(ValueError):
         cmdutils.arg_or_count(arg, count)