Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Add config option for word delimiters
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
1c2e780
..
e0c2f80
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-1,7
+1,6
@@
/* See LICENSE file for copyright and license details. */
#include <ctype.h>
#include <locale.h>
/* See LICENSE file for copyright and license details. */
#include <ctype.h>
#include <locale.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-32,7
+31,7
@@
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
struct item {
char *text;
struct item *left, *right;
struct item {
char *text;
struct item *left, *right;
-
bool
out;
+
int
out;
};
static char text[BUFSIZ] = "";
};
static char text[BUFSIZ] = "";
@@
-315,9
+314,11
@@
keypress(XKeyEvent *ev)
insert(NULL, 0 - cursor);
break;
case XK_w: /* delete word */
insert(NULL, 0 - cursor);
break;
case XK_w: /* delete word */
- while (cursor > 0 && text[nextrune(-1)] == ' ')
+ while (cursor > 0 && strchr(worddelimiters,
+ text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
insert(NULL, nextrune(-1) - cursor);
- while (cursor > 0 && text[nextrune(-1)] != ' ')
+ while (cursor > 0 && !strchr(worddelimiters,
+ text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
break;
case XK_y: /* paste selection */
insert(NULL, nextrune(-1) - cursor);
break;
case XK_y: /* paste selection */
@@
-421,7
+422,7
@@
keypress(XKeyEvent *ev)
exit(0);
}
if (sel)
exit(0);
}
if (sel)
- sel->out =
true
;
+ sel->out =
1
;
break;
case XK_Right:
if (text[cursor] != '\0') {
break;
case XK_Right:
if (text[cursor] != '\0') {
@@
-480,7
+481,7
@@
readstdin(void)
*p = '\0';
if (!(items[i].text = strdup(buf)))
die("cannot strdup %u bytes:", strlen(buf) + 1);
*p = '\0';
if (!(items[i].text = strdup(buf)))
die("cannot strdup %u bytes:", strlen(buf) + 1);
- items[i].out =
false
;
+ items[i].out =
0
;
if (strlen(items[i].text) > max)
max = strlen(maxstr = items[i].text);
}
if (strlen(items[i].text) > max)
max = strlen(maxstr = items[i].text);
}
@@
-552,7
+553,7
@@
setup(void)
XGetInputFocus(dpy, &w, &di);
if (mon != -1 && mon < n)
i = mon;
XGetInputFocus(dpy, &w, &di);
if (mon != -1 && mon < n)
i = mon;
-
if (!i &&
w != root && w != PointerRoot && w != None) {
+
else if (
w != root && w != PointerRoot && w != None) {
/* find top-level window containing current input focus */
do {
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
/* find top-level window containing current input focus */
do {
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
@@
-617,8
+618,7
@@
usage(void)
int
main(int argc, char *argv[])
{
int
main(int argc, char *argv[])
{
- bool fast = false;
- int i;
+ int i, fast = 0;
for (i = 1; i < argc; i++)
/* these options take no arguments */
for (i = 1; i < argc; i++)
/* these options take no arguments */
@@
-626,9
+626,9
@@
main(int argc, char *argv[])
puts("dmenu-"VERSION);
exit(0);
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
puts("dmenu-"VERSION);
exit(0);
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
- topbar =
false
;
+ topbar =
0
;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
- fast =
true
;
+ fast =
1
;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;