Skip to content

dropdown

Class info

Classes

Name Children Inherits
CommandDropdown
slashed.textual_adapter.dropdown
Dropdown list for command completions.
    CompletionOption
    slashed.textual_adapter.dropdown
    An option in the completion dropdown.

      🛈 DocStrings

      Dropdown widgets for command completion.

      CommandDropdown

      Bases: OptionList

      Dropdown list for command completions.

      Source code in src/slashed/textual_adapter/dropdown.py
      class CommandDropdown(OptionList):
          """Dropdown list for command completions."""
      
          DEFAULT_CSS = """
          CommandDropdown {
              background: $surface;
              border: solid $primary;
              height: auto;
              max-height: 10;
              min-width: 30;
              padding: 0 1;
              layer: dropdown;
          }
          """
      
          COMPONENT_CLASSES: ClassVar[set[str]] = {
              "option-list--option",
              "option-list--option-highlighted",
              "option-list--option-hover-highlighted",
          }
      

      CompletionOption

      Bases: Option

      An option in the completion dropdown.

      Source code in src/slashed/textual_adapter/dropdown.py
      class CompletionOption(Option):
          """An option in the completion dropdown."""
      
          def __init__(self, completion: CompletionItem) -> None:
              display = Text.from_markup(f"[blue]{completion.text}[/]")
              if completion.metadata:
                  # Only use first line of metadata
                  first_line = utils.get_first_line(completion.metadata) or ""
                  display.append_text(Text.from_markup(f" - [green]{first_line}[/]"))
              super().__init__(display)
              self.completion = completion