Пример #1
0
 def column_bindings(self) -> Iterator[List[Tuple[str, str]]]:
     """Return html-safe keybindings for each column sorted by command name."""
     bindings = api.keybindings.get(api.modes.current())
     formatted_bindings = [
         (utils.escape_html(binding), command)
         for binding, command in sorted(bindings, key=lambda x: x[1])
     ]
     return utils.split(formatted_bindings, self.column_count)
Пример #2
0
    def _on_partial_matches(self, prefix: str, matches: Iterator[Tuple[str,
                                                                       str]]):
        """Initialize widget when partial matches exist.

        Args:
            prefix: Key(s) pressed for which there are partial matches.
            matches: List of keybindings and commands that can complete the partial.
        """
        self._show_timer.start()
        text = ""
        for keybinding, command in matches:
            suffix = keybinding[len(prefix):]
            prefix = utils.escape_html(prefix)
            suffix = utils.escape_html(suffix)
            text += ("<tr>"
                     f"<td>{prefix}</td>"
                     f"<td style='color: {self._suffix_color}'>{suffix}</td>"
                     f"<td style='padding-left: 2ex'>{command}</td>"
                     "</tr>")
        self.setText(f"<table>{text}</table>")
        self._update_geometry()
Пример #3
0
 def unprocessed_keys():
     """Unprocessed keys that were pressed."""
     return utils.escape_html(EventHandlerMixin.partial_handler.text)