aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--st.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/st.c b/st.c
index 5703e96..ebc9962 100644
--- a/st.c
+++ b/st.c
@@ -663,9 +663,9 @@ bpress(XEvent *e) {
663 663
664void 664void
665selcopy(void) { 665selcopy(void) {
666 char *str, *ptr; 666 char *str, *ptr, *p;
667 int x, y, bufsize, is_selected = 0, size; 667 int x, y, bufsize, is_selected = 0, size;
668 Glyph *gp; 668 Glyph *gp, *last;
669 669
670 if(sel.bx == -1) { 670 if(sel.bx == -1) {
671 str = NULL; 671 str = NULL;
@@ -675,15 +675,19 @@ selcopy(void) {
675 675
676 /* append every set & selected glyph to the selection */ 676 /* append every set & selected glyph to the selection */
677 for(y = 0; y < term.row; y++) { 677 for(y = 0; y < term.row; y++) {
678 for(x = 0; x < term.col; x++) { 678 gp = &term.line[y][0];
679 gp = &term.line[y][x]; 679 last = gp + term.col;
680 680
681 if(!(is_selected = selected(x, y)) 681 while(--last >= gp && !(last->state & GLYPH_SET))
682 || !(gp->state & GLYPH_SET)) { 682 /* nothing */;
683
684 for(x = 0; gp <= last; x++, ++gp) {
685 if(!(is_selected = selected(x, y)))
683 continue; 686 continue;
684 } 687
685 size = utf8size(gp->c); 688 p = (gp->state & GLYPH_SET) ? gp->c : " ";
686 memcpy(ptr, gp->c, size); 689 size = utf8size(p);
690 memcpy(ptr, p, size);
687 ptr += size; 691 ptr += size;
688 } 692 }
689 /* \n at the end of every selected line except for the last one */ 693 /* \n at the end of every selected line except for the last one */