summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c1
-rw-r--r--vui.c8
-rw-r--r--vui.h11
3 files changed, 19 insertions, 1 deletions
diff --git a/main.c b/main.c
index 92e2492..af9094a 100644
--- a/main.c
+++ b/main.c
@@ -321,6 +321,7 @@ int main(int argc, const char **argv) {
for (;;) {
scratch.beg = scratch.start;
draw(NULL);
+ vui_curs_shape(mode ? VUI_CURS_BAR : VUI_CURS_BLOCK);
vui_blit();
u32 c = vui_key();
switch (mode) {
diff --git a/vui.c b/vui.c
index f97ea71..8c4a58a 100644
--- a/vui.c
+++ b/vui.c
@@ -202,6 +202,11 @@ void vui_curs_pos(int x, int y) {
win.curs_y = y;
}
+void vui_curs_shape(VuiCursorShape sh) {
+ printf("\x1b[%d q", sh);
+ fflush(stdout);
+}
+
/* TODO: use something better than signal() */
/* does sigaction allow for a context pointer? */
static void on_resized(int signo) {
@@ -247,6 +252,7 @@ static inline int bchr_equiv(VuiBuffer *a, VuiBuffer *b, unsigned i) {
void vui_fini(void) {
vui_curs_vis(1);
+ vui_curs_shape(VUI_CURS_DEFAULT);
free_buf(&win.buf1);
free_buf(&win.buf2);
free(vui_out);
@@ -793,7 +799,7 @@ static VuiKey esc_key(u32 c) {
}
VuiKey vui_key(void) {
- int c = getk();
+ unsigned c = getk();
switch (c) {
case '\n':
return KEY_RET;
diff --git a/vui.h b/vui.h
index c8f7a50..1bf43a0 100644
--- a/vui.h
+++ b/vui.h
@@ -74,6 +74,16 @@ typedef enum {
A_REVERSE = 1 << 13,
} VuiAttr;
+typedef enum {
+ VUI_CURS_BLOCK_BLINK,
+ VUI_CURS_DEFAULT,
+ VUI_CURS_BLOCK,
+ VUI_CURS_UNDERLINE_BLINK,
+ VUI_CURS_UNDERLINE,
+ VUI_CURS_BAR_BLINK,
+ VUI_CURS_BAR,
+} VuiCursorShape;
+
#define ATTR_FG(a) ((a) & 0xf)
#define ATTR_BG(a) (((a)>>4) & 0xf)
#define ATTR_A(a) ((a) & ~0xff)
@@ -132,6 +142,7 @@ void vui_fill_rect(VuiChar c, VuiAttr a, int x0, int y0, int width, int height);
void vui_curs_vis(int vis);
void vui_curs_pos(int x, int y);
+void vui_curs_shape(VuiCursorShape sh);
void vui_redraw_fn(void (*fn)(void *ctx));
void vui_redraw_ctx(void *ctx);