示例#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))
示例#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)
示例#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)
示例#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)
示例#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)
示例#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))
示例#7
0
 def test_default(self):
     assert cmdutils.arg_or_count(None, None, default=2) == 2
示例#8
0
 def test_countzero(self, arg, count, countzero, expected):
     ret = cmdutils.arg_or_count(arg, count, countzero=countzero)
     assert ret == expected
示例#9
0
 def test_normal(self, arg, count):
     assert cmdutils.arg_or_count(arg, count) == 1
示例#10
0
 def test_exceptions(self, arg, count):
     with pytest.raises(ValueError):
         cmdutils.arg_or_count(arg, count)
 def test_default(self):
     assert cmdutils.arg_or_count(None, None, default=2) == 2
 def test_countzero(self, arg, count, countzero, expected):
     ret = cmdutils.arg_or_count(arg, count, countzero=countzero)
     assert ret == expected
 def test_normal(self, arg, count):
     assert cmdutils.arg_or_count(arg, count) == 1
 def test_exceptions(self, arg, count):
     with pytest.raises(ValueError):
         cmdutils.arg_or_count(arg, count)