alot of renaming...
[k8sterm.git] / src / x11drawcur.c
blobb984370249245c28c2f857bc6973d91c23628c3c
1 static void k8t_DrawCursor (K8Term *term) {
2 K8TGlyph g;
3 int sl, scrx, scry, cmy;
4 //
5 if (term == NULL) return;
6 //
7 K8T_LIMIT(term->oldcx, 0, term->col-1);
8 K8T_LIMIT(term->oldcy, 0, term->row-1);
9 //
10 cmy = term->row-term->topline-1;
12 if (!(xw.state&K8T_WIN_FOCUSED) && !term->curblinkinactive) term->curbhidden = 0;
14 if (term->cmdline.cmdMode == K8T_CMDMODE_NONE || term->oldcy != cmy) {
15 scrx = term->oldcx;
16 scry = term->oldcy+term->topline;
17 if (scry >= 0 && scry < term->row) {
18 if (term->curbhidden < 0 ||
19 term->oldcy != term->c.y || term->oldcx != term->c.x ||
20 (term->c.state&K8T_CURSOR_HIDE) ||
21 !(xw.state&K8T_WIN_FOCUSED)) {
22 /* remove the old cursor */
23 sl = k8t_UTF8Size(term->line[term->oldcy][scrx].c);
24 g = term->line[term->oldcy][scrx];
25 if (k8t_isSelected(term, scrx, term->c.y)) g.attr ^= K8T_ATTR_REVERSE;
26 k8t_DrawString(term, g.c, &g, scrx, scry, 1, sl);
27 //k8t_DrawClear(term, scrx, term->oldcy, scrx, term->oldcy);
28 k8t_DrawCopy(term, scrx, scry, 1, 1);
30 if (term->curbhidden) term->curbhidden = 1;
34 if (term->cmdline.cmdMode != K8T_CMDMODE_NONE && term->oldcy == cmy) return;
35 if ((term->c.state&K8T_CURSOR_HIDE) != 0) return;
36 if (term->curbhidden) return;
37 /* k8t_Draw the new one */
38 scrx = term->c.x;
39 scry = term->c.y+term->topline;
40 if (scry >= 0 && scry < term->row) {
41 int nodraw = 0;
43 if (!(xw.state&K8T_WIN_FOCUSED)) {
44 if (defaultCursorInactiveBG < 0) {
45 XSetForeground(xw.dpy, dc.gc, getColor(defaultCursorBG));
46 XDrawRectangle(xw.dpy, term->picbuf, dc.gc, scrx*xw.cw, scry*xw.ch, xw.cw-1, xw.ch-1);
47 nodraw = 1;
48 } else {
49 g.bg = defaultCursorInactiveBG;
50 g.fg = defaultCursorInactiveFG;
52 } else {
53 g.fg = defaultCursorFG;
54 g.bg = defaultCursorBG;
56 if (!nodraw) {
57 g.uc = term->line[term->c.y][scrx].uc;
58 g.state = 0;
59 g.attr = K8T_ATTR_NULL;
60 if (K8T_ISSET(term, K8T_MODE_REVERSE)) g.attr |= K8T_ATTR_REVERSE;
61 sl = k8t_UTF8Size(g.c);
62 k8t_DrawString(term, g.c, &g, scrx, scry, 1, sl);
64 term->oldcx = scrx;
65 term->oldcy = term->c.y;
66 k8t_DrawCopy(term, scrx, scry, 1, 1);