commit ecbcb2bbd312eba1c8dcd5194c253c2d1da448da
parent 2d13beded20b1db3647de8a233c1d5b2ae2b4053
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 10 Oct 2014 22:54:29 +0000
simplify line_cursor_move a bit
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sob.c b/sob.c
@@ -261,15 +261,14 @@ line_out(void)
static void
line_cursor_move(size_t newpos)
{
- size_t len, y = 0, x = newpos;
+ size_t x, y = 0;
- len = line_promptlen();
- x += len;
+ x = newpos + line_promptlen();
/* linewrap */
if(cols > 0 && x > (size_t)cols - 1) {
- x = x % cols;
- y = ((newpos + len) - x) / cols;
+ y = (x - (x % cols)) / cols;
+ x %= cols;
}
fprintf(outfp, "\x1b[%zu;%zuH", y + 1, x + 1);
fflush(outfp);