refactor #23

Merged
bagas merged 3 commits from refactor into staging 2025-12-05 15:28:49 +00:00
7 changed files with 44 additions and 83 deletions
Showing only changes of commit 990bccbff7 - Show all commits

View File

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