aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-04 20:33:01 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-04 20:33:01 +0200
commitec8262e106d476ba11cb82b2e4df77a38eed1abd (patch)
tree42ffa76c6d9c2d6442baed96e00f2020f17947b7
parent684a6b59eee2c5dd6a58a003245e37dcaf520ff4 (diff)
downloadst-ec8262e106d476ba11cb82b2e4df77a38eed1abd.tar.gz
st-ec8262e106d476ba11cb82b2e4df77a38eed1abd.tar.bz2
Check alternative screen before drawing box selection
Some programs use the alternative screen (vi, less, ...), whose content is different of the main screen. If you select text in one of the screen, you don't wait the box selection is painted in the other screen, so it is necessary check if the selection was done in the same screen we are going to paint. Before to this commit, you could do something like: $ LESS="" ls | less (select some code) q and selection box remains drawing in the main screen, but the content of selection keeps text of the alternate screen. --- st.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
-rw-r--r--st.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/st.c b/st.c
index 586d124..b143582 100644
--- a/st.c
+++ b/st.c
@@ -221,6 +221,7 @@ typedef struct {
struct {int x, y;} b, e;
char *clip;
Atom xtarget;
+ bool alt;
struct timeval tclick1;
struct timeval tclick2;
} Selection;
@@ -579,6 +580,7 @@ selcopy(void) {
}
*ptr = 0;
}
+ sel.alt = IS_SET(MODE_ALTSCREEN);
xsetsel(str);
}
@@ -2076,7 +2078,10 @@ drawregion(int x1, int y1, int x2, int y2) {
int ic, ib, x, y, ox, sl;
Glyph base, new;
char buf[DRAW_BUF_SIZ];
+ bool ena_sel = sel.bx != -1, alt = IS_SET(MODE_ALTSCREEN);
+ if((sel.alt && !alt) || (!sel.alt && alt))
+ ena_sel = 0;
if(!(xw.state & WIN_VISIBLE))
return;
@@ -2089,7 +2094,7 @@ drawregion(int x1, int y1, int x2, int y2) {
ic = ib = ox = 0;
for(x = x1; x < x2; x++) {
new = term.line[y][x];
- if(sel.bx != -1 && *(new.c) && selected(x, y))
+ if(ena_sel && *(new.c) && selected(x, y))
new.mode ^= ATTR_REVERSE;
if(ib > 0 && (!(new.state & GLYPH_SET) || ATTRCMP(base, new) ||
ib >= DRAW_BUF_SIZ-UTF_SIZ)) {