ref: bac0b034810bdb5bfda0cdc45235c7c567ae0575
parent: 8b811edf951fddc747cc9596b43ea009d92b9ad7
author: cancel <cancel@cancel.fm>
date: Tue Dec 31 23:55:10 EST 2019
Add auto-display of operators guide at startup This needs work. It seems pretty annoying to me right now. This commit also adds a way for Qmsg to differentiate between dismiss-easily and dismiss-deliberately types of msg dialogs.
--- a/term_util.c
+++ b/term_util.c
@@ -66,6 +66,7 @@
struct Qmsg {
Qblock qblock;
+ Qmsg_dismiss_type dismiss_type;
};
struct Qmenu {
@@ -206,9 +207,10 @@
qblock_set_title(&qm->qblock, title);
}
-Qmsg* qmsg_push(int height, int width) {
+Qmsg* qmsg_push(int height, int width, Qmsg_dismiss_type dismiss_type) {
Qmsg* qm = malloc(sizeof(Qmsg));
qblock_init(&qm->qblock, Qblock_type_qmsg);
+ qm->dismiss_type = dismiss_type;
qnav_stack_push(&qm->qblock, height, width);
return qm;
}
@@ -220,6 +222,11 @@
case 27:
case '\r':
case KEY_ENTER:
+ return true;
+ }
+ // TODO do we need some smarter filter here? What kinds of control codes do
+ // we need to ignore so that we only dismiss on keyboard events?
+ if (qm->dismiss_type == Qmsg_dismiss_easily) {
return true;
}
return false;
--- a/term_util.h
+++ b/term_util.h
@@ -74,6 +74,11 @@
typedef struct Qmsg Qmsg;
+typedef enum {
+ Qmsg_dismiss_easily,
+ Qmsg_dismiss_deliberately,
+} Qmsg_dismiss_type;
+
typedef struct Qmenu Qmenu;
typedef enum {
@@ -116,7 +121,7 @@
void qblock_print_frame(Qblock* qb, bool active);
void qblock_set_title(Qblock* qb, char const* title);
-Qmsg* qmsg_push(int height, int width);
+Qmsg* qmsg_push(int height, int width, Qmsg_dismiss_type dismiss_type);
WINDOW* qmsg_window(Qmsg* qm);
void qmsg_set_title(Qmsg* qm, char const* title);
bool qmsg_drive(Qmsg* qm, int key);
--- a/tui_main.c
+++ b/tui_main.c
@@ -1779,7 +1779,8 @@
width += hpad * 2;
int logo_left_pad = (width - cols) / 2;
int footer_left_pad = (width - footer_len) / 2;
- Qmsg* qm = qmsg_push(tpad + rows + sep + 1 + bpad, width);
+ Qmsg* qm =
+ qmsg_push(tpad + rows + sep + 1 + bpad, width, Qmsg_dismiss_deliberately);
WINDOW* w = qmsg_window(qm);
for (int row = 0; row < rows; ++row) {
wmove(w, row + tpad, logo_left_pad);
@@ -1850,7 +1851,8 @@
}
int mid_pad = 2;
int total_width = 1 + w_input + mid_pad + w_desc;
- Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
+ Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width,
+ Qmsg_dismiss_deliberately);
qmsg_set_title(qm, "Controls");
WINDOW* w = qmsg_window(qm);
for (int i = 0; i < (int)ORCA_ARRAY_COUNTOF(items); ++i) {
@@ -1865,7 +1867,7 @@
}
}
-void push_opers_guide_msg(void) {
+void push_opers_guide_msg(Qmsg_dismiss_type dismiss_type) {
struct Guide_item {
char glyph;
char const* name;
@@ -1919,7 +1921,7 @@
int left_pad = 1;
int mid_pad = 1;
int total_width = left_pad + 1 + mid_pad + w_desc;
- Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
+ Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width, dismiss_type);
qmsg_set_title(qm, "Operators");
WINDOW* w = qmsg_window(qm);
for (int i = 0; i < (int)ORCA_ARRAY_COUNTOF(items); ++i) {
@@ -1936,7 +1938,7 @@
if (!ged->filename)
return;
bool ok = hacky_try_save(&ged->field, ged->filename);
- Qmsg* msg = qmsg_push(3, 50);
+ Qmsg* msg = qmsg_push(3, 50, Qmsg_dismiss_deliberately);
WINDOW* msgw = qmsg_window(msg);
wmove(msgw, 0, 1);
if (ok) {
@@ -2254,6 +2256,8 @@
// Send initial BPM
send_num_message(ged_state.oosc_dev, "/orca/bpm", (I32)ged_state.bpm);
+ push_opers_guide_msg(Qmsg_dismiss_easily); // I don't know about this
+
for (;;) {
switch (key) {
case ERR: {
@@ -2426,7 +2430,7 @@
push_controls_msg();
break;
case Main_menu_opers_guide:
- push_opers_guide_msg();
+ push_opers_guide_msg(Qmsg_dismiss_deliberately);
break;
case Main_menu_about:
push_about_msg();
@@ -2638,7 +2642,7 @@
push_controls_msg();
break;
case CTRL_PLUS('g'):
- push_opers_guide_msg();
+ push_opers_guide_msg(Qmsg_dismiss_deliberately);
break;
case CTRL_PLUS('s'):
try_save_with_msg(&ged_state);