diff options
| author | WormHeamer | 2025-12-28 19:37:00 -0500 |
|---|---|---|
| committer | WormHeamer | 2025-12-28 19:37:00 -0500 |
| commit | 4d8eb0a7c13a69afe30f6a251ff0d72281650f77 (patch) | |
| tree | 21920ff54741988ee25171c42f1d53b1269c0fff | |
| parent | aaa7aa0632040d1be3b16e4a0680e92035c40e12 (diff) | |
different cursor shape in insert vs normal mode
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | vui.c | 8 | ||||
| -rw-r--r-- | vui.h | 11 |
3 files changed, 19 insertions, 1 deletions
@@ -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) { @@ -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; @@ -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); |
