Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
f555908cef | |||
73120414e2 | |||
9911455f5b | |||
2772c51e79 | |||
d57c873f10 | |||
724f72142f | |||
5b8dce15d3 | |||
063c3d26e9 | |||
03c2b05bb2 | |||
8a066fabd9 | |||
6c0e05eb0d | |||
900d34347b | |||
4d0cc17794 | |||
28b6ea0f67 | |||
598d72fba9 | |||
007be12f2b | |||
6b5b580aff | |||
d8b48d64e1 | |||
a71424ac0e | |||
f1ab687c62 | |||
68a24f5535 | |||
47b37834c4 |
6
.hgtags
6
.hgtags
@ -22,3 +22,9 @@ c7f5f4d543170f03d70468e98a3a0ec8d2c4161b 1.9
|
||||
7656557298c954469a6a9564e6649b1fb5db663e 2.1
|
||||
90f0e34e7f118c9ad3227a1606211ee825942b1c 2.2
|
||||
b6e09682c8adcb6569656bee73c311f9ab457715 2.3
|
||||
9e9036cbfb4b7306c6fb366249e81dc0e65bdfde 2.4
|
||||
03e83e2788c83ddd63b45a667939d7ec783c98cb 2.4.1
|
||||
1ca5d430524e838c52ede912533cb90108c5cd66 2.4.2
|
||||
041143e9fc544c62edc58af52cae9ac5237e5945 2.5
|
||||
775f761a5647a05038e091d1c99fc35d3034cd68 2.6
|
||||
fbd9e9d63f202afe6834ccfdf890904f1897ec0b 2.7
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dmenu version
|
||||
VERSION = 2.4
|
||||
VERSION = 2.8
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
24
dmenu.1
24
dmenu.1
@ -1,4 +1,4 @@
|
||||
.TH DMENU 1 dmenu-VERSION
|
||||
.TH DMENU 1 dmenu\-VERSION
|
||||
.SH NAME
|
||||
dmenu \- dynamic menu
|
||||
.SH SYNOPSIS
|
||||
@ -53,41 +53,41 @@ dmenu is completely controlled by the keyboard. The following keys are recognize
|
||||
Appends the character to the text in the input field. This works as a filter:
|
||||
only items containing this text will be displayed.
|
||||
.TP
|
||||
.B Left/Right (Mod1-h/Mod1-l)
|
||||
.B Left/Right (Mod1\-h/Mod1\-l)
|
||||
Select the previous/next item.
|
||||
.TP
|
||||
.B PageUp/PageDown (Mod1-k/Mod1-j)
|
||||
.B PageUp/PageDown (Mod1\-k/Mod1\-j)
|
||||
Select the first item of the previous/next 'page' of items.
|
||||
.TP
|
||||
.B Home/End (Mod1-g/Mod1-G)
|
||||
.B Home/End (Mod1\-g/Mod1\-G)
|
||||
Select the first/last item.
|
||||
.TP
|
||||
.B Tab (Control-i)
|
||||
.B Tab (Control\-i)
|
||||
Copy the selected item to the input field.
|
||||
.TP
|
||||
.B Return (Control-j)
|
||||
.B Return (Control\-j)
|
||||
Confirm selection and quit (print the selected item to standard output). Returns
|
||||
.B 0
|
||||
on termination.
|
||||
.TP
|
||||
.B Shift-Return (Control-Shift-j)
|
||||
.B Shift\-Return (Control\-Shift\-j)
|
||||
Confirm selection and quit (print the text in the input field to standard output).
|
||||
Returns
|
||||
.B 0
|
||||
on termination.
|
||||
.TP
|
||||
.B Escape (Control-bracketleft)
|
||||
.B Escape (Control\-bracketleft)
|
||||
Quit without selecting an item. Returns
|
||||
.B 1
|
||||
on termination.
|
||||
.TP
|
||||
.B Backspace (Control-h)
|
||||
Remove enough characters from the input field to change its filtering effect.
|
||||
.B Backspace (Control\-h)
|
||||
Remove a character from the input field.
|
||||
.TP
|
||||
.B Control-u
|
||||
.B Control\-u
|
||||
Remove all characters from the input field.
|
||||
.TP
|
||||
.B Control-w
|
||||
.B Control\-w
|
||||
Remove all characters of current word from the input field.
|
||||
.SH SEE ALSO
|
||||
.BR dwm (1),
|
||||
|
18
dmenu.h
18
dmenu.h
@ -29,16 +29,16 @@ typedef struct {
|
||||
} font;
|
||||
} DC; /* draw context */
|
||||
|
||||
extern int screen;
|
||||
extern Display *dpy;
|
||||
extern DC dc; /* global drawing context */
|
||||
int screen;
|
||||
Display *dpy;
|
||||
DC dc; /* global drawing context */
|
||||
|
||||
/* draw.c */
|
||||
extern void drawtext(const char *text, unsigned long col[ColLast]);
|
||||
extern unsigned int textw(const char *text);
|
||||
extern unsigned int textnw(const char *text, unsigned int len);
|
||||
void drawtext(const char *text, unsigned long col[ColLast]);
|
||||
unsigned int textw(const char *text);
|
||||
unsigned int textnw(const char *text, unsigned int len);
|
||||
|
||||
/* util.c */
|
||||
extern void *emalloc(unsigned int size); /* allocates memory, exits on error */
|
||||
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||
extern char *estrdup(const char *str); /* duplicates str, exits on allocation error */
|
||||
void *emalloc(unsigned int size); /* allocates memory, exits on error */
|
||||
void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||
char *estrdup(const char *str); /* duplicates str, exits on allocation error */
|
||||
|
@ -1,2 +1,9 @@
|
||||
#!/bin/sh
|
||||
/bin/ls -lL `echo $PATH | tr : ' '` 2> /dev/null | awk '$1 ~ /^[^d].*x/ { print $NF }' | /usr/bin/sort -u
|
||||
IFS=:
|
||||
for dir in $PATH
|
||||
do
|
||||
for file in "$dir"/*
|
||||
do
|
||||
test -x "$file" && echo "${file##*/}"
|
||||
done
|
||||
done | sort | uniq
|
||||
|
15
draw.c
15
draw.c
@ -12,7 +12,6 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
@ -41,18 +40,12 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
}
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = col[ColFG];
|
||||
if(dc.font.set) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc,
|
||||
x, y, buf, len);
|
||||
}
|
||||
else {
|
||||
gcv.font = dc.font.xfont->fid;
|
||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||
XSetForeground(dpy, dc.gc, col[ColFG]);
|
||||
if(dc.font.set)
|
||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||
else
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
textw(const char *text) {
|
||||
|
39
main.c
39
main.c
@ -108,6 +108,19 @@ drawmenu(void) {
|
||||
XFlush(dpy);
|
||||
}
|
||||
|
||||
static Bool
|
||||
grabkeyboard(void) {
|
||||
unsigned int len;
|
||||
|
||||
for(len = 1000; len; len--) {
|
||||
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
|
||||
== GrabSuccess)
|
||||
break;
|
||||
usleep(1000);
|
||||
}
|
||||
return len > 0;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
initcolor(const char *colstr) {
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
@ -196,7 +209,7 @@ match(char *pattern) {
|
||||
static void
|
||||
kpress(XKeyEvent * e) {
|
||||
char buf[32];
|
||||
int i, num, prev_nitem;
|
||||
int i, num;
|
||||
unsigned int len;
|
||||
KeySym ksym;
|
||||
|
||||
@ -282,12 +295,8 @@ kpress(XKeyEvent * e) {
|
||||
}
|
||||
break;
|
||||
case XK_BackSpace:
|
||||
if((i = len)) {
|
||||
prev_nitem = nitem;
|
||||
do {
|
||||
text[--i] = 0;
|
||||
match(text);
|
||||
} while(i && nitem && prev_nitem == nitem);
|
||||
if(len) {
|
||||
text[--len] = 0;
|
||||
match(text);
|
||||
}
|
||||
break;
|
||||
@ -418,10 +427,6 @@ main(int argc, char *argv[]) {
|
||||
XModifierKeymap *modmap;
|
||||
XSetWindowAttributes wa;
|
||||
|
||||
if(isatty(STDIN_FILENO)) {
|
||||
fputs("error: dmenu can't run in an interactive shell\n", stdout);
|
||||
usage();
|
||||
}
|
||||
/* command line args */
|
||||
for(i = 1; i < argc; i++)
|
||||
if(!strncmp(argv[i], "-b", 3)) {
|
||||
@ -455,10 +460,14 @@ main(int argc, char *argv[]) {
|
||||
eprint("dmenu: cannot open display\n");
|
||||
screen = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, screen);
|
||||
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) != GrabSuccess)
|
||||
usleep(1000);
|
||||
if(isatty(STDIN_FILENO)) {
|
||||
maxname = readstdin();
|
||||
running = grabkeyboard();
|
||||
}
|
||||
else { /* prevent keypress loss */
|
||||
running = grabkeyboard();
|
||||
maxname = readstdin();
|
||||
}
|
||||
/* init modifier map */
|
||||
modmap = XGetModifierMapping(dpy);
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -490,6 +499,8 @@ main(int argc, char *argv[]) {
|
||||
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
if(!dc.font.set)
|
||||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||
if(maxname)
|
||||
cmdw = textw(maxname);
|
||||
if(cmdw > mw / 3)
|
||||
|
Reference in New Issue
Block a user