textual_adapter
Class info¶
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| CommandInput | slashed.textual_adapter.command_input | Single-line command input with completion support. |
| CommandTextArea | slashed.textual_adapter.command_textarea | Multi-line command input with completion support. |
| SlashedApp | slashed.textual_adapter.app | Base app with slash command support. |
| SlashedSuggester | slashed.textual_adapter.suggester | Adapts a Slashed CompletionProvider to Textual's Suggester interface. |
| TextualOutputWriter | slashed.textual_adapter.app | Output writer that routes messages to bound widgets. |
🛈 DocStrings¶
Textual integration for Slashed.
CommandInput
¶
Bases: Input, CommandWidgetMixin[TContext]
Single-line command input with completion support.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TContext
|
Type of the context data available to commands via ctx.get_data() |
required |
Source code in src/slashed/textual_adapter/command_input.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
action_accept_completion
¶
Accept the currently selected completion.
Source code in src/slashed/textual_adapter/command_input.py
action_hide_dropdown
¶
action_navigate_down
¶
action_navigate_up
¶
on_input_changed
async
¶
Update completions when input changes.
Source code in src/slashed/textual_adapter/command_input.py
on_key
¶
Handle special keys.
Source code in src/slashed/textual_adapter/command_input.py
CommandTextArea
¶
Bases: TextArea, CommandWidgetMixin[TContext]
Multi-line command input with completion support.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TContext
|
Type of the context data available to commands via ctx.get_data() |
required |
Source code in src/slashed/textual_adapter/command_textarea.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
action_accept_completion
¶
Accept the currently selected completion.
Source code in src/slashed/textual_adapter/command_textarea.py
action_hide_dropdown
¶
action_navigate_down
¶
action_navigate_up
¶
clear_input
¶
get_cursor_screen_position
¶
get_first_line
¶
on_key
¶
Handle special keys.
Source code in src/slashed/textual_adapter/command_textarea.py
on_text_area_changed
async
¶
SlashedApp
¶
Bases: App[TResult]
Base app with slash command support.
This app provides slash command functionality with optional typed context data. Commands can access the context data through self.context.get_data().
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TContext
|
Type of the command context data. When using typed context, access it via self.context.get_data() to get proper type checking. |
required | |
TResult
|
Type of value returned by app.run(). Use None if the app doesn't return anything. |
required |
Example
Source code in src/slashed/textual_adapter/app.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
__init__
¶
__init__(
store: CommandStore | None = None,
data: TContext | None = None,
commands: list[type[SlashedCommand] | BaseCommand] | None = None,
*args: Any,
**kwargs: Any,
) -> None
Initialize app with command store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TContext | None
|
Optional context data |
None
|
commands
|
list[type[SlashedCommand] | BaseCommand] | None
|
Optional list of commands to register |
None
|
store
|
CommandStore | None
|
Optional command store (creates new one if not provided) |
None
|
*args
|
Any
|
Arguments passed to textual.App |
()
|
**kwargs
|
Any
|
Keyword arguments passed to textual.App |
{}
|
Source code in src/slashed/textual_adapter/app.py
bind_output
¶
Bind an output stream to a widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
str
|
ID for this output stream |
required |
widget_query
|
str
|
CSS query to find the target widget |
required |
default
|
bool
|
Whether this is the default output |
False
|
Source code in src/slashed/textual_adapter/app.py
command_input
classmethod
¶
command_input(
input_id: str,
) -> Callable[[Callable[[Any, str], Awaitable[None]]], Callable[[Any, str], Awaitable[None]]]
Register an Input widget to handle commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_id
|
str
|
ID of the Input widget that should handle commands |
required |
Example
Source code in src/slashed/textual_adapter/app.py
get_suggester
¶
get_suggester() -> SlashedSuggester
on_input_submitted
async
¶
Handle input submission.
Source code in src/slashed/textual_adapter/app.py
SlashedSuggester
¶
Bases: Suggester
Adapts a Slashed CompletionProvider to Textual's Suggester interface.
Source code in src/slashed/textual_adapter/suggester.py
__init__
¶
__init__(store: CommandStore, context: CommandContext[Any], case_sensitive: bool = False) -> None
Initialize suggester with store and context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
CommandStore
|
Command store for looking up commands and completers |
required |
context
|
CommandContext[Any]
|
Command execution context |
required |
case_sensitive
|
bool
|
Whether to use case-sensitive matching |
False
|
Source code in src/slashed/textual_adapter/suggester.py
get_suggestion
async
¶
Get completion suggestion for current input value.
Source code in src/slashed/textual_adapter/suggester.py
TextualOutputWriter
¶
Bases: OutputWriter
Output writer that routes messages to bound widgets.
Supports different widget types: - Labels: Direct update of content - VerticalScroll/Container: Mount new Label with content - Other widgets: Try update() method
Source code in src/slashed/textual_adapter/app.py
bind
¶
Bind an output to a widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
str
|
ID for this output stream |
required |
widget_query
|
str
|
CSS query to find the target widget |
required |
default
|
bool
|
Whether this is the default output for unspecified streams |
False
|
Source code in src/slashed/textual_adapter/app.py
print
async
¶
Print message to bound widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to display |
required |
output_id
|
str | None
|
Optional output stream ID. Uses default if not specified. |
None
|
The message is handled differently based on widget type: - For containers (VerticalScroll/Container): Mount new Label - For Label widgets: Update content - For other widgets: Try update() method
Raises:
| Type | Description |
|---|---|
ValueError
|
If no default binding is configured or binding not found |
TypeError
|
If widget type is not supported |