Add config option for word delimiters
120e8401
Let the user configure word boundaries other than ' ', only works with the portable character set.
2 file(s) · +10 −2
Let the user configure word boundaries other than ' ', only works with the portable character set.
| 15 | 15 | static const char *outfgcolor = "#000000"; |
|
| 16 | 16 | /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ |
|
| 17 | 17 | static unsigned int lines = 0; |
|
| 18 | + | ||
| 19 | + | /* |
|
| 20 | + | * Characters not considered part of a word while deleting words |
|
| 21 | + | * for example: " /?\"&[]" |
|
| 22 | + | */ |
|
| 23 | + | static const char worddelimiters[] = " "; |
| 314 | 314 | insert(NULL, 0 - cursor); |
|
| 315 | 315 | break; |
|
| 316 | 316 | case XK_w: /* delete word */ |
|
| 317 | - | while (cursor > 0 && text[nextrune(-1)] == ' ') |
|
| 317 | + | while (cursor > 0 && strchr(worddelimiters, |
|
| 318 | + | text[nextrune(-1)])) |
|
| 318 | 319 | insert(NULL, nextrune(-1) - cursor); |
|
| 319 | - | while (cursor > 0 && text[nextrune(-1)] != ' ') |
|
| 320 | + | while (cursor > 0 && !strchr(worddelimiters, |
|
| 321 | + | text[nextrune(-1)])) |
|
| 320 | 322 | insert(NULL, nextrune(-1) - cursor); |
|
| 321 | 323 | break; |
|
| 322 | 324 | case XK_y: /* paste selection */ |