From 424d5f3f7f491b1985e8a501e0a2f984a6c3f799 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Mon, 11 Apr 2011 19:34:19 -0400 Subject: [PATCH] CHA is 1-based --- linenoise.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linenoise.c b/linenoise.c index 19dbdfe..63a7512 100644 --- a/linenoise.c +++ b/linenoise.c @@ -58,7 +58,7 @@ * * CHA (Cursor Horizontal Absolute) * Sequence: ESC [ n G - * Effect: moves cursor to column n + * Effect: moves cursor to column n (1 based) * * EL (Erase Line) * Sequence: ESC [ n K @@ -304,7 +304,7 @@ static void refreshLine(const char *prompt, struct current *current) { } /* Cursor to left edge, then the prompt */ - fd_printf(current->fd, "\x1b[0G"); + fd_printf(current->fd, "\x1b[1G"); IGNORE_RC(write(current->fd, prompt, plen)); /* Now the current buffer content */ @@ -340,7 +340,7 @@ static void refreshLine(const char *prompt, struct current *current) { IGNORE_RC(write(current->fd, buf, b)); /* Erase to right, move cursor to original position */ - fd_printf(current->fd, "\x1b[0K" "\x1b[0G\x1b[%dC", pos + pchars + backup); + fd_printf(current->fd, "\x1b[0K" "\x1b[1G\x1b[%dC", pos + pchars + backup); } static void set_current(struct current *current, const char *str) -- 2.44.0