some changes
This commit is contained in:
parent
e35976f4a5
commit
b319a691c7
|
@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||||
* for example: " /?\"&[]"
|
* for example: " /?\"&[]"
|
||||||
*/
|
*/
|
||||||
static const char worddelimiters[] = " ";
|
static const char worddelimiters[] = " ";
|
||||||
|
static unsigned int borderwidth = 2;
|
||||||
|
static unsigned int bordervisible = 0;
|
||||||
|
static const unsigned int gappx = 10;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
};
|
||||||
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Characters not considered part of a word while deleting words
|
||||||
|
* for example: " /?\"&[]"
|
||||||
|
*/
|
||||||
|
static const char worddelimiters[] = " ";
|
||||||
|
static unsigned int borderwidth = 2;
|
||||||
|
static unsigned int bordervisible = 0;
|
||||||
|
static const unsigned int gappx = 10;
|
30
dmenu.c
30
dmenu.c
|
@ -55,6 +55,9 @@ static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
static int dmx = gappx;
|
||||||
|
static int dmy = gappx;
|
||||||
|
|
||||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
static char *(*fstrstr)(const char *, const char *) = strstr;
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
|
||||||
|
@ -658,9 +661,9 @@ setup(void)
|
||||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
x = info[i].x_org;
|
x = info[i].x_org + dmx;
|
||||||
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
|
||||||
mw = info[i].width;
|
mw = info[i].width - dmx * 2;
|
||||||
XFree(info);
|
XFree(info);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -668,9 +671,9 @@ setup(void)
|
||||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
die("could not get embedding window attributes: 0x%lx",
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
parentwin);
|
parentwin);
|
||||||
x = 0;
|
x = dmx;
|
||||||
y = topbar ? 0 : wa.height - mh;
|
y = topbar ? dmy : wa.height - mh - dmy;
|
||||||
mw = wa.width;
|
mw = wa.width - dmx * 2;
|
||||||
}
|
}
|
||||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
inputw = mw / 3; /* input width: ~33% of monitor width */
|
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||||
|
@ -680,9 +683,15 @@ setup(void)
|
||||||
swa.override_redirect = True;
|
swa.override_redirect = True;
|
||||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
win = XCreateWindow(dpy, parentwin, x, y - (topbar ? 0 : borderwidth * 2), mw - borderwidth * 2, mh, borderwidth,
|
||||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
if (borderwidth) {
|
||||||
|
if (bordervisible)
|
||||||
|
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||||
|
else
|
||||||
|
XSetWindowBorder(dpy, win, scheme[SchemeNorm][ColBg].pixel);
|
||||||
|
}
|
||||||
XSetClassHint(dpy, win, &ch);
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
@ -711,6 +720,7 @@ static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
|
" [-g gap] [-bw borderwidth] [-bv bordervisible]\n"
|
||||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -738,6 +748,8 @@ main(int argc, char *argv[])
|
||||||
/* these options take one argument */
|
/* these options take one argument */
|
||||||
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||||
lines = atoi(argv[++i]);
|
lines = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-g"))
|
||||||
|
dmx = dmy = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-m"))
|
else if (!strcmp(argv[i], "-m"))
|
||||||
mon = atoi(argv[++i]);
|
mon = atoi(argv[++i]);
|
||||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
|
@ -754,6 +766,10 @@ main(int argc, char *argv[])
|
||||||
colors[SchemeSel][ColFg] = argv[++i];
|
colors[SchemeSel][ColFg] = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||||
embed = argv[++i];
|
embed = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-bw"))
|
||||||
|
borderwidth = (unsigned int)argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-bv"))
|
||||||
|
bordervisible = (unsigned int)argv[++i];
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue