[hackers] [st] Applying the tab expansion patch from koga. || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Sun, 28 Oct 2012 13:39:04 +0100 (CET)

changeset: 370:127e792e5a3e
user: Christoph Lohmann <20h_AT_r-36.net>
date: Sun Oct 28 13:35:00 2012 +0100
files: st.c
description:
Applying the tab expansion patch from koga.


diff -r 32b780b3f648 -r 127e792e5a3e st.c
--- a/st.c Sun Oct 28 13:25:53 2012 +0100
+++ b/st.c Sun Oct 28 13:35:00 2012 +0100
_AT_@ -663,9 +663,9 @@
 
 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;
_AT_@ -675,15 +675,19 @@
 
                 /* 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 */
Received on Sun Oct 28 2012 - 13:39:04 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 28 2012 - 13:48:31 CET