diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-06 12:41:14 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-06 12:41:14 -0700 |
commit | 2964a5e74aaf09c0299d38fe756cbc91c018fd99 (patch) | |
tree | b30f1c4a2a379d1588707c409266919f1e924b3f | |
parent | 9b99cd2a5609150726b484cd69b14c662e095e8d (diff) | |
download | teliva-2964a5e74aaf09c0299d38fe756cbc91c018fd99.tar.gz |
refactor menu drawing
-rw-r--r-- | src/lcurseslib.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/lcurseslib.c b/src/lcurseslib.c index 90755c3..ff9e235 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -19,19 +19,30 @@ static void cleanup(void) { } +int menu_column = 0; +void draw_string_on_menu(const char* s) { + mvaddstr(LINES-1, menu_column, " "); + ++menu_column; + mvaddstr(LINES-1, menu_column, s); + menu_column += strlen(s); + mvaddstr(LINES-1, menu_column, " "); + ++menu_column; +} +void draw_menu_item(const char* key, const char* name) { + attroff(A_REVERSE); + draw_string_on_menu(key); + attron(A_REVERSE); + draw_string_on_menu(name); + attroff(A_REVERSE); +} + void draw_menu (void) { attron(A_BOLD|A_REVERSE); for (int x = 0; x < COLS; ++x) mvaddch(LINES-1, x, ' '); - attroff(A_REVERSE); - mvaddstr(LINES-1, 2, " ^x "); - attron(A_REVERSE); - mvaddstr(LINES-1, 6, " exit "); - attroff(A_REVERSE); - mvaddstr(LINES-1, 12, " ^e "); - attron(A_REVERSE); - mvaddstr(LINES-1, 16, " edit "); - attroff(A_BOLD|A_REVERSE); + menu_column = 2; + draw_menu_item("^x", "exit"); + draw_menu_item("^e", "edit"); } |