dev
Aurélien Aptel 2010-08-31 18:22:59 +02:00
parent 591d147af7
commit 9703859e6c
1 changed files with 12 additions and 13 deletions

13
st.c
View File

@ -218,13 +218,13 @@ selinit(void) {
} }
static inline int selected(int x, int y) { static inline int selected(int x, int y) {
if ((sel.ey==y && sel.by==y)) { if(sel.ey == y && sel.by == y) {
int bx = MIN(sel.bx, sel.ex); int bx = MIN(sel.bx, sel.ex);
int ex = MAX(sel.bx, sel.ex); int ex = MAX(sel.bx, sel.ex);
return (x>=bx && x<=ex); return BETWEEN(x, bx, ex);
} }
return (((y>sel.b[1] && y<sel.e[1]) || (y==sel.e[1] && x<=sel.e[0])) || \ return ((sel.b[1] < y&&y < sel.e[1]) || (y==sel.e[1] && x<=sel.e[0]))
(y==sel.b[1] && x>=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1]))); || (y==sel.b[1] && x>=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1]));
} }
static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
@ -249,13 +249,12 @@ static char *getseltext() {
int ls, x, y, sz; int ls, x, y, sz;
if(sel.bx == -1) if(sel.bx == -1)
return NULL; return NULL;
sz = ((term.col+1) * (sel.e[1]-sel.b[1]+1)); sz = (term.col+1) * (sel.e[1]-sel.b[1]+1);
ptr = str = malloc(sz); ptr = str = malloc(sz);
for(y = 0; y < term.row; y++) { for(y = 0; y < term.row; y++) {
for(x = 0; x < term.col; x++) { for(x = 0; x < term.col; x++)
if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y))) if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y)))
*ptr = term.line[y][x].c, ptr++; *ptr = term.line[y][x].c, ptr++;
}
if(ls) if(ls)
*ptr = '\n', ptr++; *ptr = '\n', ptr++;
} }