diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-25 11:17:36 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-01 17:10:24 +0100 |
commit | bfa0029f3e734ce5fda6e96dc74ed4f4a96556f6 (patch) | |
tree | caecd3747ac536fce057c812f9f59e9c30659119 | |
parent | 0365e093104248439c6df595fcf38d102b2c2fb9 (diff) | |
download | messenger-cli-bfa0029f3e734ce5fda6e96dc74ed4f4a96556f6.tar.gz messenger-cli-bfa0029f3e734ce5fda6e96dc74ed4f4a96556f6.zip |
Added simple test menu
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/messenger_cli.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/messenger_cli.c b/src/messenger_cli.c index 97ab83d..558170f 100644 --- a/src/messenger_cli.c +++ b/src/messenger_cli.c | |||
@@ -49,8 +49,11 @@ run (void *cls, char* const* args, | |||
49 | getmaxyx(stdscr, my, mx); | 49 | getmaxyx(stdscr, my, mx); |
50 | 50 | ||
51 | WINDOW *win = newwin(15, 30, by + (my - by - 15) / 2, bx + (mx - bx - 30) / 2); | 51 | WINDOW *win = newwin(15, 30, by + (my - by - 15) / 2, bx + (mx - bx - 30) / 2); |
52 | 52 | keypad(win, TRUE); | |
53 | char c; | 53 | |
54 | int selected = 0; | ||
55 | |||
56 | int c; | ||
54 | do { | 57 | do { |
55 | getbegyx(stdscr, by, bx); | 58 | getbegyx(stdscr, by, bx); |
56 | getmaxyx(stdscr, my, mx); | 59 | getmaxyx(stdscr, my, mx); |
@@ -76,8 +79,20 @@ run (void *cls, char* const* args, | |||
76 | box(win, 0, 0); | 79 | box(win, 0, 0); |
77 | 80 | ||
78 | wmove(win, 1, 1); | 81 | wmove(win, 1, 1); |
79 | wprintw(win, "%d %d, %d %d", bx, by, mx, my); | 82 | wprintw(win, "%d %d, %d %d | %d %d", bx, by, mx, my, c, KEY_DOWN); |
83 | |||
84 | const int attrs_select = A_BOLD; | ||
80 | 85 | ||
86 | for (int i = 0; i < 5; i++) { | ||
87 | if (i == selected) wattron(win, attrs_select); | ||
88 | |||
89 | wmove(win, i+2, 1); | ||
90 | wprintw(win, "Option %d", i+1); | ||
91 | |||
92 | if (i == selected) wattroff(win, attrs_select); | ||
93 | } | ||
94 | |||
95 | wmove(win, 7, 1); | ||
81 | c = wgetch(win); | 96 | c = wgetch(win); |
82 | } | 97 | } |
83 | else | 98 | else |
@@ -85,6 +100,9 @@ run (void *cls, char* const* args, | |||
85 | c = getch(); | 100 | c = getch(); |
86 | } | 101 | } |
87 | 102 | ||
103 | if (KEY_UP == c) selected = (selected > 0? selected - 1 : 0); | ||
104 | else if (KEY_DOWN == c) selected = (selected < 4? selected + 1 : 4); | ||
105 | |||
88 | clear(); | 106 | clear(); |
89 | refresh(); | 107 | refresh(); |
90 | } while (c != 'q'); | 108 | } while (c != 'q'); |