mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
Merge a5aa483f9b
into d87922c0eb
This commit is contained in:
commit
2ae45c901a
2 changed files with 61 additions and 3 deletions
|
@ -33,6 +33,45 @@ const (
|
|||
maxLines = 10000
|
||||
)
|
||||
|
||||
func keypadToChar(keyString string) string {
|
||||
switch keyString {
|
||||
case "kp0":
|
||||
return "0"
|
||||
case "kp1":
|
||||
return "1"
|
||||
case "kp2":
|
||||
return "2"
|
||||
case "kp3":
|
||||
return "3"
|
||||
case "kp4":
|
||||
return "4"
|
||||
case "kp5":
|
||||
return "5"
|
||||
case "kp6":
|
||||
return "6"
|
||||
case "kp7":
|
||||
return "7"
|
||||
case "kp8":
|
||||
return "8"
|
||||
case "kp9":
|
||||
return "9"
|
||||
case "kpplus":
|
||||
return "+"
|
||||
case "kpminus":
|
||||
return "-"
|
||||
case "kpmul":
|
||||
return "*"
|
||||
case "kpdiv":
|
||||
return "/"
|
||||
case "kpperiod":
|
||||
return "."
|
||||
case "kpequal":
|
||||
return "="
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// Attachment represents a special object within the text, distinct from regular characters.
|
||||
type Attachment struct {
|
||||
ID string // A unique identifier for this attachment instance
|
||||
|
@ -1512,7 +1551,14 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
|||
m.transposeLeft()
|
||||
|
||||
default:
|
||||
m.insertRunesFromUserInput([]rune(msg.Text))
|
||||
// Handle keypad keys by converting them to their character equivalents
|
||||
if msg.Text == "" {
|
||||
if char := keypadToChar(msg.String()); char != "" {
|
||||
m.insertRunesFromUserInput([]rune(char))
|
||||
}
|
||||
} else {
|
||||
m.insertRunesFromUserInput([]rune(msg.Text))
|
||||
}
|
||||
}
|
||||
|
||||
case pasteMsg:
|
||||
|
|
|
@ -130,6 +130,18 @@ func isScrollRelatedInput(keyString string) bool {
|
|||
return len(keyString) > 1
|
||||
}
|
||||
|
||||
func isKeypadKey(keyString string) bool {
|
||||
switch keyString {
|
||||
case "kp0", "kp1", "kp2", "kp3", "kp4",
|
||||
"kp5", "kp6", "kp7", "kp8", "kp9",
|
||||
"kpplus", "kpminus", "kpmul", "kpdiv",
|
||||
"kpperiod", "kpenter", "kpequal":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmd tea.Cmd
|
||||
var cmds []tea.Cmd
|
||||
|
@ -236,8 +248,8 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
return a, tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
// 4. Maximize editor responsiveness for printable characters
|
||||
if msg.Text != "" {
|
||||
// 4. Maximize editor responsiveness for printable characters and keypad keys
|
||||
if msg.Text != "" || isKeypadKey(keyString) {
|
||||
updated, cmd := a.editor.Update(msg)
|
||||
a.editor = updated.(chat.EditorComponent)
|
||||
cmds = append(cmds, cmd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue