diff options
| author | pancake@nopcode.org <unknown> | 2010-08-31 17:36:55 +0200 |
|---|---|---|
| committer | pancake@nopcode.org <unknown> | 2010-08-31 17:36:55 +0200 |
| commit | 591d147af7d59f31a68513f613124d49f25f9859 (patch) | |
| tree | 386af53d0c8ca8a4957b418861374956c65e005c | |
| parent | 1132d9e2d65f469dedd9c5b6f356495c7a87b743 (diff) | |
| download | st-591d147af7d59f31a68513f613124d49f25f9859.tar.gz st-591d147af7d59f31a68513f613124d49f25f9859.zip | |
fix segfault when selecting big buffers
shift+insert paste clipboard
honor CFLAGS and LDFLAGS in config.mk
| -rw-r--r-- | config.mk | 6 | ||||
| -rw-r--r-- | st.c | 22 |
2 files changed, 9 insertions, 19 deletions
| @@ -16,8 +16,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil | |||
| 16 | 16 | ||
| 17 | # flags | 17 | # flags |
| 18 | CPPFLAGS = -DVERSION=\"${VERSION}\" | 18 | CPPFLAGS = -DVERSION=\"${VERSION}\" |
| 19 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} | 19 | CFLAGS += -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} |
| 20 | LDFLAGS = -s ${LIBS} | 20 | LDFLAGS += -s ${LIBS} |
| 21 | 21 | ||
| 22 | # compiler and linker | 22 | # compiler and linker |
| 23 | CC = cc | 23 | CC ?= cc |
| @@ -249,19 +249,15 @@ static char *getseltext() { | |||
| 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 = ((xw.w/xw.ch) * (sel.e[1]-sel.b[1]+2)); | 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; | 257 | *ptr = term.line[y][x].c, ptr++; |
| 258 | ptr++; | ||
| 259 | } | ||
| 260 | } | ||
| 261 | if (ls) { | ||
| 262 | *ptr = '\n'; | ||
| 263 | ptr++; | ||
| 264 | } | 258 | } |
| 259 | if (ls) | ||
| 260 | *ptr = '\n', ptr++; | ||
| 265 | } | 261 | } |
| 266 | *ptr = 0; | 262 | *ptr = 0; |
| 267 | return str; | 263 | return str; |
| @@ -283,12 +279,6 @@ static void brelease(XEvent *e) { | |||
| 283 | int b; | 279 | int b; |
| 284 | sel.mode = 0; | 280 | sel.mode = 0; |
| 285 | getbuttoninfo(e, &b, &sel.ex, &sel.ey); | 281 | getbuttoninfo(e, &b, &sel.ex, &sel.ey); |
| 286 | if(b==4) | ||
| 287 | tscrollup(1); | ||
| 288 | else | ||
| 289 | if(b==5) | ||
| 290 | tscrolldown(1); | ||
| 291 | else | ||
| 292 | if(sel.bx==sel.ex && sel.by==sel.ey) { | 282 | if(sel.bx==sel.ex && sel.by==sel.ey) { |
| 293 | sel.bx = -1; | 283 | sel.bx = -1; |
| 294 | if(b==2) | 284 | if(b==2) |
| @@ -1411,7 +1401,7 @@ kpress(XEvent *ev) { | |||
| 1411 | break; | 1401 | break; |
| 1412 | case XK_Insert: | 1402 | case XK_Insert: |
| 1413 | if(shift) | 1403 | if(shift) |
| 1414 | draw(1), puts("draw!")/* XXX: paste X clipboard */; | 1404 | selpaste(), draw(1); |
| 1415 | break; | 1405 | break; |
| 1416 | default: | 1406 | default: |
| 1417 | fprintf(stderr, "errkey: %d\n", (int)ksym); | 1407 | fprintf(stderr, "errkey: %d\n", (int)ksym); |
