trading_agent.terminal.widgets.composer
¶
The box where the user writes messages, with Claude Code's keys.
Enter sends. A ? typed into the empty box asks for the list of keys. File paths pasted by dragging files onto the terminal become attachments, Ctrl+V attaches a picture on the clipboard, and Backspace in the empty box removes the newest attachment. Shift+Enter, Alt+Enter, Ctrl+J, or a backslash typed just before Enter, starts a new line. Up on the first line and Down on the last line move through earlier prompts. While the command menu is open, Up, Down and Tab move through the menu and Enter picks from it.
Typical usage example:
composer = Composer(PromptHistory(None)) # The screen handles Composer.Submitted, MenuMoved and MenuPicked.
Composer
¶
Bases: TextArea
The message box.
Attributes:
| Name | Type | Description |
|---|---|---|
menu_open |
Whether the command menu above the box is showing, set by the screen. |
Creates the box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
PromptHistory
|
The earlier prompts, for Up and Down. |
required |
placeholder
|
str
|
The hint shown while the box is empty. |
''
|
Source code in src/trading_agent/terminal/widgets/composer.py
Submitted
¶
Bases: Message
The user pressed Enter to send what is in the box.
Creates the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
What the box held. |
required |
Source code in src/trading_agent/terminal/widgets/composer.py
MenuMoved
¶
Bases: Message
The user moved the command menu's highlight.
Creates the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
-1 for up, 1 for down. |
required |
Source code in src/trading_agent/terminal/widgets/composer.py
MenuPicked
¶
Bases: Message
The user picked the highlighted command with Tab.
KeysWanted
¶
Bases: Message
The user typed ? into the empty box, asking for the list of keys.
FilesDropped
¶
Bases: Message
Files were dragged onto the terminal, which pasted their paths.
Creates the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[Path]
|
The files. |
required |
Source code in src/trading_agent/terminal/widgets/composer.py
PictureWanted
¶
Bases: Message
The user pressed Ctrl+V, which attaches a picture on the clipboard.
EmptyBackspace
¶
Bases: Message
The user pressed Backspace in the empty box, which removes the newest attached file.
set_text
¶
Replaces the box's text and puts the cursor at its end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The new text. |
required |