X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=8074df97285b76152bf02c02597ca2b129665286;hb=082bab29f3551e5cee332832ff767c3fb65a5cbc;hp=fc64a779d35346b6394fa8df332230b388318166;hpb=78215c8ee0f4cb62655730260520f185ce97c620;p=st.git diff --git a/st.c b/st.c index fc64a77..8074df9 100644 --- a/st.c +++ b/st.c @@ -2248,7 +2248,7 @@ xtermclear(int col1, int row1, int col2, int row2) { void xclear(int x1, int y1, int x2, int y2) { XftDrawRect(xw.draw, - &dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg], + &dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg], x1, y1, x2-x1, y2-y1); } @@ -2431,9 +2431,13 @@ xinit(void) { /* input methods */ xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL); + if(xw.xim == NULL) + die("XOpenIM failed. Could not open input device.\n"); xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); + if(xw.xic == NULL) + die("XCreateIC failed. Could not obtain input method.\n"); /* white cursor, black outline */ cursor = XCreateFontCursor(xw.dpy, XC_xterm); @@ -2511,8 +2515,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { } } - if(base.mode & ATTR_REVERSE) - temp = fg, fg = bg, bg = temp; + if(base.mode & ATTR_REVERSE) { + temp = fg; + fg = bg; + bg = temp; + } XftTextExtentsUtf8(xw.dpy, font->set, (FcChar8 *)s, bytelen, &extents); @@ -2521,11 +2528,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { /* Intelligent cleaning up of the borders. */ if(x == 0) { xclear(0, (y == 0)? 0 : winy, borderpx, - winy + xw.ch + (y == term.row-1)? xw.h : 0); + winy + xw.ch + ((y >= term.row-1)? xw.h : 0)); } - if(x + charlen >= term.col-1) { + if(x + charlen >= term.col) { xclear(winx + width, (y == 0)? 0 : winy, xw.w, - (y == term.row-1)? xw.h : (winy + xw.ch)); + ((y >= term.row-1)? xw.h : (winy + xw.ch))); } if(y == 0) xclear(winx, 0, winx + width, borderpx); @@ -2724,7 +2731,7 @@ kmap(KeySym k, uint state) { break; } if(i == LEN(mappedkeys)) { - if((k & 0xFFFF) < 0xFF00) + if((k & 0xFFFF) < 0xFD00) return NULL; } @@ -2742,12 +2749,13 @@ kmap(KeySym k, uint state) { continue; if(term.numlock && kp->appkey == 2) continue; - } else if (kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) { + } else if(kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) { continue; } if((kp->appcursor < 0 && IS_SET(MODE_APPCURSOR)) || - (kp->appcursor > 0 && !IS_SET(MODE_APPCURSOR))) { + (kp->appcursor > 0 + && !IS_SET(MODE_APPCURSOR))) { continue; }