refactor!: use term/input

feat: update bubbletea & term/input

refactor!: use term/input for input handling

Reference: https://github.com/charmbracelet/x/tree/main/exp/term
This commit is contained in:
Ayman Bagabas
2024-04-22 16:24:27 -04:00
parent 48dffdd97e
commit 075dd25792
7 changed files with 62 additions and 44 deletions
+8 -3
View File
@@ -17,8 +17,10 @@ import (
)
// Internal messages for clipboard operations.
type pasteMsg string
type pasteErrMsg struct{ error }
type (
pasteMsg string
pasteErrMsg struct{ error }
)
// EchoMode sets the input behavior of the text input field.
type EchoMode int
@@ -614,13 +616,16 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
m.previousSuggestion()
default:
// Input one or more regular characters.
m.insertRunesFromUserInput(msg.Runes)
m.insertRunesFromUserInput([]rune{msg.Rune})
}
// Check again if can be completed
// because value might be something that does not match the completion prefix
m.updateSuggestions()
case tea.PasteMsg:
m.insertRunesFromUserInput([]rune(msg))
case pasteMsg:
m.insertRunesFromUserInput([]rune(msg))