diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-08-31 18:22:59 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-08-31 18:22:59 +0200 |
commit | 75143af77c1f0d2e01c678acee29d87331c47b9d (patch) | |
tree | ad27a2f09cc077fb1e633253479ab314f3be5d0a | |
parent | 87d1f986378186aa433ae09e1581dca3911991ae (diff) | |
download | st-patched-75143af77c1f0d2e01c678acee29d87331c47b9d.tar.bz2 st-patched-75143af77c1f0d2e01c678acee29d87331c47b9d.tar.xz st-patched-75143af77c1f0d2e01c678acee29d87331c47b9d.zip |
cleanup.
-rw-r--r-- | st.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -218,13 +218,13 @@ selinit(void) { | |||
218 | } | 218 | } |
219 | 219 | ||
220 | static inline int selected(int x, int y) { | 220 | static inline int selected(int x, int y) { |
221 | if ((sel.ey==y && sel.by==y)) { | 221 | if(sel.ey == y && sel.by == y) { |
222 | int bx = MIN(sel.bx, sel.ex); | 222 | int bx = MIN(sel.bx, sel.ex); |
223 | int ex = MAX(sel.bx, sel.ex); | 223 | int ex = MAX(sel.bx, sel.ex); |
224 | return (x>=bx && x<=ex); | 224 | return BETWEEN(x, bx, ex); |
225 | } | 225 | } |
226 | return (((y>sel.b[1] && y<sel.e[1]) || (y==sel.e[1] && x<=sel.e[0])) || \ | 226 | return ((sel.b[1] < y&&y < sel.e[1]) || (y==sel.e[1] && x<=sel.e[0])) |
227 | (y==sel.b[1] && x>=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1]))); | 227 | || (y==sel.b[1] && x>=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1])); |
228 | } | 228 | } |
229 | 229 | ||
230 | static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { | 230 | static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { |
@@ -232,9 +232,9 @@ static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { | |||
232 | *b=*b==4096?5:*b==2048?4:*b==1024?3:*b==512?2:*b==256?1:-1; | 232 | *b=*b==4096?5:*b==2048?4:*b==1024?3:*b==512?2:*b==256?1:-1; |
233 | *x = e->xbutton.x/xw.cw; | 233 | *x = e->xbutton.x/xw.cw; |
234 | *y = e->xbutton.y/xw.ch; | 234 | *y = e->xbutton.y/xw.ch; |
235 | sel.b[0] = sel.by<sel.ey?sel.bx:sel.ex; | 235 | sel.b[0] = sel.by < sel.ey ? sel.bx : sel.ex; |
236 | sel.b[1] = MIN(sel.by, sel.ey); | 236 | sel.b[1] = MIN(sel.by, sel.ey); |
237 | sel.e[0] = sel.by<sel.ey?sel.ex:sel.bx; | 237 | sel.e[0] = sel.by < sel.ey ? sel.ex : sel.bx; |
238 | sel.e[1] = MAX(sel.by, sel.ey); | 238 | sel.e[1] = MAX(sel.by, sel.ey); |
239 | } | 239 | } |
240 | 240 | ||
@@ -247,16 +247,15 @@ static void bpress(XEvent *e) { | |||
247 | static char *getseltext() { | 247 | static char *getseltext() { |
248 | char *str, *ptr; | 248 | char *str, *ptr; |
249 | int ls, x, y, sz; | 249 | int ls, x, y, sz; |
250 | if(sel.bx==-1) | 250 | if(sel.bx == -1) |
251 | return NULL; | 251 | return NULL; |
252 | sz = ((term.col+1) * (sel.e[1]-sel.b[1]+1)); | 252 | sz = (term.col+1) * (sel.e[1]-sel.b[1]+1); |
253 | ptr = str = malloc (sz); | 253 | ptr = str = malloc(sz); |
254 | for(y = 0; y < term.row; y++) { | 254 | for(y = 0; y < term.row; y++) { |
255 | for(x = 0; x < term.col; x++) { | 255 | for(x = 0; x < term.col; x++) |
256 | if(term.line[y][x].state & GLYPH_SET && (ls=selected(x, y))) | 256 | if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y))) |
257 | *ptr = term.line[y][x].c, ptr++; | 257 | *ptr = term.line[y][x].c, ptr++; |
258 | } | 258 | if(ls) |
259 | if (ls) | ||
260 | *ptr = '\n', ptr++; | 259 | *ptr = '\n', ptr++; |
261 | } | 260 | } |
262 | *ptr = 0; | 261 | *ptr = 0; |