tear out a lot more
This commit is contained in:
parent
aa74459a4e
commit
577c419c2a
@ -57,19 +57,6 @@ static Clr *scheme[SchemeLast];
|
|||||||
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;
|
||||||
|
|
||||||
static void
|
|
||||||
appenditem(struct item *item, struct item **list, struct item **last)
|
|
||||||
{
|
|
||||||
if (*last)
|
|
||||||
(*last)->right = item;
|
|
||||||
else
|
|
||||||
*list = item;
|
|
||||||
|
|
||||||
item->left = *last;
|
|
||||||
item->right = NULL;
|
|
||||||
*last = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calcoffsets(void)
|
calcoffsets(void)
|
||||||
{
|
{
|
||||||
@ -98,19 +85,6 @@ cleanup(void)
|
|||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
drawitem(struct item *item, int x, int y, int w)
|
|
||||||
{
|
|
||||||
if (item == sel)
|
|
||||||
drw_setscheme(drw, scheme[SchemeSel]);
|
|
||||||
else if (item->out)
|
|
||||||
drw_setscheme(drw, scheme[SchemeOut]);
|
|
||||||
else
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
|
|
||||||
return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawmenu(void)
|
drawmenu(void)
|
||||||
{
|
{
|
||||||
@ -125,34 +99,6 @@ drawmenu(void)
|
|||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
readstdin(void)
|
|
||||||
{
|
|
||||||
char buf[sizeof text], *p;
|
|
||||||
size_t i, imax = 0, size = 0;
|
|
||||||
unsigned int tmpmax = 0;
|
|
||||||
|
|
||||||
/* read each line from stdin and add it to the item list */
|
|
||||||
for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
|
|
||||||
if (i + 1 >= size / sizeof *items)
|
|
||||||
if (!(items = realloc(items, (size += BUFSIZ))))
|
|
||||||
die("cannot realloc %u bytes:", size);
|
|
||||||
if ((p = strchr(buf, '\n')))
|
|
||||||
*p = '\0';
|
|
||||||
if (!(items[i].text = strdup(buf)))
|
|
||||||
die("cannot strdup %u bytes:", strlen(buf) + 1);
|
|
||||||
items[i].out = 0;
|
|
||||||
drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
|
|
||||||
if (tmpmax > inputw) {
|
|
||||||
inputw = tmpmax;
|
|
||||||
imax = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (items)
|
|
||||||
items[i].text = NULL;
|
|
||||||
inputw = items ? TEXTW(items[imax].text) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup(void)
|
setup(void)
|
||||||
{
|
{
|
||||||
@ -281,13 +227,9 @@ main(int argc, char *argv[])
|
|||||||
prompt = argv[++i];
|
prompt = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
||||||
fonts[0] = argv[++i];
|
fonts[0] = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-nb")) /* normal background color */
|
else if (!strcmp(argv[i], "-b")) /* selected background color */
|
||||||
colors[SchemeNorm][ColBg] = argv[++i];
|
|
||||||
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
|
|
||||||
colors[SchemeNorm][ColFg] = argv[++i];
|
|
||||||
else if (!strcmp(argv[i], "-sb")) /* selected background color */
|
|
||||||
colors[SchemeSel][ColBg] = argv[++i];
|
colors[SchemeSel][ColBg] = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
|
else if (!strcmp(argv[i], "-f")) /* selected foreground color */
|
||||||
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];
|
||||||
@ -315,8 +257,6 @@ main(int argc, char *argv[])
|
|||||||
die("pledge");
|
die("pledge");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
readstdin();
|
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
while(1); // bodge
|
while(1); // bodge
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user