Skip to content

SessionCommands

Base classes

Name Children Inherits
Provider
textual.command
Base class for command palette command providers.

⋔ Inheritance diagram

graph TD
  107846719569600["app.SessionCommands"]
  107846718989776["command.Provider"]
  107846685946768["abc.ABC"]
  137699722799616["builtins.object"]
  107846718989776 --> 107846719569600
  107846685946768 --> 107846718989776
  137699722799616 --> 107846685946768

🛈 DocStrings

Bases: Provider

Command palette entries of the session screen.

Source code in src/acptui/ui/app.py
class SessionCommands(Provider):
    """Command palette entries of the session screen."""

    def _commands(self) -> list[tuple[str, str, Callable[[], object]]]:
        screen = self.screen
        return list(session_commands(screen)) if isinstance(screen, SessionScreen) else []

    async def discover(self) -> Hits:
        for name, help_text, callback in self._commands():
            yield DiscoveryHit(name, callback, help=help_text)

    async def search(self, query: str) -> Hits:
        matcher = self.matcher(query)
        for name, help_text, callback in self._commands():
            if (score := matcher.match(name)) > 0:
                yield Hit(score, matcher.highlight(name), callback, help=help_text)

:fa-brands-github: Show source on GitHub