This commit is contained in:
Bruno Rybársky 2024-06-09 11:03:31 +02:00
parent bf471b4934
commit 2b34c71573

@ -20,11 +20,9 @@ func newInternalTerminalHandler(shellCharacter, welcomeMessage string, commandRe
}
}
func clearLine(w telnet.Writer) {
func clearLine(w telnet.Writer) error {
_, err := w.RawWrite([]byte{0x1B, 0x5B, 0x4B})
if err != nil {
return
}
return err
}
func (handler *internalTerminalHandler) ServeTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader) {
@ -75,7 +73,9 @@ func (handler *internalTerminalHandler) ServeTELNET(ctx telnet.Context, w telnet
clients[clientID].HistoryIndex++
}
lineBuffer = []byte(clients[clientID].History[clients[clientID].HistoryIndex])
clearLine(w)
if clearLine(w) != nil {
return
}
_, err := w.Write(lineBuffer)
if err != nil {
return
@ -87,7 +87,9 @@ func (handler *internalTerminalHandler) ServeTELNET(ctx telnet.Context, w telnet
clients[clientID].HistoryIndex--
}
lineBuffer = []byte(clients[clientID].History[clients[clientID].HistoryIndex])
clearLine(w)
if clearLine(w) != nil {
return
}
_, err := w.Write(lineBuffer)
if err != nil {
return