Skip to contentSkip to conversation

client: ignore control sequence length in prompt

PATCH Applied Ronan Pigott 2 participants 2 messages Dec 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: ignore control sequence length in prompt

From: Ronan Pigott <[email protected]>

Readline uses the characters \001 and \002 to mark the start and end of zero-length character sequnces in the prompt before prompt expansion. Without these characters the input point can become offset from the visual end of the prompt when performing some actions.
---

iwctl gets messed up if you press up and down once to recall and then dismiss the last history line. This fixes that.

 client/display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
client/display.c +2 -1
index b19759ea..88bc913f 100644
@@ -39,7 +39,8 @@
 #include "client/command.h"
 #include "client/display.h"
 
-#define IWD_PROMPT COLOR_GREEN "[iwd]" COLOR_OFF "# "
+#define IWD_PROMPT \
+	"\001" COLOR_GREEN "\002" "[iwd]" "\001" COLOR_OFF "\002" "# "
 #define LINE_LEN 81
 
 static struct l_signal *window_change_signal;
Signature · 1 line
2.29.2
#1 lore raw

Hi Ronan,

Quoted 10 lines · Ronan Pigott

From: Ronan Pigott <[email protected]>

Readline uses the characters \001 and \002 to mark the start and end of zero-length character sequnces in the prompt before prompt expansion. Without these characters the input point can become offset from the visual end of the prompt when performing some actions.
---

iwctl gets messed up if you press up and down once to recall and then dismiss the last history line. This fixes that.

Interesting. I have never observed this behavior and I do this often.

Quoted 4 lines
  client/display.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis