iomenu

interactive text selection menu
Log | Files | Refs | README | LICENSE

commit a393b370908b21080348141ea591395502f4a36e
parent 63ce568f63eef334f256370d444e557d2ecceb68
Author: Josuah Demangeonā  ā µ <mail@josuah.net>
Date:   Sat, 18 Mar 2017 19:42:46 +0100

scrolling working on line mode

Diffstat:
Miomenu.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/iomenu.c b/iomenu.c @@ -18,7 +18,8 @@ char input[BUFSIZ]; -size_t current = 0, matchc = 0, linec = 0, offset = 0; +size_t current = 0, offset = 0, last = 0; +size_t linec = 0, matchc = 0; char **linev = NULL, **matchv = NULL; char *opt_prompt = ""; int opt_lines = 0; @@ -166,14 +167,15 @@ print_string(char *str, size_t limit, int current) void print_lines(size_t count, size_t cols) { - size_t printed = 0, i = current / count * count; + size_t p = 0; /* amount of lines printed */ + offset = current / count * count; - for (; printed < count && i < matchc; printed++, i++) { + for (size_t i = offset; p < count && i < matchc; p++, i++) { fputc('\n', stderr); print_string(matchv[i], cols, i == current); } - while (printed++ <= count) + while (p++ <= count) fputs("\n\033[K", stderr); }