update: handle message deletion properly

This commit is contained in:
2025-12-05 22:24:46 +07:00
parent 659f6c3ee7
commit 990bccbff7

View File

@ -44,6 +44,7 @@ type Forwarder interface {
} }
type Interaction struct { type Interaction struct {
InputLength int
CommandBuffer *bytes.Buffer CommandBuffer *bytes.Buffer
EditMode bool EditMode bool
EditSlug string EditSlug string
@ -96,13 +97,18 @@ func (i *Interaction) HandleUserInput() {
i.SendMessage(string(buf[:n])) i.SendMessage(string(buf[:n]))
if char == 8 || char == 127 { if char == 8 || char == 127 {
if i.InputLength > 0 {
//i.CommandBuffer.Truncate(i.CommandBuffer.Len() - 1)
i.SendMessage("\b \b")
}
if i.CommandBuffer.Len() > 0 { if i.CommandBuffer.Len() > 0 {
i.CommandBuffer.Truncate(i.CommandBuffer.Len() - 1) i.CommandBuffer.Truncate(i.CommandBuffer.Len() - 1)
i.SendMessage("\b \b")
} }
continue continue
} }
i.InputLength += n
if char == '/' { if char == '/' {
i.CommandBuffer.Reset() i.CommandBuffer.Reset()
i.CommandBuffer.WriteByte(char) i.CommandBuffer.WriteByte(char)
@ -111,6 +117,7 @@ func (i *Interaction) HandleUserInput() {
if i.CommandBuffer.Len() > 0 { if i.CommandBuffer.Len() > 0 {
if char == 13 { if char == 13 {
i.SendMessage("\033[K")
i.HandleCommand(i.CommandBuffer.String()) i.HandleCommand(i.CommandBuffer.String())
continue continue
} }