summaryrefslogtreecommitdiffhomepage
path: root/tui/tui.h
diff options
context:
space:
mode:
Diffstat (limited to 'tui/tui.h')
-rw-r--r--tui/tui.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/tui/tui.h b/tui/tui.h
index 9046620..90d569b 100644
--- a/tui/tui.h
+++ b/tui/tui.h
@@ -66,11 +66,19 @@ enum {
TUI_KEY_RESIZE,
TUI_KEY_TAB,
TUI_KEY_BACKTAB,
+ TUI_KEY_MOUSE,
};
#define TUI_MAX_W 500
#define TUI_MAX_H 200
+/** @brief One mouse event; coordinates are 0-based cells. */
+struct tui_mouse {
+ int x, y;
+ int button; /**< 0 left, 1 middle, 2 right, 64 wheel up, 65 wheel down */
+ bool release;
+};
+
struct tui {
int w, h;
int fd_in, fd_out;
@@ -83,6 +91,7 @@ struct tui {
int inlen;
char out[32768];
int olen;
+ struct tui_mouse mouse;
};
bool tui_alloc(struct tui *t, int w, int h);
@@ -109,12 +118,13 @@ int tui_key(struct tui *t, int timeout_ms);
/* ---- messages and the application loop ------------------------------- */
-enum tui_msg_type { TUI_MSG_KEY, TUI_MSG_RESIZE, TUI_MSG_TICK };
+enum tui_msg_type { TUI_MSG_KEY, TUI_MSG_RESIZE, TUI_MSG_TICK, TUI_MSG_MOUSE };
struct tui_msg {
enum tui_msg_type type;
- int key; /**< TUI_MSG_KEY: a byte or one of TUI_KEY_* */
- int w, h; /**< TUI_MSG_RESIZE: the new size */
+ int key; /**< TUI_MSG_KEY: a byte or one of TUI_KEY_* */
+ int w, h; /**< TUI_MSG_RESIZE: the new size */
+ struct tui_mouse mouse; /**< TUI_MSG_MOUSE */
};
struct tui_app {
@@ -173,6 +183,9 @@ bool tui_table_key(struct tui_table *tb, int key, int rows, int height);
int tui_tabs_draw(struct tui *t, int x, int y, const char *const *labels, int n,
int active);
+/** @brief Which tab covers cell @p x, or -1. Tabs start at column 0. */
+int tui_tabs_hit(int x, const char *const *labels, int n);
+
/** Cycle tabs with left/right/tab/backtab; true when it was consumed. */
bool tui_tabs_key(int key, int *active, int n);