aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-17 22:13:09 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-17 22:13:09 +0200
commit88a8f85a8a6de56d23510cf6e7810d90478085a5 (patch)
tree5ed1a807527bb243d35bef192011bb647d92815c /st.c
parent111199cf226b33f12e6ee3e66e50fbe5c3566e33 (diff)
downloadst-88a8f85a8a6de56d23510cf6e7810d90478085a5.tar.gz
st-88a8f85a8a6de56d23510cf6e7810d90478085a5.tar.bz2
Copy non set positions as spaces
st selection don't insert in the selection position whose value is not set. This is correct for the positions in the end of the line, but cause some problems in the beginning. For example echo -e 'a\tb' will print in the screen: a b but after selecting and copying in some place you get: ab because positions from 1 to 7 don't have any value. This patch deals all positions without value as blank (even at the end of the line). --- st.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
Diffstat (limited to 'st.c')
-rw-r--r--st.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/st.c b/st.c
index c408ca9..b2e5e22 100644
--- a/st.c
+++ b/st.c
@@ -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';