diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-03-18 07:42:06 -0700 |
---|---|---|
committer | Kent Overstreet <koverstreet@google.com> | 2013-04-23 16:37:36 -0700 |
commit | 3ea07dd3b8ded95c4a66ec2866f08df33888f0df (patch) | |
tree | 826824757847ff671081b18b643cdd164a81744c | |
parent | 4056c980881d2c5aa456eed6cb7a775b1ba8a237 (diff) |
better cursor drawing
-rw-r--r-- | st.c | 42 | ||||
-rw-r--r-- | term.c | 4 | ||||
-rw-r--r-- | term.h | 1 |
3 files changed, 17 insertions, 30 deletions
@@ -536,40 +536,24 @@ retry: static void xdrawcursor(struct st_window *xw) { - struct st_glyph g, *p; + struct st_glyph g; - g.c = ' '; + if (xw->term.hide) + return; + + g.c = term_pos(&xw->term, xw->term.c.pos)->c; g.cmp = 0; - g.bg = defaultcs; g.fg = defaultbg; + g.bg = xw->focused ? defaultcs : defaultucs; - xw->term.oldcursor.x = min(xw->term.oldcursor.x, xw->term.size.x - 1); - xw->term.oldcursor.y = min(xw->term.oldcursor.y, xw->term.size.y - 1); - - p = term_pos(&xw->term, xw->term.c.pos); - - g.c = p->c; - - /* remove the old cursor */ - xdraw_glyphs(xw, xw->term.oldcursor, - *term_pos(&xw->term, xw->term.oldcursor), - term_pos(&xw->term, xw->term.oldcursor), 1); - - /* draw the new one */ - if (!xw->term.hide) { - if (!xw->focused) - g.bg = defaultucs; - - g.reverse = xw->term.reverse; - if (g.reverse) { - unsigned t = g.fg; - g.fg = g.bg; - g.bg = t; - } - - xdraw_glyphs(xw, xw->term.c.pos, g, &g, 1); - xw->term.oldcursor = xw->term.c.pos; + g.reverse = xw->term.reverse; + if (g.reverse) { + unsigned t = g.fg; + g.fg = g.bg; + g.bg = t; } + + xdraw_glyphs(xw, xw->term.c.pos, g, &g, 1); } static struct st_glyph sel_glyph(struct st_window *xw, unsigned x, unsigned y) @@ -307,6 +307,8 @@ static void tmovex(struct st_term *term, unsigned x) static void tmovey(struct st_term *term, unsigned y) { + term->dirty[term->c.pos.y] = 1; + term->c.wrapnext = 0; term->c.pos.y = term->c.origin ? clamp(y, term->top, term->bot) @@ -330,6 +332,8 @@ static void tmoveato(struct st_term *term, struct coord pos) static void tmoverel(struct st_term *term, int x, int y) { + term->dirty[term->c.pos.y] = 1; + term->c.pos.x = clamp_t(int, term->c.pos.x + x, 0, term->size.x - 1); term->c.pos.y = clamp_t(int, term->c.pos.y + y, 0, term->size.y - 1); @@ -160,7 +160,6 @@ struct st_term { struct tcursor c; /* cursor */ struct tcursor saved; - struct coord oldcursor; struct st_selection sel; unsigned top; /* top scroll limit */ unsigned bot; /* bottom scroll limit */ |