Removing the xclearborders() hack. St now cleans up the parts of the border,

if something needs to be drawn close to it.
master
Christoph Lohmann 12 years ago
parent 4eddf19fdc
commit 0cc7ee5e73
  1. 59
      st.c

59
st.c

@ -224,7 +224,9 @@ typedef struct {
int mode; int mode;
int bx, by; int bx, by;
int ex, ey; int ex, ey;
struct {int x, y;} b, e; struct {
int x, y;
} b, e;
char *clip; char *clip;
Atom xtarget; Atom xtarget;
bool alt; bool alt;
@ -587,10 +589,10 @@ selected(int x, int y) {
return BETWEEN(x, bx, ex); return BETWEEN(x, bx, ex);
} }
return ((sel.b.y < y&&y < sel.e.y) return ((sel.b.y < y && y < sel.e.y)
|| (y==sel.e.y && x<=sel.e.x)) || (y == sel.e.y && x <= sel.e.x))
|| (y==sel.b.y && x>=sel.b.x || (y == sel.b.y && x >= sel.b.x
&& (x<=sel.e.x || sel.b.y!=sel.e.y)); && (x <= sel.e.x || sel.b.y != sel.e.y));
} }
void void
@ -803,12 +805,12 @@ brelease(XEvent *e) {
/* double click to select word */ /* double click to select word */
sel.bx = sel.ex; sel.bx = sel.ex;
while(sel.bx > 0 && term.line[sel.ey][sel.bx-1].state & GLYPH_SET && while(sel.bx > 0 && term.line[sel.ey][sel.bx-1].state & GLYPH_SET &&
term.line[sel.ey][sel.bx-1].c[0] != ' ') { term.line[sel.ey][sel.bx-1].c[0] != ' ') {
sel.bx--; sel.bx--;
} }
sel.b.x = sel.bx; sel.b.x = sel.bx;
while(sel.ex < term.col-1 && term.line[sel.ey][sel.ex+1].state & GLYPH_SET && while(sel.ex < term.col-1 && term.line[sel.ey][sel.ex+1].state & GLYPH_SET &&
term.line[sel.ey][sel.ex+1].c[0] != ' ') { term.line[sel.ey][sel.ex+1].c[0] != ' ') {
sel.ex++; sel.ex++;
} }
sel.e.x = sel.ex; sel.e.x = sel.ex;
@ -1031,7 +1033,8 @@ treset(void) {
memset(term.tabs, 0, term.col * sizeof(*term.tabs)); memset(term.tabs, 0, term.col * sizeof(*term.tabs));
for(i = TAB; i < term.col; i += TAB) for(i = TAB; i < term.col; i += TAB)
term.tabs[i] = 1; term.tabs[i] = 1;
term.top = 0, term.bot = term.row - 1; term.top = 0;
term.bot = term.row - 1;
term.mode = MODE_WRAP; term.mode = MODE_WRAP;
tclearregion(0, 0, term.col-1, term.row-1); tclearregion(0, 0, term.col-1, term.row-1);
@ -1040,7 +1043,8 @@ treset(void) {
void void
tnew(int col, int row) { tnew(int col, int row) {
/* set screen size */ /* set screen size */
term.row = row, term.col = col; term.row = row;
term.col = col;
term.line = xmalloc(term.row * sizeof(Line)); term.line = xmalloc(term.row * sizeof(Line));
term.alt = xmalloc(term.row * sizeof(Line)); term.alt = xmalloc(term.row * sizeof(Line));
term.dirty = xmalloc(term.row * sizeof(*term.dirty)); term.dirty = xmalloc(term.row * sizeof(*term.dirty));
@ -1437,8 +1441,8 @@ tsetmode(bool priv, bool set, int *args, int narg) {
if(IS_SET(MODE_ALTSCREEN)) if(IS_SET(MODE_ALTSCREEN))
tclearregion(0, 0, term.col-1, term.row-1); tclearregion(0, 0, term.col-1, term.row-1);
if((set && !IS_SET(MODE_ALTSCREEN)) || if((set && !IS_SET(MODE_ALTSCREEN)) ||
(!set && IS_SET(MODE_ALTSCREEN))) { (!set && IS_SET(MODE_ALTSCREEN))) {
tswapscreen(); tswapscreen();
} }
if(*args != 1049) if(*args != 1049)
break; break;
@ -1909,7 +1913,6 @@ tputc(char *c, int len) {
case 'c': /* RIS -- Reset to inital state */ case 'c': /* RIS -- Reset to inital state */
treset(); treset();
term.esc = 0; term.esc = 0;
xclearborders();
xresettitle(); xresettitle();
break; break;
case '=': /* DECPAM -- Application keypad */ case '=': /* DECPAM -- Application keypad */
@ -2090,18 +2093,6 @@ xclear(int x1, int y1, int x2, int y2) {
x1, y1, x2-x1, y2-y1); x1, y1, x2-x1, y2-y1);
} }
void
xclearborders(void) {
/* top and left border */
xclear(0, 0, BORDER, xw.h);
xclear(0, 0, xw.w, BORDER);
/* lower and right border */
xclear(BORDER, xw.th - 1, xw.w, xw.h);
/* Will just draw what hasn't been drawn by the previous call. */
xclear(xw.tw - 1, BORDER, xw.w, xw.h - xw.th - 2);
}
void void
xhints(void) { xhints(void) {
XClassHint class = {opt_class ? opt_class : TNAME, TNAME}; XClassHint class = {opt_class ? opt_class : TNAME, TNAME};
@ -2264,8 +2255,8 @@ xinit(void) {
void void
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
int winx = BORDER+x*xw.cw, winy = BORDER+y*xw.ch, int winx = BORDER + x * xw.cw, winy = BORDER + y * xw.ch,
width = charlen*xw.cw; width = charlen * xw.cw;
Font *font = &dc.font; Font *font = &dc.font;
XGlyphInfo extents; XGlyphInfo extents;
XftColor *fg = &dc.xft_col[base.fg], *bg = &dc.xft_col[base.bg], XftColor *fg = &dc.xft_col[base.fg], *bg = &dc.xft_col[base.bg],
@ -2328,6 +2319,20 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
&extents); &extents);
width = extents.xOff; width = extents.xOff;
/* Intelligent cleaning up of the borders. */
if(x == 0) {
xclear(0, (y == 0)? 0 : winy, BORDER,
winy + xw.ch + (y == term.row-1)? xw.h : 0);
}
if(x + charlen >= term.col-1) {
xclear(winx + width, (y == 0)? 0 : winy, xw.w,
winy + xw.ch + (y == term.row-1)? xw.h : 0);
}
if(y == 0)
xclear(winx, 0, winx + width, BORDER);
if(y == term.row-1)
xclear(winx, winy + xw.ch, winx + width, xw.h);
XftDrawRect(xw.xft_draw, bg, winx, winy, width, xw.ch); XftDrawRect(xw.xft_draw, bg, winx, winy, width, xw.ch);
XftDrawStringUtf8(xw.xft_draw, fg, font->xft_set, winx, XftDrawStringUtf8(xw.xft_draw, fg, font->xft_set, winx,
winy + font->ascent, (FcChar8 *)s, bytelen); winy + font->ascent, (FcChar8 *)s, bytelen);
@ -2382,7 +2387,6 @@ void
redraw(void) { redraw(void) {
struct timespec tv = {0, REDRAW_TIMEOUT * 1000}; struct timespec tv = {0, REDRAW_TIMEOUT * 1000};
xclearborders();
tfulldirt(); tfulldirt();
draw(); draw();
XSync(xw.dpy, False); /* necessary for a good tput flash */ XSync(xw.dpy, False); /* necessary for a good tput flash */
@ -2598,7 +2602,6 @@ resize(XEvent *e) {
tresize(col, row); tresize(col, row);
xresize(col, row); xresize(col, row);
xclearborders();
ttyresize(); ttyresize();
} }

Loading…
Cancel
Save