ref: 05b552be69cd98d2ee718976f37a0e0d7da452b0
parent: 185d7449243457f5ad60346b702e2168da63a636
author: cancel <cancel@cancel.fm>
date: Thu Dec 13 17:55:54 EST 2018
Cleanup, add start of controls dialog
--- a/term_util.c
+++ b/term_util.c
@@ -113,7 +113,7 @@
Qmsg* qmsg_of(Qnav_block* qb) { return ORCA_CONTAINER_OF(qb, Qmsg, nav_block); }
void qmenu_start(Qmenu* qm) { memset(qm, 0, sizeof(Qmenu)); }
-void qmenu_add_text_item(Qmenu* qm, char const* text, int id) {
+void qmenu_add_choice(Qmenu* qm, char const* text, int id) {
ITEM* item = new_item(text, NULL);
set_item_userptr(item, (void*)(intptr_t)(id));
qm->ncurses_items[qm->items_count] = item;
--- a/term_util.h
+++ b/term_util.h
@@ -99,7 +99,7 @@
Qmsg* qmsg_of(Qnav_block* qb);
void qmenu_start(Qmenu* qm);
-void qmenu_add_text_item(Qmenu* qm, char const* text, int id);
+void qmenu_add_choice(Qmenu* qm, char const* text, int id);
void qmenu_add_spacer(Qmenu* qm);
void qmenu_push_to_nav(Qmenu* qm);
bool qmenu_drive(Qmenu* qm, int key, Qmenu_action* out_action);
--- a/tui_main.c
+++ b/tui_main.c
@@ -1439,9 +1439,10 @@
//
enum {
- Menu_id_quit = 1,
- Menu_id_save,
- Menu_id_save_as,
+ Main_menu_quit = 1,
+ Main_menu_controls,
+ Main_menu_save,
+ Main_menu_save_as,
};
struct {
@@ -1451,15 +1452,25 @@
void push_main_menu() {
Qmenu* qm = &g_main_menu.qmenu;
qmenu_start(qm);
- qmenu_add_text_item(qm, "Save", Menu_id_save);
- // qmenu_add_text_item(qm, "Save As...", Menu_id_save_as);
+ qmenu_add_choice(qm, "Save", Main_menu_save);
+ // qmenu_add_choice(qm, "Save As...", Main_menu_save_as);
qmenu_add_spacer(qm);
- qmenu_add_text_item(qm, "Quit", Menu_id_quit);
+ qmenu_add_choice(qm, "Controls", Main_menu_controls);
+ qmenu_add_spacer(qm);
+ qmenu_add_choice(qm, "Quit", Main_menu_quit);
qmenu_push_to_nav(qm);
qnav_draw_box(&qm->nav_block);
qnav_draw_title(&qm->nav_block, "ORCA");
}
+void push_controls_msg() {
+ Qmsg* qm = qmsg_push(30, 30);
+ WINDOW* w = qmsg_window(qm);
+ wmove(w, 0, 0);
+ wprintw(w, "ctrl+Q\tquit\n");
+ wprintw(w, "arrow keys\tmove cursor\n");
+}
+
void try_save_with_msg(Ged* ged) {
if (!ged->filename)
return;
@@ -1774,12 +1785,15 @@
case Qmenu_action_type_picked: {
if (qm == &g_main_menu.qmenu) {
switch (act.picked.id) {
- case Menu_id_quit:
+ case Main_menu_quit:
goto quit;
- case Menu_id_save: {
+ case Main_menu_controls:
+ push_controls_msg();
+ break;
+ case Main_menu_save: {
try_save_with_msg(&ged_state);
} break;
- case Menu_id_save_as: {
+ case Main_menu_save_as: {
Qmsg* msg = qmsg_push(3, 30);
WINDOW* msgw = qmsg_window(msg);
wmove(msgw, 0, 1);