mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Add a function that adds an entry to a menuq, normalizing a common code
path; from Tiago Cunha.
This commit is contained in:
17
menu.c
17
menu.c
@@ -25,6 +25,7 @@
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -604,6 +605,22 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
menuq_add(struct menu_q *mq, void *ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
struct menu *mi;
|
||||
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
mi->ctx = ctx;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)vsnprintf(mi->text, sizeof(mi->text), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
TAILQ_INSERT_TAIL(mq, mi, entry);
|
||||
}
|
||||
|
||||
void
|
||||
menuq_clear(struct menu_q *mq)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user