X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=c4ff67c104d83cfdb22388c85f9dfd563478efeb;hb=784765ca35389a9579976d3e5ec9dc73de4bf4d9;hp=5703e964ab644596bd5ed6e44e04cf447a10a740;hpb=71b09ec4f172da9a89be2add54b5b94da8af3bea;p=st.git diff --git a/st.c b/st.c index 5703e96..c4ff67c 100644 --- a/st.c +++ b/st.c @@ -663,9 +663,9 @@ bpress(XEvent *e) { void selcopy(void) { - char *str, *ptr; + char *str, *ptr, *p; int x, y, bufsize, is_selected = 0, size; - Glyph *gp; + Glyph *gp, *last; if(sel.bx == -1) { str = NULL; @@ -675,15 +675,19 @@ selcopy(void) { /* append every set & selected glyph to the selection */ for(y = 0; y < term.row; y++) { - for(x = 0; x < term.col; x++) { - gp = &term.line[y][x]; + gp = &term.line[y][0]; + last = gp + term.col; - if(!(is_selected = selected(x, y)) - || !(gp->state & GLYPH_SET)) { + while(--last >= gp && !(last->state & GLYPH_SET)) + /* nothing */; + + for(x = 0; gp <= last; x++, ++gp) { + if(!(is_selected = selected(x, y))) continue; - } - size = utf8size(gp->c); - memcpy(ptr, gp->c, size); + + p = (gp->state & GLYPH_SET) ? gp->c : " "; + size = utf8size(p); + memcpy(ptr, p, size); ptr += size; } /* \n at the end of every selected line except for the last one */ @@ -2598,9 +2602,11 @@ xseturgency(int add) { void focus(XEvent *ev) { if(ev->type == FocusIn) { + XSetICFocus(xw.xic); xw.state |= WIN_FOCUSED; xseturgency(0); } else { + XUnsetICFocus(xw.xic); xw.state &= ~WIN_FOCUSED; } } @@ -2770,7 +2776,7 @@ run(void) { while(XPending(xw.dpy)) { XNextEvent(xw.dpy, &ev); - if(XFilterEvent(&ev, xw.win)) + if(XFilterEvent(&ev, None)) continue; if(handler[ev.type]) (handler[ev.type])(&ev); @@ -2845,6 +2851,7 @@ main(int argc, char *argv[]) { run: setlocale(LC_CTYPE, ""); + XSetLocaleModifiers(""); tnew(80, 24); xinit(); ttynew();