当前位置: 首页>>代码示例>>Python>>正文


Python modeman.leave函数代码示例

本文整理汇总了Python中qutebrowser.keyinput.modeman.leave函数的典型用法代码示例。如果您正苦于以下问题:Python leave函数的具体用法?Python leave怎么用?Python leave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了leave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _on_aborted

 def _on_aborted(self, key_mode):
     """Leave KEY_MODE whenever a prompt is aborted."""
     try:
         modeman.leave(self._win_id, key_mode, 'aborted', maybe=True)
     except objreg.RegistryUnavailableError:
         # window was deleted: ignore
         pass
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:7,代码来源:prompt.py

示例2: _filter_number_hints

    def _filter_number_hints(self):
        """Apply filters for numbered hints and renumber them.

        Return:
            Elements which are still visible
        """
        # renumber filtered hints
        elems = []
        for e in self._context.all_elems:
            try:
                if not self._is_hidden(e.label):
                    elems.append(e)
            except webelem.IsNullError:
                pass
        if not elems:
            # Whoops, filtered all hints
            modeman.leave(self._win_id, usertypes.KeyMode.hint,
                          'all filtered')
            return {}

        strings = self._hint_strings(elems)
        self._context.elems = {}
        for elem, string in zip(elems, strings):
            elem.label.setInnerXml(string)
            self._context.elems[string] = elem
        keyparsers = objreg.get('keyparsers', scope='window',
                                window=self._win_id)
        keyparser = keyparsers[usertypes.KeyMode.hint]
        keyparser.update_bindings(strings, preserve_filter=True)

        return self._context.elems
开发者ID:djfinlay,项目名称:qutebrowser,代码行数:31,代码来源:hints.py

示例3: filter_hints

    def filter_hints(self, filterstr):
        """Filter displayed hints according to a text.

        Args:
            filterstr: The string to filer with, or None to show all.
        """
        for elems in self._context.elems.values():
            if (filterstr is None or
                    str(elems.elem).lower().startswith(filterstr)):
                if self._is_hidden(elems.label):
                    # hidden element which matches again -> unhide it
                    elems.label.setStyleProperty('display', 'none')
            else:
                # element doesn't match anymore -> hide it
                elems.label.setStyleProperty('display', 'none')
        visible = {}
        for k, e in self._context.elems.items():
            if not self._is_hidden(e.label):
                visible[k] = e
        if not visible:
            # Whoops, filtered all hints
            modeman.leave(self._win_id, usertypes.KeyMode.hint, 'all filtered')
        elif len(visible) == 1 and config.get('hints', 'auto-follow'):
            # unpacking gets us the first (and only) key in the dict.
            self.fire(*visible)
开发者ID:pyrho,项目名称:qutebrowser,代码行数:25,代码来源:hints.py

示例4: filter_hints

    def filter_hints(self, filterstr):
        """Filter displayed hints according to a text.

        Args:
            filterstr: The string to filter with, or None to show all.
        """
        for elems in self._context.elems.values():
            try:
                if (filterstr is None or
                        filterstr.casefold() in str(elems.elem).casefold()):
                    if self._is_hidden(elems.label):
                        # hidden element which matches again -> show it
                        self._show_elem(elems.label)
                else:
                    # element doesn't match anymore -> hide it
                    self._hide_elem(elems.label)
            except webelem.IsNullError:
                pass
        visible = {}
        for k, e in self._context.elems.items():
            try:
                if not self._is_hidden(e.label):
                    visible[k] = e
            except webelem.IsNullError:
                pass
        if not visible:
            # Whoops, filtered all hints
            modeman.leave(self._win_id, usertypes.KeyMode.hint, 'all filtered')
        elif len(visible) == 1 and config.get('hints', 'auto-follow'):
            # unpacking gets us the first (and only) key in the dict.
            self.fire(*visible)
开发者ID:xManusx,项目名称:qutebrowser,代码行数:31,代码来源:hints.py

示例5: prompt_yes

 def prompt_yes(self):
     """Answer yes to a yes/no prompt."""
     if self._question.mode != usertypes.PromptMode.yesno:
         # We just ignore this if we don't have a yes/no question.
         return
     self._question.answer = True
     modeman.leave(usertypes.KeyMode.yesno, 'yesno accept')
     self._question.done()
开发者ID:har5ha,项目名称:qutebrowser,代码行数:8,代码来源:prompter.py

示例6: prompt_no

 def prompt_no(self):
     """Answer no to a yes/no prompt."""
     if self._question.mode != usertypes.PromptMode.yesno:
         # We just ignore this if we don't have a yes/no question.
         return
     self._question.answer = False
     modeman.leave(self._win_id, usertypes.KeyMode.yesno, 'prompt accept')
     self._question.done()
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:8,代码来源:prompter.py

示例7: filter_hints

    def filter_hints(self, filterstr):
        """Filter displayed hints according to a text.

        Args:
            filterstr: The string to filter with, or None to use the filter
                       from previous call (saved in `self._filterstr`). If
                       `filterstr` is an empty string or if both `filterstr`
                       and `self._filterstr` are None, all hints are shown.
        """
        if filterstr is None:
            filterstr = self._context.filterstr
        else:
            self._context.filterstr = filterstr

        log.hints.debug("Filtering hints on {!r}".format(filterstr))

        visible = []
        # pylint: disable=not-an-iterable
        for label in self._context.all_labels:
            try:
                if self._filter_matches(filterstr, str(label.elem)):
                    visible.append(label)
                    # Show label again if it was hidden before
                    label.show()
                else:
                    # element doesn't match anymore -> hide it
                    label.hide()
            except webelem.Error:
                pass
        # pylint: enable=not-an-iterable

        if not visible:
            # Whoops, filtered all hints
            modeman.leave(self._win_id, usertypes.KeyMode.hint,
                          'all filtered')
            return

        if self._context.hint_mode == 'number':
            # renumber filtered hints
            strings = self._hint_strings(visible)
            self._context.labels = {}
            for label, string in zip(visible, strings):
                label.update_text('', string)
                self._context.labels[string] = label
            keyparsers = objreg.get('keyparsers', scope='window',
                                    window=self._win_id)
            keyparser = keyparsers[usertypes.KeyMode.hint]
            keyparser.update_bindings(strings, preserve_filter=True)

            # Note: filter_hints can be called with non-None filterstr only
            # when number mode is active
            if filterstr is not None:
                # pass self._context.labels as the dict of visible hints
                self._handle_auto_follow(filterstr=filterstr,
                                         visible=self._context.labels)
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:55,代码来源:hints.py

示例8: command_accept

 def command_accept(self):
     """Execute the command currently in the commandline."""
     prefixes = {
         ':': '',
         '/': 'search -- ',
         '?': 'search -r -- ',
     }
     text = self.text()
     self.history.append(text)
     modeman.leave(self._win_id, usertypes.KeyMode.command, 'cmd accept')
     self.got_cmd.emit(prefixes[text[0]] + text[1:])
开发者ID:shawa,项目名称:qutebrowser,代码行数:11,代码来源:command.py

示例9: command_accept

 def command_accept(self):
     """Execute the command currently in the commandline."""
     signals = {
         ':': self.got_cmd,
         '/': self.got_search,
         '?': self.got_search_rev,
     }
     text = self.text()
     self.history.append(text)
     modeman.leave(self._win_id, usertypes.KeyMode.command, 'cmd accept')
     if text[0] in signals:
         signals[text[0]].emit(text.lstrip(text[0]))
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:12,代码来源:command.py

示例10: _on_global_mode_left

    def _on_global_mode_left(self, mode):
        """Leave prompt/yesno mode in this window if it was left elsewhere.

        This ensures no matter where a prompt was answered, we leave the prompt
        mode and dispose of the prompt object in every window.
        """
        if mode not in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]:
            return
        modeman.leave(self._win_id, mode, 'left in other window', maybe=True)
        item = self._layout.takeAt(0)
        if item is not None:
            widget = item.widget()
            log.prompt.debug("Deleting prompt {}".format(widget))
            widget.hide()
            widget.deleteLater()
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:15,代码来源:prompt.py

示例11: mouserelease_insertmode_cb

        def mouserelease_insertmode_cb(elem):
            """Callback which gets called from JS."""
            if elem is None:
                log.mouse.debug("Element vanished!")
                return

            if elem.is_editable():
                log.mouse.debug("Clicked editable element (delayed)!")
                modeman.enter(self._tab.win_id, usertypes.KeyMode.insert,
                              'click-delayed', only_if_normal=True)
            else:
                log.mouse.debug("Clicked non-editable element (delayed)!")
                if config.get('input', 'auto-leave-insert-mode'):
                    modeman.leave(self._tab.win_id, usertypes.KeyMode.insert,
                                  'click-delayed', maybe=True)
开发者ID:mlochbaum,项目名称:qutebrowser,代码行数:15,代码来源:mouse.py

示例12: command_accept

    def command_accept(self, rapid=False):
        """Execute the command currently in the commandline.

        Args:
            rapid: Run the command without closing or clearing the command bar.
        """
        text = self.text()
        self.history.append(text)

        was_search = self._handle_search()

        if not rapid:
            modeman.leave(self._win_id, usertypes.KeyMode.command,
                          'cmd accept')

        if not was_search:
            self.got_cmd[str].emit(text[1:])
开发者ID:mehak,项目名称:qutebrowser,代码行数:17,代码来源:command.py

示例13: command_accept

    def command_accept(self):
        """Execute the command currently in the commandline.

        Emit:
            got_cmd: If a new cmd was entered.
            got_search: If a new search was entered.
            got_search_rev: If a new reverse search was entered.
        """
        signals = {
            ':': self.got_cmd,
            '/': self.got_search,
            '?': self.got_search_rev,
        }
        text = self.text()
        self.history.append(text)
        modeman.leave(usertypes.KeyMode.command, 'cmd accept')
        if text[0] in signals:
            signals[text[0]].emit(text.lstrip(text[0]))
开发者ID:har5ha,项目名称:qutebrowser,代码行数:18,代码来源:command.py

示例14: keyPressEvent

    def keyPressEvent(self, e):
        """Override keyPressEvent to ignore Return key presses.

        If this widget is focused, we are in passthrough key mode, and
        Enter/Shift+Enter/etc. will cause QLineEdit to think it's finished
        without command_accept to be called.
        """
        text = self.text()
        if text in modeparsers.STARTCHARS and e.key() == Qt.Key_Backspace:
            e.accept()
            modeman.leave(self._win_id, usertypes.KeyMode.command,
                          'prefix deleted')
            return
        if e.key() == Qt.Key_Return:
            e.ignore()
            return
        else:
            super().keyPressEvent(e)
开发者ID:mehak,项目名称:qutebrowser,代码行数:18,代码来源:command.py

示例15: _filter_non_number_hints

    def _filter_non_number_hints(self):
        """Apply filters for letter/word hints.

        Return:
            Elements which are still visible
        """
        visible = {}
        for string, elem in self._context.elems.items():
            try:
                if not self._is_hidden(elem.label):
                    visible[string] = elem
            except webelem.IsNullError:
                pass
        if not visible:
            # Whoops, filtered all hints
            modeman.leave(self._win_id, usertypes.KeyMode.hint,
                          'all filtered')
        return visible
开发者ID:djfinlay,项目名称:qutebrowser,代码行数:18,代码来源:hints.py


注:本文中的qutebrowser.keyinput.modeman.leave函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。