X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=4bf637887cbb40392afbf06ae28c074d1349391d;hb=a5dc1b46976b2252f9d7bb68f126c4b0f351dd1a;hp=3ebf8c6947e69086dfb51541600d5320f8ce7466;hpb=33201ac65f74e45b4fa60822ba9a538c3cfa9b25;p=st.git diff --git a/st.c b/st.c index 3ebf8c6..4bf6378 100644 --- a/st.c +++ b/st.c @@ -42,6 +42,7 @@ #define STR_ARG_SIZ ESC_ARG_SIZ /* macros */ +#define IS_SET(flag) ((term.mode & (flag)) != 0) #define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) #define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) @@ -51,6 +52,17 @@ /* constants */ #define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: ': /* DECPNM -- Normal keypad */ - term.mode &= ~MODE_APPKEYPAD; + xsetmode(0, MODE_APPKEYPAD); break; case '7': /* DECSC -- Save Cursor */ tcursor(CURSOR_SAVE); @@ -2521,14 +2529,44 @@ resettitle(void) } void -redraw(void) +drawregion(int x1, int y1, int x2, int y2) { - tfulldirt(); - draw(); + int y; + for (y = y1; y < y2; y++) { + if (!term.dirty[y]) + continue; + + term.dirty[y] = 0; + xdrawline(term.line[y], x1, y, x2); + } } void -numlock(const Arg *dummy) +draw(void) { - term.numlock ^= 1; + int cx = term.c.x; + + if (!xstartdraw()) + return; + + /* adjust cursor position */ + LIMIT(term.ocx, 0, term.col-1); + LIMIT(term.ocy, 0, term.row-1); + if (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY) + term.ocx--; + if (term.line[term.c.y][cx].mode & ATTR_WDUMMY) + cx--; + + drawregion(0, 0, term.col, term.row); + xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], + term.ocx, term.ocy, term.line[term.ocy][term.ocx]); + term.ocx = cx, term.ocy = term.c.y; + xfinishdraw(); +} + +void +redraw(void) +{ + tfulldirt(); + draw(); }