X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=b2e5e2228ae46706a963cbe831b1cc9d400dfbb2;hb=88a8f85a8a6de56d23510cf6e7810d90478085a5;hp=df7f8d8675864d375e122663138fd760c4d5e7f1;hpb=e3671006dba1c21316c570e11d6688f5513fb44e;p=st.git diff --git a/st.c b/st.c index df7f8d8..b2e5e22 100644 --- a/st.c +++ b/st.c @@ -363,14 +363,14 @@ void * xmalloc(size_t len) { void *p = malloc(len); if(!p) - die("Out of memory"); + die("Out of memory\n"); return p; } void * xrealloc(void *p, size_t len) { if((p = realloc(p, len)) == NULL) - die("Out of memory"); + die("Out of memory\n"); return p; } @@ -596,14 +596,17 @@ selcopy(void) { /* append every set & selected glyph to the selection */ for(y = 0; y < term.row; y++) { for(x = 0; x < term.col; x++) { - is_selected = selected(x, y); - if((term.line[y][x].state & GLYPH_SET) && is_selected) { - int size = utf8size(term.line[y][x].c); - memcpy(ptr, term.line[y][x].c, size); - ptr += size; - } + int size; + char *p; + Glyph *gp = &term.line[y][x]; + + if(!(is_selected = selected(x, y))) + continue; + 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 */ if(is_selected && y < sel.e.y) *ptr++ = '\n';