aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-10-28 13:35:00 +0100
committerChristoph Lohmann <20h@r-36.net>2012-10-28 13:35:00 +0100
commitb56a0da283bd09d5084f472353c1a0b1b084613e (patch)
tree270495abe0d30f039cec7058e4741e07053d7052
parent71b09ec4f172da9a89be2add54b5b94da8af3bea (diff)
downloadst-b56a0da283bd09d5084f472353c1a0b1b084613e.tar.gz
st-b56a0da283bd09d5084f472353c1a0b1b084613e.tar.bz2
Applying the tab expansion patch from koga.
-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) {
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 */