From 20fae8a8709773ccab90e1af8f9fd5b3e8f99ddc Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:07:27 -0400 Subject: [PATCH] fix: prompt refresh (closes #116) --- readline/codes.go | 6 +++--- readline/prompt.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/readline/codes.go b/readline/codes.go index 8787f07..680aa79 100644 --- a/readline/codes.go +++ b/readline/codes.go @@ -57,9 +57,9 @@ const ( seqPosSave = "\x1b[s" seqPosRestore = "\x1b[u" - seqClearLineAfer = "\x1b[0k" - seqClearLineBefore = "\x1b[1k" - seqClearLine = "\x1b[2k" + seqClearLineAfer = "\x1b[0K" + seqClearLineBefore = "\x1b[1K" + seqClearLine = "\x1b[2K" seqClearScreenBelow = "\x1b[0J" seqClearScreen = "\x1b[2J" // Clears screen fully seqCursorTopLeft = "\x1b[H" // Clears screen and places cursor on top-left diff --git a/readline/prompt.go b/readline/prompt.go index a19b56c..81738ac 100644 --- a/readline/prompt.go +++ b/readline/prompt.go @@ -11,6 +11,7 @@ import ( // It also calculates the runes in the string as well as any non-printable escape codes. func (rl *Instance) SetPrompt(s string) { rl.mainPrompt = s + rl.computePrompt() } // RefreshPromptLog - A simple function to print a string message (a log, or more broadly, @@ -68,7 +69,6 @@ func (rl *Instance) RefreshPromptLog(log string) (err error) { // RefreshPromptInPlace - Refreshes the prompt in the very same place he is. func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { - // We adjust cursor movement, depending on which mode we're currently in. // Prompt data intependent if !rl.modeTabCompletion { @@ -82,7 +82,7 @@ func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { // Update the prompt if a special has been passed. if prompt != "" { - rl.mainPrompt = prompt + rl.SetPrompt(prompt) } if rl.Multiline { @@ -137,7 +137,7 @@ func (rl *Instance) RefreshPromptCustom(prompt string, offset int, clearLine boo // Update the prompt if a special has been passed. if prompt != "" { - rl.mainPrompt = prompt + rl.SetPrompt(prompt) } // Add a new line if needed