Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
308fe78b83 | |||
c4b656e0da | |||
3e39c526d2 | |||
a9a3836861 | |||
eb96af27f4 | |||
d78ff08d99 | |||
cd2133a5f6 | |||
c585e8e498 | |||
523aa08f51 | |||
1a13d0465d | |||
9b38fda6fe | |||
db6093f6ec | |||
a9b1de384a | |||
43b0c2c3dd | |||
f5036b90ef | |||
153aaf88bf |
4
LICENSE
4
LICENSE
@ -8,8 +8,8 @@ MIT/X Consortium License
|
|||||||
© 2009 Markus Schnalke <meillo@marmaro.de>
|
© 2009 Markus Schnalke <meillo@marmaro.de>
|
||||||
© 2009 Evan Gates <evan.gates@gmail.com>
|
© 2009 Evan Gates <evan.gates@gmail.com>
|
||||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||||
© 2014-2019 Hiltjo Posthuma <hiltjo@codemadness.org>
|
© 2014-2022 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||||
© 2015-2018 Quentin Rameau <quinq@fifth.space>
|
© 2015-2019 Quentin Rameau <quinq@fifth.space>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 4.9
|
VERSION = 5.1
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
47
dmenu.c
47
dmenu.c
@ -103,13 +103,20 @@ cleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
cistrstr(const char *s, const char *sub)
|
cistrstr(const char *h, const char *n)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t i;
|
||||||
|
|
||||||
for (len = strlen(sub); *s; s++)
|
if (!n[0])
|
||||||
if (!strncasecmp(s, sub, len))
|
return (char *)h;
|
||||||
return (char *)s;
|
|
||||||
|
for (; *h; ++h) {
|
||||||
|
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
|
||||||
|
tolower((unsigned char)h[i]); ++i)
|
||||||
|
;
|
||||||
|
if (n[i] == '\0')
|
||||||
|
return (char *)h;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,9 +367,11 @@ keypress(XKeyEvent *ev)
|
|||||||
utf8, utf8, win, CurrentTime);
|
utf8, utf8, win, CurrentTime);
|
||||||
return;
|
return;
|
||||||
case XK_Left:
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
movewordedge(-1);
|
movewordedge(-1);
|
||||||
goto draw;
|
goto draw;
|
||||||
case XK_Right:
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
movewordedge(+1);
|
movewordedge(+1);
|
||||||
goto draw;
|
goto draw;
|
||||||
case XK_Return:
|
case XK_Return:
|
||||||
@ -400,6 +409,7 @@ insert:
|
|||||||
insert(buf, len);
|
insert(buf, len);
|
||||||
break;
|
break;
|
||||||
case XK_Delete:
|
case XK_Delete:
|
||||||
|
case XK_KP_Delete:
|
||||||
if (text[cursor] == '\0')
|
if (text[cursor] == '\0')
|
||||||
return;
|
return;
|
||||||
cursor = nextrune(+1);
|
cursor = nextrune(+1);
|
||||||
@ -410,6 +420,7 @@ insert:
|
|||||||
insert(NULL, nextrune(-1) - cursor);
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
break;
|
break;
|
||||||
case XK_End:
|
case XK_End:
|
||||||
|
case XK_KP_End:
|
||||||
if (text[cursor] != '\0') {
|
if (text[cursor] != '\0') {
|
||||||
cursor = strlen(text);
|
cursor = strlen(text);
|
||||||
break;
|
break;
|
||||||
@ -429,6 +440,7 @@ insert:
|
|||||||
cleanup();
|
cleanup();
|
||||||
exit(1);
|
exit(1);
|
||||||
case XK_Home:
|
case XK_Home:
|
||||||
|
case XK_KP_Home:
|
||||||
if (sel == matches) {
|
if (sel == matches) {
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
break;
|
break;
|
||||||
@ -437,6 +449,7 @@ insert:
|
|||||||
calcoffsets();
|
calcoffsets();
|
||||||
break;
|
break;
|
||||||
case XK_Left:
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||||
cursor = nextrune(-1);
|
cursor = nextrune(-1);
|
||||||
break;
|
break;
|
||||||
@ -445,18 +458,21 @@ insert:
|
|||||||
return;
|
return;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case XK_Up:
|
case XK_Up:
|
||||||
|
case XK_KP_Up:
|
||||||
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||||
curr = prev;
|
curr = prev;
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XK_Next:
|
case XK_Next:
|
||||||
|
case XK_KP_Next:
|
||||||
if (!next)
|
if (!next)
|
||||||
return;
|
return;
|
||||||
sel = curr = next;
|
sel = curr = next;
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
break;
|
break;
|
||||||
case XK_Prior:
|
case XK_Prior:
|
||||||
|
case XK_KP_Prior:
|
||||||
if (!prev)
|
if (!prev)
|
||||||
return;
|
return;
|
||||||
sel = curr = prev;
|
sel = curr = prev;
|
||||||
@ -473,6 +489,7 @@ insert:
|
|||||||
sel->out = 1;
|
sel->out = 1;
|
||||||
break;
|
break;
|
||||||
case XK_Right:
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
if (text[cursor] != '\0') {
|
if (text[cursor] != '\0') {
|
||||||
cursor = nextrune(+1);
|
cursor = nextrune(+1);
|
||||||
break;
|
break;
|
||||||
@ -481,6 +498,7 @@ insert:
|
|||||||
return;
|
return;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case XK_Down:
|
case XK_Down:
|
||||||
|
case XK_KP_Down:
|
||||||
if (sel && sel->right && (sel = sel->right) == next) {
|
if (sel && sel->right && (sel = sel->right) == next) {
|
||||||
curr = next;
|
curr = next;
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
@ -553,9 +571,14 @@ run(void)
|
|||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
while (!XNextEvent(dpy, &ev)) {
|
while (!XNextEvent(dpy, &ev)) {
|
||||||
if (XFilterEvent(&ev, None))
|
if (XFilterEvent(&ev, win))
|
||||||
continue;
|
continue;
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
|
case DestroyNotify:
|
||||||
|
if (ev.xdestroywindow.window != win)
|
||||||
|
break;
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
case Expose:
|
case Expose:
|
||||||
if (ev.xexpose.count == 0)
|
if (ev.xexpose.count == 0)
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
@ -659,15 +682,17 @@ setup(void)
|
|||||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
XSetClassHint(dpy, win, &ch);
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
/* open input methods */
|
|
||||||
xim = XOpenIM(dpy, NULL, NULL, NULL);
|
/* input methods */
|
||||||
|
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
|
||||||
|
die("XOpenIM failed: could not open input device");
|
||||||
|
|
||||||
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||||
XNClientWindow, win, XNFocusWindow, win, NULL);
|
XNClientWindow, win, XNFocusWindow, win, NULL);
|
||||||
|
|
||||||
XMapRaised(dpy, win);
|
XMapRaised(dpy, win);
|
||||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
|
||||||
if (embed) {
|
if (embed) {
|
||||||
XSelectInput(dpy, parentwin, FocusChangeMask);
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||||
for (i = 0; i < du && dws[i] != win; ++i)
|
for (i = 0; i < du && dws[i] != win; ++i)
|
||||||
XSelectInput(dpy, dws[i], FocusChangeMask);
|
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||||
@ -731,8 +756,6 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
fputs("warning: no locale support\n", stderr);
|
fputs("warning: no locale support\n", stderr);
|
||||||
if (!XSetLocaleModifiers(""))
|
|
||||||
fputs("warning: no locale modifiers support\n", stderr);
|
|
||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("cannot open display");
|
die("cannot open display");
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
|
0
dmenu_path
Normal file → Executable file
0
dmenu_path
Normal file → Executable file
1
drw.c
1
drw.c
@ -95,6 +95,7 @@ drw_free(Drw *drw)
|
|||||||
{
|
{
|
||||||
XFreePixmap(drw->dpy, drw->drawable);
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
XFreeGC(drw->dpy, drw->gc);
|
XFreeGC(drw->dpy, drw->gc);
|
||||||
|
drw_fontset_free(drw->fonts);
|
||||||
free(drw);
|
free(drw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
stest.c
2
stest.c
@ -84,7 +84,7 @@ main(int argc, char *argv[])
|
|||||||
if (!argc) {
|
if (!argc) {
|
||||||
/* read list from stdin */
|
/* read list from stdin */
|
||||||
while ((n = getline(&line, &linesiz, stdin)) > 0) {
|
while ((n = getline(&line, &linesiz, stdin)) > 0) {
|
||||||
if (n && line[n - 1] == '\n')
|
if (line[n - 1] == '\n')
|
||||||
line[n - 1] = '\0';
|
line[n - 1] = '\0';
|
||||||
test(line, line);
|
test(line, line);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user