diff --git a/config.def.h b/config.def.h index 047b5d1..dcaf67c 100644 --- a/config.def.h +++ b/config.def.h @@ -90,3 +90,4 @@ static char gfx[] = { #define TRIPLECLICK_TIMEOUT (2*DOUBLECLICK_TIMEOUT) #define TAB 8 +#define WORD_BREAK " " diff --git a/st.c b/st.c index 504688a..37288e5 100644 --- a/st.c +++ b/st.c @@ -228,6 +228,7 @@ typedef struct { } DC; static void die(const char*, ...); +static bool is_word_break(char); static void draw(void); static void drawregion(int, int, int, int); static void execsh(void); @@ -673,10 +674,10 @@ brelease(XEvent *e) { /* double click to select word */ sel.bx = sel.ex; while(sel.bx > 0 && term.line[sel.ey][sel.bx-1].state & GLYPH_SET && - term.line[sel.ey][sel.bx-1].c[0] != ' ') sel.bx--; + !is_word_break(term.line[sel.ey][sel.bx-1].c[0])) sel.bx--; sel.b.x = sel.bx; while(sel.ex < term.col-1 && term.line[sel.ey][sel.ex+1].state & GLYPH_SET && - term.line[sel.ey][sel.ex+1].c[0] != ' ') sel.ex++; + !is_word_break(term.line[sel.ey][sel.ex+1].c[0])) sel.ex++; sel.e.x = sel.ex; sel.b.y = sel.e.y = sel.ey; selcopy(); @@ -718,6 +719,17 @@ die(const char *errstr, ...) { exit(EXIT_FAILURE); } +bool +is_word_break(char c) { + static char *word_break = WORD_BREAK; + char *s = word_break; + while(*s) { + if(*s == c) return true; + s++; + } + return false; +} + void execsh(void) { char **args;