simplify line_cursor_move a bit - sob - simple output bar
(HTM) git clone git://git.codemadness.org/sob
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit ecbcb2bbd312eba1c8dcd5194c253c2d1da448da
(DIR) parent 2d13beded20b1db3647de8a233c1d5b2ae2b4053
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 10 Oct 2014 22:54:29 +0000
simplify line_cursor_move a bit
Diffstat:
M sob.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
---
(DIR) 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);