KeyMap Expansion

This commit is contained in:
2025-07-31 13:31:14 -05:00
parent 174fab2c6d
commit 9e88799391
7 changed files with 111 additions and 54 deletions

18
chat.go
View File

@@ -166,12 +166,12 @@ func (w *Chat) WantW() int { return w.w }
func (w *Chat) WantH() int { return w.h }
func (w *Chat) initKeyMap() {
w.keyMap = NewKeyMap(map[tcell.Key]func() bool{
tcell.KeyEsc: func() bool {
w.keyMap = NewKeyMap(map[tcell.Key]func(ev *tcell.EventKey) bool{
tcell.KeyEsc: func(ev *tcell.EventKey) bool {
w.SetActive(false)
return true
},
tcell.KeyUp: func() bool {
tcell.KeyUp: func(ev *tcell.EventKey) bool {
if w.historyPosition < len(w.history)-1 {
w.historyPosition++
w.value = w.history[w.historyPosition].Message
@@ -180,7 +180,7 @@ func (w *Chat) initKeyMap() {
}
return false
},
tcell.KeyDown: func() bool {
tcell.KeyDown: func(ev *tcell.EventKey) bool {
if w.historyPosition > -1 {
w.historyPosition--
if w.historyPosition == -1 {
@@ -193,31 +193,31 @@ func (w *Chat) initKeyMap() {
}
return false
},
tcell.KeyLeft: func() bool {
tcell.KeyLeft: func(ev *tcell.EventKey) bool {
if w.cursor > 0 {
w.cursor--
return true
}
return false
},
tcell.KeyRight: func() bool {
tcell.KeyRight: func(ev *tcell.EventKey) bool {
if w.cursor < len(w.value) {
w.cursor++
return true
}
return false
},
tcell.KeyCtrlU: func() bool {
tcell.KeyCtrlU: func(ev *tcell.EventKey) bool {
w.value = w.value[w.cursor:]
w.cursor = 0
return true
},
tcell.KeyTab: func() bool {
tcell.KeyTab: func(ev *tcell.EventKey) bool {
// Auto-complete
// TODO: Find best guess for current word
return false
},
tcell.KeyEnter: func() bool {
tcell.KeyEnter: func(ev *tcell.EventKey) bool {
// TODO: Submit the message
return false
},