diff --git a/docs/example.Xresources b/docs/example.Xresources index eef9db5..ae38ed4 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -56,10 +56,6 @@ spmenu.col_sgrcolor15: #ffffff spmenu.globalcolors: 1 spmenu.alpha: 1 -!! Width -spmenu.accuratewidth: 1 -spmenu.borderwidth: 0 - !! Lines and columns spmenu.lineheight: 1 spmenu.lines: 0 @@ -73,6 +69,7 @@ spmenu.histdup: 0 !! Matches spmenu.type: 1 +spmenu.passwd: 0 spmenu.fuzzy: 1 spmenu.sortmatches: 1 spmenu.casesensitive: 0 @@ -81,7 +78,12 @@ spmenu.casesensitive: 0 spmenu.menuposition: 1 spmenu.menupaddingv: 0 spmenu.menupaddingh: 0 +spmenu.menuwidth: 0 +spmenu.xpos: 0 +spmenu.ypos: 0 spmenu.minwidth: 1000 +spmenu.accuratewidth: 1 +spmenu.borderwidth: 0 !! Properties spmenu.dockproperty: 1 diff --git a/docs/spmenu.conf b/docs/spmenu.conf index 5bbd29e..85840f5 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -12,6 +12,9 @@ spmenu = border = 0; paddingv = 0; paddingh = 0; + x = 0; + y = 0; + width = 0; monitor = -1; managed = 0; alpha = 1; @@ -134,6 +137,7 @@ spmenu = // Input input = ( { fast = 1; type = 1; + password = 0; } ); // Mode diff --git a/libs/argv.c b/libs/argv.c index a740106..417687a 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -209,11 +209,11 @@ readargs(int argc, char *argv[]) } else if (!strcmp(argv[i], "-H") || (!strcmp(argv[i], "--hist-file"))) // hist file location histfile = argv[++i]; else if (!strcmp(argv[i], "-x") || (!strcmp(argv[i], "--x-position"))) // window x offset - dmx = atoi(argv[++i]); + xpos = atoi(argv[++i]); else if (!strcmp(argv[i], "-y") || (!strcmp(argv[i], "--y-position"))) // window y offset (from bottom up if -b) - dmy = atoi(argv[++i]); + ypos = atoi(argv[++i]); else if (!strcmp(argv[i], "-z") || (!strcmp(argv[i], "--width"))) // make spmenu this wide - dmw = atoi(argv[++i]); + menuwidth = atoi(argv[++i]); else if (!strcmp(argv[i], "-p") || (!strcmp(argv[i], "--prompt"))) // adds prompt to left of input field prompt = argv[++i]; else if (!strcmp(argv[i], "-It") || (!strcmp(argv[i], "--input"))) // specify initial text diff --git a/libs/conf/config.c b/libs/conf/config.c index 01de95a..c60f091 100644 --- a/libs/conf/config.c +++ b/libs/conf/config.c @@ -64,6 +64,9 @@ conf_init(void) config_setting_lookup_int(conf, "position", &menuposition); // spmenu.window.menuposition config_setting_lookup_int(conf, "paddingv", &menupaddingv); // spmenu.window.paddingv config_setting_lookup_int(conf, "paddingh", &menupaddingh); // spmenu.window.paddingh + config_setting_lookup_int(conf, "x", &xpos); // spmenu.window.x + config_setting_lookup_int(conf, "y", &xpos); // spmenu.window.y + config_setting_lookup_int(conf, "width", &menuwidth); // spmenu.window.width config_setting_lookup_int(conf, "border", &borderwidth); // spmenu.window.border config_setting_lookup_int(conf, "managed", &managed); // spmenu.window.managed config_setting_lookup_int(conf, "monitor", &mon); // spmenu.window.monitor @@ -327,6 +330,7 @@ conf_init(void) // look up config_setting_lookup_int(conf, "fast", &fast); // spmenu.input.fast config_setting_lookup_int(conf, "type", &type); // spmenu.input.type + config_setting_lookup_int(conf, "password", &passwd); // spmenu.input.password } } diff --git a/libs/xresources.h b/libs/xresources.h index b064097..28319a1 100644 --- a/libs/xresources.h +++ b/libs/xresources.h @@ -52,6 +52,9 @@ ResourcePref resources[] = { { "globalcolors", INTEGER, &globalcolors }, { "coloritems", INTEGER, &coloritems }, { "menuposition", INTEGER, &menuposition }, + { "xpos", INTEGER, &xpos }, + { "ypos", INTEGER, &ypos }, + { "menuwidth", INTEGER, &menuwidth }, { "menupaddingv", INTEGER, &menupaddingv }, { "menupaddingh", INTEGER, &menupaddingh }, { "textpadding", INTEGER, &textpadding }, @@ -59,6 +62,7 @@ ResourcePref resources[] = { { "accuratewidth", INTEGER, &accuratewidth }, { "alpha", INTEGER, &alpha }, { "type", INTEGER, &type }, + { "passwd", INTEGER, &passwd }, { "minwidth", INTEGER, &minwidth }, { "preselected", INTEGER, &preselected }, { "borderwidth", INTEGER, &borderwidth }, diff --git a/options.h b/options.h index a821596..5536a2b 100644 --- a/options.h +++ b/options.h @@ -17,7 +17,10 @@ static int alpha = 1; /* Enable alpha */ static int menuposition = 1; /* Position of the menu (0: Bottom, 1: Top, 2: Center */ static int menupaddingv = 0; /* Vertical padding of bar (in pixels) */ static int menupaddingh = 0; /* Horizontal padding of bar (in pixels) */ -static int minwidth = 1000; /* Minimum width */ +static int menuwidth = 0; /* spmenu width when setting X/Y position */ +static int minwidth = 1000; /* Minimum width when centered */ +static int xpos = 0; /* X position to offset spmenu */ +static int ypos = 0; /* Y position to offset spmenu */ static int managed = 0; /* Let your window manager manage spmenu? */ /* Window properties */ @@ -52,6 +55,7 @@ static char *input = NULL; /* Default input text */ /* Match options */ static int type = 1; /* Allow typing into spmenu or only allow keybinds. */ +static int passwd = 0; /* Replace input with another character and don't read stdin */ static int sortmatches = 1; /* Sort matches (0/1) */ static int casesensitive = 0; /* Case-sensitive by default? (0/1) */ static int preselected = 0; /* Which line should spmenu preselect? */ diff --git a/spmenu.c b/spmenu.c index 2d9d9a2..bfde0c2 100644 --- a/spmenu.c +++ b/spmenu.c @@ -125,13 +125,9 @@ static int numlockmask = 0; // height of each item, menu width, menu height static int bh, mw, mh; static int reallines = 0; -static int dmx = 0; // put spmenu at this x offset -static int dmy = 0; // put spmenu at this y offset (measured from the bottom if menuposition is 0) -static unsigned int dmw = 0; // make spmenu this wide static int inputw = 0; static int promptw; static int plw = 0; -static int passwd = 0; static int lrpad; // sum of left and right padding static int vp; // vertical padding for bar static int sp; // side padding for bar @@ -587,9 +583,9 @@ setupdisplay(void) x = info[i].x_org + ((info[i].width - mw) / 2); y = info[i].y_org + ((info[i].height - mh) / 2); } else { // top or bottom - x = info[i].x_org + dmx; - y = info[i].y_org + (menuposition ? 0 : info[i].height - mh - dmy); - mw = (dmw>0 ? dmw : info[i].width); + x = info[i].x_org + xpos; + y = info[i].y_org + (menuposition ? 0 : info[i].height - mh - ypos); + mw = (menuwidth>0 ? menuwidth : info[i].width); } XFree(info);