summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2024-07-23 14:05:41 -0500
committer@syxhe <https://t.me/syxhe>2024-07-23 14:05:41 -0500
commit50f435fbc734faf6a870f0777cf3e8d3a9bd5c21 (patch)
tree06ff5dfd6c0555e175d7b13f3de587b7114d9630 /src/screen.c
parent72839bcfca470f3840697e2215edff02d3e42ab1 (diff)
Menu works now
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/screen.c b/src/screen.c
index 5ca2dc2..362a1a7 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -170,21 +170,34 @@ int main() {
170 //* Menu example (fuck menus got damn) 170 //* Menu example (fuck menus got damn)
171 ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; 171 ITEM *items[STATIC_ARRSIZE(menu_choices) + 1];
172 MENU *menu; 172 MENU *menu;
173 WINDOW *menuholder;
173 174
174 for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) 175 for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++)
175 items[i] = new_item(menu_choices[i], menu_choices[i]); 176 items[i] = new_item(menu_choices[i], NULL);
176 items[STATIC_ARRSIZE(menu_choices)] = NULL; 177 items[STATIC_ARRSIZE(menu_choices)] = NULL;
177 178
178 menu = new_menu(items); 179 menu = new_menu(items);
179 if(menu == NULL) 180 if(menu == NULL)
180 error(1, errno, "Could not create menu"); 181 error(1, errno, "Could not create menu");
181 182
182 // set_menu_format(menu, 3, col); 183 set_menu_format(menu, 1, col);
184 menu_opts_on(menu, O_ONEVALUE | O_IGNORECASE);
185 menu_opts_off(menu, O_SHOWDESC);
186
187 menuholder = newwin(1, col, row - 1, 0);
188 keypad(menuholder, TRUE);
189
190 int holder1 = -1, holder2 = -1;
191 getmaxyx(menuholder, holder1, holder2);
192 set_menu_win(menu, menuholder);
193 set_menu_sub(menu, derwin(menuholder, holder1, holder2, 0, 0));
194
195 set_menu_mark(menu, NULL);
183 post_menu(menu); 196 post_menu(menu);
184 refresh(); 197 wrefresh(menuholder);
185 198
186 int c; 199 int c;
187 while((c = getch()) != KEY_F(4)) { 200 while((c = wgetch(menuholder)) != KEY_F(4)) {
188 switch(c) { 201 switch(c) {
189 case KEY_DOWN: 202 case KEY_DOWN:
190 menu_driver(menu, REQ_DOWN_ITEM); 203 menu_driver(menu, REQ_DOWN_ITEM);
@@ -208,9 +221,11 @@ int main() {
208 } 221 }
209 222
210 223
224 // Clean up the menu
225 unpost_menu(menu);
226 free_menu(menu);
211 for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) 227 for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++)
212 free_item(items[i]); 228 free_item(items[i]);
213 free_menu(menu);
214 //*/ 229 //*/
215 230
216 endwin(); // Clean up curses 231 endwin(); // Clean up curses