Change summary
internal/ui/model/keys.go | 5 +++++
internal/ui/model/ui.go | 8 ++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
Detailed changes
@@ -10,6 +10,7 @@ type KeyMap struct {
Newline key.Binding
AddImage key.Binding
MentionFile key.Binding
+ Commands key.Binding
// Attachments key maps
AttachmentDeleteMode key.Binding
@@ -123,6 +124,10 @@ func DefaultKeyMap() KeyMap {
key.WithKeys("@"),
key.WithHelp("@", "mention file"),
)
+ km.Editor.Commands = key.NewBinding(
+ key.WithKeys("/"),
+ key.WithHelp("/", "commands"),
+ )
km.Editor.AttachmentDeleteMode = key.NewBinding(
key.WithKeys("ctrl+r"),
key.WithHelp("ctrl+r+{i}", "delete attachment at index i"),
@@ -1542,6 +1542,10 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
if cmd != nil {
cmds = append(cmds, cmd)
}
+ case key.Matches(msg, m.keyMap.Editor.Commands) && m.textarea.Value() == "":
+ if cmd := m.openCommandsDialog(); cmd != nil {
+ cmds = append(cmds, cmd)
+ }
default:
if handleGlobalKeys(msg) {
// Handle global keys first before passing to textarea.
@@ -1865,7 +1869,7 @@ func (m *UI) ShortHelp() []key.Binding {
k := &m.keyMap
tab := k.Tab
commands := k.Commands
- if m.focus == uiFocusEditor && m.textarea.LineCount() == 0 {
+ if m.focus == uiFocusEditor && m.textarea.Value() == "" {
commands.SetHelp("/ or ctrl+p", "commands")
}
@@ -1941,7 +1945,7 @@ func (m *UI) FullHelp() [][]key.Binding {
hasAttachments := len(m.attachments.List()) > 0
hasSession := m.hasSession()
commands := k.Commands
- if m.focus == uiFocusEditor && m.textarea.LineCount() == 0 {
+ if m.focus == uiFocusEditor && m.textarea.Value() == "" {
commands.SetHelp("/ or ctrl+p", "commands")
}