]> git.lizzy.rs Git - linenoise.git/commitdiff
CHA is 1-based
authorMathias Stearn <redbeard0531@gmail.com>
Mon, 11 Apr 2011 23:34:19 +0000 (19:34 -0400)
committerSteve Bennett <steveb@workware.net.au>
Tue, 12 Apr 2011 23:21:55 +0000 (09:21 +1000)
linenoise.c

index 19dbdfe9b81712d186a39edb8cc62aa8bd083bf6..63a75123355cb429bc306a976f79491fbc202998 100644 (file)
@@ -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)