X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=538ed9a4c21695bf2be39bed9fa6e8c7f1f5beb1;hb=2f215654a4b27eb573fb6551d28bdf760e95ef58;hp=f7fecf85be8e8368afff571a3d11d74228d337bb;hpb=2b3c1219c863d9faa30ae58e5bf56d58ada0247d;p=st.git diff --git a/st.c b/st.c index f7fecf8..538ed9a 100644 --- a/st.c +++ b/st.c @@ -110,7 +110,8 @@ enum term_mode { MODE_MOUSEBTN = 32, MODE_MOUSEMOTION = 64, MODE_MOUSE = 32|64, - MODE_REVERSE = 128 + MODE_REVERSE = 128, + MODE_KBDLOCK = 256 }; enum escape_state { @@ -201,7 +202,7 @@ typedef struct { XftDraw *xft_draw; Visual *vis; int scr; - Bool isfixed; /* is fixed geometry? */ + bool isfixed; /* is fixed geometry? */ int fx, fy, fw, fh; /* fixed geometry */ int tw, th; /* tty width and height */ int w; /* window width */ @@ -292,7 +293,7 @@ static void tfulldirt(void); static void ttynew(void); static void ttyread(void); -static void ttyresize(int, int); +static void ttyresize(void); static void ttywrite(const char *, size_t); static void xdraws(char *, Glyph, int, int, int, int); @@ -899,7 +900,7 @@ ttywrite(const char *s, size_t n) { } void -ttyresize(int x, int y) { +ttyresize(void) { struct winsize w; w.ws_row = term.row; @@ -940,7 +941,7 @@ tcursor(int mode) { void treset(void) { - unsigned i; + uint i; term.c = (TCursor){{ .mode = ATTR_NULL, .fg = DefaultFG, @@ -952,6 +953,7 @@ treset(void) { term.tabs[i] = 1; term.top = 0, term.bot = term.row - 1; term.mode = MODE_WRAP; + xclear(0, 0, xw.w, xw.h); tclearregion(0, 0, term.col-1, term.row-1); } @@ -1327,6 +1329,9 @@ tsetmode(bool priv, bool set, int *args, int narg) { } } else { switch(*args) { + case 2: + MODBIT(term.mode, set, MODE_KBDLOCK); + break; case 4: MODBIT(term.mode, set, MODE_INSERT); break; @@ -1603,7 +1608,7 @@ strreset(void) { void tputtab(bool forward) { - unsigned x = term.c.x; + uint x = term.c.x; if(forward) { if(x == term.col) @@ -2256,6 +2261,8 @@ kpress(XEvent *ev) { int shift; Status status; + if (IS_SET(MODE_KBDLOCK)) + return; meta = e->state & Mod1Mask; shift = e->state & ShiftMask; len = XmbLookupString(xw.xic, e, buf, sizeof(buf), &ksym, &status); @@ -2326,7 +2333,7 @@ resize(XEvent *e) { xclear(0, 0, xw.w, xw.h); tresize(col, row); xresize(col, row); - ttyresize(col, row); + ttyresize(); } void @@ -2381,7 +2388,7 @@ run(void) { int main(int argc, char *argv[]) { int i, bitm, xr, yr; - unsigned int wr, hr; + uint wr, hr; xw.fw = xw.fh = xw.fx = xw.fy = 0; xw.isfixed = False; @@ -2433,9 +2440,9 @@ main(int argc, char *argv[]) { run: setlocale(LC_CTYPE, ""); + xinit(); tnew(80, 24); ttynew(); - xinit(); selinit(); run(); return 0;