forked from speedie/spmenu
indent lots of code using vim gg=G
This commit is contained in:
parent
fc8d12cd0a
commit
5efe236380
28
libs/arg.c
28
libs/arg.c
|
@ -344,13 +344,13 @@ out:
|
|||
}
|
||||
|
||||
void setimgsize(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
setimagesize(imagewidth + arg->i, imageheight + arg->i);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void flipimg(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
|
||||
if (!image) return;
|
||||
|
||||
|
@ -358,11 +358,11 @@ void flipimg(Arg *arg) {
|
|||
|
||||
drawmenu();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void setimgpos(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!image || hideimage) return;
|
||||
|
||||
if (imageposition < 3) {
|
||||
|
@ -372,11 +372,11 @@ void setimgpos(Arg *arg) {
|
|||
}
|
||||
|
||||
drawmenu();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void setimggaps(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
imagegaps += arg->i;
|
||||
|
||||
if (!image || hideimage) return;
|
||||
|
@ -389,32 +389,32 @@ void setimggaps(Arg *arg) {
|
|||
imagegaps -= arg->i;
|
||||
|
||||
drawmenu();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void rotateimg(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
|
||||
if (!image || hideimage) return;
|
||||
|
||||
rotation += arg->i ? arg->i : 1;
|
||||
|
||||
drawmenu();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void toggleimg(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
|
||||
hideimage = !hideimage;
|
||||
|
||||
drawmenu();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void defaultimg(Arg *arg) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
|
||||
if (hideimage || !image) return;
|
||||
|
||||
|
@ -425,7 +425,7 @@ void defaultimg(Arg *arg) {
|
|||
}
|
||||
|
||||
drawmenu();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void setlines(Arg *arg) {
|
||||
|
|
22
libs/argv.c
22
libs/argv.c
|
@ -14,7 +14,7 @@ void readargs(int argc, char *argv[]) {
|
|||
loadtheme = 1;
|
||||
} else if (!strcmp(argv[j], "-nltm") || (!strcmp(argv[j], "--no-load-theme"))) {
|
||||
loadtheme = 0;
|
||||
#if USECONFIG
|
||||
#if USECONFIG
|
||||
} else if (!strcmp(argv[j], "-cf") || (!strcmp(argv[j], "--config-file"))) { // specify a config file
|
||||
if (argv[j+1]) {
|
||||
cconf = 1;
|
||||
|
@ -29,13 +29,13 @@ void readargs(int argc, char *argv[]) {
|
|||
} else {
|
||||
die("This argument requires a second argument.\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if USECONFIG
|
||||
#if USECONFIG
|
||||
conf_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (k = 1; k < argc; k++) {
|
||||
if (!strcmp(argv[k], "-xrdb") || (!strcmp(argv[k], "--xrdb"))) {
|
||||
|
@ -51,12 +51,12 @@ void readargs(int argc, char *argv[]) {
|
|||
|
||||
// init/read xrdb
|
||||
if (xresources) {
|
||||
#if USEXRESOURCES
|
||||
#if USEXRESOURCES
|
||||
XrmInitialize();
|
||||
load_xresources();
|
||||
#else
|
||||
#else
|
||||
; // avoids a warning
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// no arguments
|
||||
|
@ -208,14 +208,14 @@ void readargs(int argc, char *argv[]) {
|
|||
|| !strcmp(argv[i], "-ngbc")
|
||||
|| !strcmp(argv[i], "--global-colors")
|
||||
|| !strcmp(argv[i], "--no-global-colors")
|
||||
#if USECONFIG
|
||||
#if USECONFIG
|
||||
|| !strcmp(argv[i], "-cf")
|
||||
|| !strcmp(argv[i], "--config-file")
|
||||
|| (argconf && !strcmp(argv[i], argconf))
|
||||
|| !strcmp(argv[i], "-tm")
|
||||
|| !strcmp(argv[i], "--theme")
|
||||
|| (argtheme && !strcmp(argv[i], argtheme))
|
||||
#endif
|
||||
#endif
|
||||
))
|
||||
continue;
|
||||
else
|
||||
|
@ -416,14 +416,14 @@ void readargs(int argc, char *argv[]) {
|
|||
|| !strcmp(argv[i], "-ngbc")
|
||||
|| !strcmp(argv[i], "--global-colors")
|
||||
|| !strcmp(argv[i], "--no-global-colors")
|
||||
#if USECONFIG
|
||||
#if USECONFIG
|
||||
|| !strcmp(argv[i], "-cf")
|
||||
|| !strcmp(argv[i], "--config-file")
|
||||
|| (argconf && !strcmp(argv[i], argconf))
|
||||
|| !strcmp(argv[i], "-tm")
|
||||
|| !strcmp(argv[i], "--theme")
|
||||
|| (argtheme && !strcmp(argv[i], argtheme))
|
||||
#endif
|
||||
#endif
|
||||
))
|
||||
continue;
|
||||
else
|
||||
|
|
|
@ -46,13 +46,13 @@ void set_prop(void) {
|
|||
void resizeclient(void) {
|
||||
int omh = mh;
|
||||
int x, y;
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
int j, di, a, n, area = 0;
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
unsigned int du;
|
||||
Window w, dw, *dws;
|
||||
#endif
|
||||
#endif
|
||||
XWindowAttributes wa;
|
||||
struct item *item;
|
||||
int itemCount = 0;
|
||||
|
@ -66,14 +66,14 @@ void resizeclient(void) {
|
|||
reallines = lines;
|
||||
|
||||
// resize client to image height
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (image) resizetoimageheight(imageheight);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mh = (lines + 1) * bh + 2 * menumarginv;
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
int i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
|
@ -115,7 +115,7 @@ void resizeclient(void) {
|
|||
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("spmenu: could not get embedding window attributes: 0x%lx",
|
||||
|
|
40
libs/draw.c
40
libs/draw.c
|
@ -38,7 +38,7 @@ drawhighlights(struct item *item, int x, int y, int w, int p)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawitemtext(struct item *item, int x, int y, int w)
|
||||
{
|
||||
char buffer[MAXITEMLENGTH]; // buffer containing item text
|
||||
|
@ -188,7 +188,7 @@ drawitemtext(struct item *item, int x, int y, int w)
|
|||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawitem(int x, int y, int w)
|
||||
{
|
||||
struct item *item;
|
||||
|
@ -210,9 +210,9 @@ drawitem(int x, int y, int w)
|
|||
if (!strcmp(capstext, ""))
|
||||
capsWidth = 0;
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
int ox = 0; // original x position
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// draw items and image
|
||||
if (lines > 0) {
|
||||
|
@ -220,12 +220,12 @@ drawitem(int x, int y, int w)
|
|||
int rx = 0;
|
||||
|
||||
// draw image first
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!hideimage && longestedge != 0) {
|
||||
rx = ox;
|
||||
rx += MAX((imagegaps * 2) + imagewidth + menumarginh, indentitems ? x : 0);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
if (!indentitems) {
|
||||
rx = 0;
|
||||
} else {
|
||||
|
@ -286,7 +286,7 @@ drawitem(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawprompt(int x, int y, int w)
|
||||
{
|
||||
if (prompt && *prompt && !hideprompt) {
|
||||
|
@ -305,7 +305,7 @@ drawprompt(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawinput(int x, int y, int w)
|
||||
{
|
||||
char *censort; // censor text (password)
|
||||
|
@ -342,7 +342,7 @@ drawinput(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawlarrow(int x, int y, int w)
|
||||
{
|
||||
if (hidelarrow) return x;
|
||||
|
@ -356,7 +356,7 @@ drawlarrow(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawrarrow(int x, int y, int w)
|
||||
{
|
||||
if (hiderarrow) return x;
|
||||
|
@ -370,7 +370,7 @@ drawrarrow(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawnumber(int x, int y, int w)
|
||||
{
|
||||
if (hidematchcount) return x;
|
||||
|
@ -395,7 +395,7 @@ drawnumber(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawmode(int x, int y, int w)
|
||||
{
|
||||
if (!hidemode) { // draw mode indicator
|
||||
|
@ -420,7 +420,7 @@ drawmode(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
drawcaps(int x, int y, int w)
|
||||
{
|
||||
if (!w) return x; // not caps lock
|
||||
|
@ -447,7 +447,7 @@ drawcaps(int x, int y, int w)
|
|||
return x;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
drawmenu(void)
|
||||
{
|
||||
int x = 0, y = 0, w = 0;
|
||||
|
@ -481,11 +481,11 @@ drawmenu(void)
|
|||
|
||||
// why have an empty line?
|
||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
) && (!image || hideimage)) {
|
||||
#else
|
||||
#else
|
||||
)) {
|
||||
#endif
|
||||
#endif
|
||||
y -= bh;
|
||||
mh = (lines + 1) * bh - bh + 2 * menumarginv;
|
||||
|
||||
|
@ -494,11 +494,11 @@ drawmenu(void)
|
|||
XResizeWindow(dpy, win, mw - 2 * sp - 2 * borderwidth, mh);
|
||||
drw_resize(drw, mw - 2 * sp - 2 * borderwidth, mh);
|
||||
}
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
else if (hideprompt && hideinput && hidemode && hidematchcount) {
|
||||
y -= bh;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!hideprompt) {
|
||||
w = promptw;
|
||||
|
@ -530,4 +530,4 @@ drawmenu(void)
|
|||
}
|
||||
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
}
|
||||
}
|
||||
|
|
12
libs/event.c
12
libs/event.c
|
@ -1,8 +1,8 @@
|
|||
void eventloop(void) {
|
||||
XEvent ev;
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
int noimg = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while (!XNextEvent(dpy, &ev)) {
|
||||
if (XFilterEvent(&ev, None))
|
||||
|
@ -16,9 +16,9 @@ void eventloop(void) {
|
|||
exit(1);
|
||||
case ButtonPress:
|
||||
buttonpress(&ev);
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
noimg = 0;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case MotionNotify: // currently does nothing
|
||||
break;
|
||||
|
@ -70,12 +70,12 @@ void eventloop(void) {
|
|||
}
|
||||
|
||||
// redraw image on X11 event
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!noimg) {
|
||||
drawimage();
|
||||
} else {
|
||||
noimg = 0; // draw it next time
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,13 +324,13 @@ void resizetoimageheight(int imageheight) {
|
|||
int wtr = 0;
|
||||
|
||||
int x, y;
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
int j, di, a, n, area = 0;
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
unsigned int du;
|
||||
Window w, dw, *dws;
|
||||
#endif
|
||||
#endif
|
||||
XWindowAttributes wa;
|
||||
|
||||
if (lines * bh < imageheight + imagegaps * 2) {
|
||||
|
@ -348,7 +348,7 @@ void resizetoimageheight(int imageheight) {
|
|||
}
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
int i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
|
@ -390,7 +390,7 @@ void resizetoimageheight(int imageheight) {
|
|||
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("spmenu: could not get embedding window attributes: 0x%lx",
|
||||
|
|
|
@ -201,12 +201,12 @@ Fnt* drw_font_create(Drw* drw, char *font[], size_t fontcount) {
|
|||
if (!drw || !font)
|
||||
return NULL;
|
||||
|
||||
#if USEPANGO
|
||||
#if USEPANGO
|
||||
Fnt *fnt = NULL;
|
||||
|
||||
fnt = xfont_create(drw, *font);
|
||||
return (drw->font = fnt);
|
||||
#else
|
||||
#else
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
||||
|
@ -217,14 +217,14 @@ Fnt* drw_font_create(Drw* drw, char *font[], size_t fontcount) {
|
|||
}
|
||||
}
|
||||
return (drw->font = ret);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void drw_font_free(Fnt *font) {
|
||||
if (font) {
|
||||
#if !USEPANGO
|
||||
#if !USEPANGO
|
||||
drw_font_free(font->next);
|
||||
#endif
|
||||
#endif
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ int xerrordummy(Display *dpy, XErrorEvent *ee) {
|
|||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) {
|
||||
XSetErrorHandler(xerrordummy);
|
||||
|
||||
#if USEPANGO // pango
|
||||
#if USEPANGO // pango
|
||||
char buf[1024];
|
||||
int ty;
|
||||
unsigned int ew = 0;
|
||||
|
@ -368,7 +368,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
|
|||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
#else // xft
|
||||
#else // xft
|
||||
char buf[1024];
|
||||
int ty;
|
||||
unsigned int ew = 0;
|
||||
|
@ -494,7 +494,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
|
|||
XSync(drw->dpy, False);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
@ -514,14 +514,14 @@ unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) {
|
|||
}
|
||||
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) {
|
||||
#if !USEPANGO
|
||||
#if !USEPANGO
|
||||
XGlyphInfo ext;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
#if USEPANGO
|
||||
#if USEPANGO
|
||||
PangoRectangle r;
|
||||
if(markup)
|
||||
pango_layout_set_markup(font->layout, text, len);
|
||||
|
@ -530,15 +530,15 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||
pango_layout_get_extents(font->layout, 0, &r);
|
||||
if(markup) // clear markup attributes
|
||||
pango_layout_set_attributes(font->layout, NULL);
|
||||
#else
|
||||
#else
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
#endif
|
||||
#endif
|
||||
if (w)
|
||||
#if USEPANGO
|
||||
#if USEPANGO
|
||||
*w = r.width / PANGO_SCALE;
|
||||
#else
|
||||
#else
|
||||
*w = ext.xOff;
|
||||
#endif
|
||||
#endif
|
||||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ typedef struct {
|
|||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
#if USEPANGO
|
||||
#if USEPANGO
|
||||
PangoLayout *layout;
|
||||
#else
|
||||
#else
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
#endif
|
||||
#endif
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg, ColPwl }; /* Clr scheme index */
|
||||
|
|
|
@ -15,6 +15,7 @@ void fuzzymatch(void) {
|
|||
itext_len = strlen(it->text);
|
||||
pidx = 0; // pointer
|
||||
sidx = eidx = -1; // start of match, end of match
|
||||
|
||||
// walk through item text
|
||||
for (i = 0; i < itext_len && (c = it->text[i]); i++) {
|
||||
// fuzzy match pattern
|
||||
|
|
|
@ -39,23 +39,23 @@ void readstdin(void) {
|
|||
o = 1;
|
||||
}
|
||||
|
||||
#if !USEIMAGE
|
||||
#if !USEIMAGE
|
||||
if (o) {
|
||||
;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!o) longestedge = imagegaps = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// clean
|
||||
if (items) {
|
||||
items[i].text = NULL;
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
items[i].image = NULL;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
inputw = items ? TEXTWM(items[imax].text) : 0;
|
||||
|
@ -119,19 +119,19 @@ void readfile(void) {
|
|||
o = 1;
|
||||
}
|
||||
|
||||
#if !USEIMAGE
|
||||
#if !USEIMAGE
|
||||
if (o) {
|
||||
;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
inputw = items ? TEXTWM(items[i].text) : 0;
|
||||
lines = columns == 1 ? i : MIN(i, lines); // i = number of items
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!o) longestedge = imagegaps = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (i == listcount) {
|
||||
listchanged = 0;
|
||||
|
@ -149,13 +149,13 @@ void readfile(void) {
|
|||
}
|
||||
|
||||
int parsemarkup(int index) {
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
int w, h;
|
||||
char *limg = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// parse image markup
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if(!strncmp("IMG:", items[index].text, strlen("IMG:"))) {
|
||||
if(!(items[index].image = malloc(strlen(items[index].text)+1)))
|
||||
fprintf(stderr, "spmenu: cannot malloc %lu bytes\n", strlen(items[index].text));
|
||||
|
@ -177,7 +177,7 @@ int parsemarkup(int index) {
|
|||
if(items[index].image) {
|
||||
limg = items[index].image;
|
||||
}
|
||||
#else // remove the data, just for convenience
|
||||
#else // remove the data, just for convenience
|
||||
char *data;
|
||||
|
||||
if(!strncmp("IMG:", items[index].text, strlen("IMG:"))) {
|
||||
|
@ -187,7 +187,7 @@ int parsemarkup(int index) {
|
|||
items[index].text += strlen("IMG:")+strlen(data)+1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* TODO: use this for something
|
||||
* current usage is not very uslful, however it's here to be used later.
|
||||
|
@ -212,13 +212,13 @@ int parsemarkup(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (limg) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ declare -a icondir
|
|||
|
||||
# TODO: mac support
|
||||
fail_mac() {
|
||||
[ -f "/usr/local/share/spmenu/allowusageonmac" ] && return
|
||||
cat << EOF
|
||||
[ -f "/usr/local/share/spmenu/allowusageonmac" ] && return
|
||||
cat << EOF
|
||||
spmenu_run currently does not support macOS due to the outdated Bash version.
|
||||
See https://spmenu.speedie.site/index.php/Using+spmenu+on+macOS for more information.
|
||||
|
||||
|
@ -134,12 +134,12 @@ path() {
|
|||
}
|
||||
|
||||
print_help() {
|
||||
if [ "$DMENU_COMPAT" != "true" ]; then
|
||||
COL='\033[0;31m'
|
||||
RUNLAUNCHER_EX_ARGS="--lines 20 --columns 1 --normal --sgr1 $HELP_COLOR --hide-cursor --no-allow-typing --no-color-items --hide-prompt --hide-powerline --hide-input --hide-right-arrow --hide-left-arrow --hide-mode --hide-match-count --hide-caps"
|
||||
read -ra rl_ex <<< "$RUNLAUNCHER_EX_ARGS"
|
||||
fi
|
||||
cat << EOF | $RUNLAUNCHER "${rl_help[@]}" "${rl_ex[@]}" > /dev/null
|
||||
if [ "$DMENU_COMPAT" != "true" ]; then
|
||||
COL='\033[0;31m'
|
||||
RUNLAUNCHER_EX_ARGS="--lines 20 --columns 1 --normal --sgr1 $HELP_COLOR --hide-cursor --no-allow-typing --no-color-items --hide-prompt --hide-powerline --hide-input --hide-right-arrow --hide-left-arrow --hide-mode --hide-match-count --hide-caps"
|
||||
read -ra rl_ex <<< "$RUNLAUNCHER_EX_ARGS"
|
||||
fi
|
||||
cat << EOF | $RUNLAUNCHER "${rl_help[@]}" "${rl_ex[@]}" > /dev/null
|
||||
Start typing in keywords to list out entries. Press Enter to select an entry. The selected entry will be run through a shell.
|
||||
To set spmenu options, you pass arguments to 'spmenu_run' directly. See 'spmenu --help' for a list of valid arguments.
|
||||
To configure spmenu, you may also copy ${DESTDIR}${PREFIX}/share/spmenu/example.Xresources to $CONFDIR/spmenu/spmenurc and edit that.
|
||||
|
@ -155,7 +155,7 @@ EOF
|
|||
}
|
||||
|
||||
print_cli_help() {
|
||||
cat << EOF
|
||||
cat << EOF
|
||||
spmenu_run - Run launcher for spmenu
|
||||
|
||||
spmenu_run -x, --run List entries in \$PATH.
|
||||
|
@ -174,9 +174,9 @@ EOF
|
|||
}
|
||||
|
||||
print_config() {
|
||||
[ -f "$CONFDIR/spmenu/run/config" ] && . "$CONFDIR/spmenu/run/config" && return
|
||||
mkdir -p "$CONFDIR/spmenu/run"
|
||||
cat << EOF > "$CONFDIR/spmenu/run/config"
|
||||
[ -f "$CONFDIR/spmenu/run/config" ] && . "$CONFDIR/spmenu/run/config" && return
|
||||
mkdir -p "$CONFDIR/spmenu/run"
|
||||
cat << EOF > "$CONFDIR/spmenu/run/config"
|
||||
# spmenu_run default configuration file
|
||||
#
|
||||
# This is the configuration file for the run launcher spmenu comes with.
|
||||
|
@ -453,12 +453,12 @@ prepare_dirnav() {
|
|||
}
|
||||
|
||||
print_desktop_help() {
|
||||
if [ "$DMENU_COMPAT" != "true" ]; then
|
||||
COL='\033[0;31m'
|
||||
RUNLAUNCHER_EX_ARGS="--lines 20 --columns 1 --normal --sgr1 $HELP_COLOR --hide-cursor --hide-caps --no-allow-typing --no-color-items --hide-prompt --hide-powerline --hide-input --hide-right-arrow --hide-left-arrow --hide-mode --hide-match-count"
|
||||
read -ra rl_ex <<< "${RUNLAUNCHER_EX_ARGS}"
|
||||
fi
|
||||
cat << EOF | $RUNLAUNCHER "${rl_help[@]}" "${rl_ex[@]}" > /dev/null
|
||||
if [ "$DMENU_COMPAT" != "true" ]; then
|
||||
COL='\033[0;31m'
|
||||
RUNLAUNCHER_EX_ARGS="--lines 20 --columns 1 --normal --sgr1 $HELP_COLOR --hide-cursor --hide-caps --no-allow-typing --no-color-items --hide-prompt --hide-powerline --hide-input --hide-right-arrow --hide-left-arrow --hide-mode --hide-match-count"
|
||||
read -ra rl_ex <<< "${RUNLAUNCHER_EX_ARGS}"
|
||||
fi
|
||||
cat << EOF | $RUNLAUNCHER "${rl_help[@]}" "${rl_ex[@]}" > /dev/null
|
||||
Start typing in keywords to list out entries. Press Enter to select an entry. The selected entry will be run through a shell.
|
||||
To set spmenu options, you modify \$RUNLAUNCHER_ARGS in the config. See 'spmenu --help' for a list of valid arguments to add to the variable.
|
||||
To configure spmenu itself, you may copy ${DESTDIR}${PREFIX}/share/spmenu.conf to ~/.config/spmenu/spmenu.conf.
|
||||
|
|
|
@ -46,39 +46,39 @@ command -v maim > /dev/null && maim -uB > /tmp/image.png
|
|||
IMAGE="/tmp/image.png"
|
||||
|
||||
main() {
|
||||
[ -e "$IMAGE" ] && IMAGEARG="--image-size 500 --no-generate-cache" && IMAGEPREFIX="IMG:" || IMAGE=""
|
||||
[ -e "$IMAGE" ] && IMAGEARG="--image-size 500 --no-generate-cache" && IMAGEPREFIX="IMG:" || IMAGE=""
|
||||
|
||||
printf "$IMAGEPREFIX$IMAGE\t${v2}s${v3}p${v4}m${v5}e${v6}n${v7}u${v8} $([ -f "${DESTDIR}${PREFIX}/share/spmenu/version" ] && cat "${DESTDIR}${PREFIX}/share/spmenu/version")\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b1}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b2}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b3}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b4}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b5}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b6}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b7}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b8}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b9}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b10}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b11}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b12}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b13}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b14}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b15}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b16}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${v1}q${v2}w${v3}e${v4}r${v5}t${v6}y${v7}u${v8}i${v9}o${v10}p${v11}[${v12}]${v13}a${v14}s${v15}d${v16}f\n\
|
||||
$IMAGEPREFIX$IMAGE\t<b>qwertyuiop[]asdf</b> - b\n\
|
||||
$IMAGEPREFIX$IMAGE\t<i>qwertyuiop[]asdf</i> - i\n\
|
||||
$IMAGEPREFIX$IMAGE\t<s>qwertyuiop[]asdf</s> - s\n\
|
||||
$IMAGEPREFIX$IMAGE\t<u>qwertyuiop[]asdf</u> - u\n\
|
||||
$IMAGEPREFIX$IMAGE\t<sub>qwertyuiop[]asdf - sub</sub>\n\
|
||||
$IMAGEPREFIX$IMAGE\t<sup>qwertyuiop[]asdf - sup</sup>\n\
|
||||
$IMAGEPREFIX$IMAGE\t<tt>qwertyuiop[]asdf</tt> - tt\n\
|
||||
$IMAGEPREFIX$IMAGE\t<small>qwertyuiop[]asdf</small> - small\n\
|
||||
$IMAGEPREFIX$IMAGE\t<big>qwertyuiop[]asdf</big> - big\n\
|
||||
$IMAGEPREFIX$IMAGE\t\n\
|
||||
$IMAGEPREFIX$IMAGE\tArguments will be passed to spmenu.\n\
|
||||
$IMAGEPREFIX$IMAGE\tReport any issues at the Codeberg repo.\n\
|
||||
" | spmenu --no-alpha --lines 40 $IMAGEARG "$@" --columns 1 --prompt "<big>spmenu <i>test</i> <small>script</small></big>"
|
||||
}
|
||||
printf "$IMAGEPREFIX$IMAGE\t${v2}s${v3}p${v4}m${v5}e${v6}n${v7}u${v8} $([ -f "${DESTDIR}${PREFIX}/share/spmenu/version" ] && cat "${DESTDIR}${PREFIX}/share/spmenu/version")\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b1}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b2}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b3}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b4}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b5}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b6}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b7}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b8}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b9}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b10}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b11}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b12}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b13}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b14}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b15}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${b16}\n\
|
||||
$IMAGEPREFIX$IMAGE\t${v1}q${v2}w${v3}e${v4}r${v5}t${v6}y${v7}u${v8}i${v9}o${v10}p${v11}[${v12}]${v13}a${v14}s${v15}d${v16}f\n\
|
||||
$IMAGEPREFIX$IMAGE\t<b>qwertyuiop[]asdf</b> - b\n\
|
||||
$IMAGEPREFIX$IMAGE\t<i>qwertyuiop[]asdf</i> - i\n\
|
||||
$IMAGEPREFIX$IMAGE\t<s>qwertyuiop[]asdf</s> - s\n\
|
||||
$IMAGEPREFIX$IMAGE\t<u>qwertyuiop[]asdf</u> - u\n\
|
||||
$IMAGEPREFIX$IMAGE\t<sub>qwertyuiop[]asdf - sub</sub>\n\
|
||||
$IMAGEPREFIX$IMAGE\t<sup>qwertyuiop[]asdf - sup</sup>\n\
|
||||
$IMAGEPREFIX$IMAGE\t<tt>qwertyuiop[]asdf</tt> - tt\n\
|
||||
$IMAGEPREFIX$IMAGE\t<small>qwertyuiop[]asdf</small> - small\n\
|
||||
$IMAGEPREFIX$IMAGE\t<big>qwertyuiop[]asdf</big> - big\n\
|
||||
$IMAGEPREFIX$IMAGE\t\n\
|
||||
$IMAGEPREFIX$IMAGE\tArguments will be passed to spmenu.\n\
|
||||
$IMAGEPREFIX$IMAGE\tReport any issues at the Codeberg repo.\n\
|
||||
" | spmenu --no-alpha --lines 40 $IMAGEARG "$@" --columns 1 --prompt "<big>spmenu <i>test</i> <small>script</small></big>"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
main "$@"
|
||||
|
|
40
spmenu.c
40
spmenu.c
|
@ -163,9 +163,9 @@ static int screen;
|
|||
struct item {
|
||||
char *text;
|
||||
char *clntext;
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
char *image;
|
||||
#endif
|
||||
#endif
|
||||
char *ex;
|
||||
struct item *left, *right;
|
||||
int hp;
|
||||
|
@ -360,9 +360,9 @@ int max_textw(void) {
|
|||
void cleanup(void) {
|
||||
size_t i;
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
cleanupimage(); // function frees images
|
||||
#endif
|
||||
#endif
|
||||
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root); // ungrab keys
|
||||
|
||||
|
@ -517,9 +517,9 @@ void xinitvisual(void) {
|
|||
|
||||
void setupdisplay(void) {
|
||||
int x, y, i;
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
int j, di;
|
||||
#endif
|
||||
#endif
|
||||
unsigned int du;
|
||||
unsigned int tmp, minstrlen = 0, curstrlen = 0;
|
||||
int numwidthchecks = 100;
|
||||
|
@ -527,11 +527,11 @@ void setupdisplay(void) {
|
|||
XIM xim;
|
||||
Window w, dw, *dws;
|
||||
XWindowAttributes wa;
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
int a, n, area = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
init_appearance(); // init colorschemes by reading arrays
|
||||
|
||||
|
@ -547,9 +547,9 @@ void setupdisplay(void) {
|
|||
reallines = lines;
|
||||
|
||||
// resize client to image height if deemed necessary
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (image) resizetoimageheight(imageheight);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mh = (lines + 1) * bh + 2 * menumarginv; // lines + 1 * bh is the menu height
|
||||
|
||||
|
@ -574,7 +574,7 @@ void setupdisplay(void) {
|
|||
}
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
#if USEXINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
|
@ -613,7 +613,7 @@ void setupdisplay(void) {
|
|||
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("spmenu: could not get embedding window attributes: 0x%lx",
|
||||
|
@ -640,9 +640,9 @@ void setupdisplay(void) {
|
|||
set_window();
|
||||
set_prop();
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
setimageopts();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// input methods
|
||||
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
|
||||
|
@ -687,9 +687,9 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
readargs(argc, argv); // start by reading arguments
|
||||
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
longestedge = MAX(imagewidth, imageheight);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!type) {
|
||||
mode = 0;
|
||||
|
@ -740,10 +740,10 @@ int main(int argc, char *argv[]) {
|
|||
prepare_window_size(); // this function sets padding size
|
||||
|
||||
// pledge limits what programs can do, so here we specify what spmenu should be allowed to do
|
||||
#ifdef __OpenBSD__
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath wpath cpath", NULL) == -1)
|
||||
die("pledge");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
loadhistory(); // read history entries
|
||||
|
||||
|
@ -757,13 +757,13 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// set default values
|
||||
#if USEIMAGE
|
||||
#if USEIMAGE
|
||||
if (!imagew || !imageh || !imageg) {
|
||||
imagew = imagewidth;
|
||||
imageh = imageheight;
|
||||
imagegaps = imagegaps;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
setupdisplay(); // set up display and create window
|
||||
eventloop(); // function is a loop which checks X11 events and calls other functions accordingly
|
||||
|
|
Loading…
Reference in a new issue