add some arguments for the mode feature

This commit is contained in:
speedie 2023-02-26 05:44:48 +01:00
parent b94365f88c
commit 2d4b2fb00f
5 changed files with 39 additions and 4 deletions

View file

@ -64,3 +64,6 @@ spmenu.imagesize: 86
spmenu.imagegaps: 0 spmenu.imagegaps: 0
spmenu.imageposition: 0 spmenu.imageposition: 0
spmenu.generatecache: 0 spmenu.generatecache: 0
spmenu.mode: 1
spmenu.normtext: Normal
spmenu.instext: Insert

View file

@ -5,9 +5,9 @@ switchmode(const Arg *arg)
allowkeys = !selkeys; allowkeys = !selkeys;
if (!selkeys) { if (!selkeys) {
strcpy(modetext, "Normal"); strcpy(modetext, normtext);
} else { } else {
strcpy(modetext, "Insert"); strcpy(modetext, instext);
} }
if (hidemode) strcpy(modetext, ""); if (hidemode) strcpy(modetext, "");

View file

@ -21,6 +21,11 @@ static int imagegaps = 0; /* Image gaps */
static int imageposition = 0; /* Image position (0: Top, 1: Bottom, 2: Center, 3: Top center) */ static int imageposition = 0; /* Image position (0: Top, 1: Bottom, 2: Center, 3: Top center) */
static int generatecache = 0; /* Generate image cache by default */ static int generatecache = 0; /* Generate image cache by default */
/* Mode options */
static int mode = 1; /* Mode to start speedwm in (0: Normal mode, 1: Insert mode) */
static char normtext[] = "Normal"; /* Text to display for normal mode */
static char instext[] = "Insert"; /* Text to display for insert mode */
/* Color support */ /* Color support */
static int colorsupport = 1; /* Support 256 colors? Otherwise the default 16 colors will be used. */ static int colorsupport = 1; /* Support 256 colors? Otherwise the default 16 colors will be used. */

View file

@ -1761,9 +1761,13 @@ usage(void)
"spmenu -y <y offset> Offset spmenu y position by <y offset>\n" "spmenu -y <y offset> Offset spmenu y position by <y offset>\n"
"spmenu -n <line> Preselect <line> in the list of items\n" "spmenu -n <line> Preselect <line> in the list of items\n"
"spmenu -z <width> Width of the spmenu window\n" "spmenu -z <width> Width of the spmenu window\n"
"spmenu -nmt <text> Set normal mode text to <text>\n"
"spmenu -imt <text> Set insert mode text to <text>\n"
"spmenu -bw Width of the border. 0 will disable the border\n" "spmenu -bw Width of the border. 0 will disable the border\n"
"spmenu -s Use case-sensitive matching\n" "spmenu -s Use case-sensitive matching\n"
"spmenu -i Use case-insensitive matching\n" "spmenu -i Use case-insensitive matching\n"
"spmenu -nm Start spmenu in normal mode\n"
"spmenu -im Start spmenu in insert mode\n"
"spmenu -t Position spmenu at the top of the screen\n" "spmenu -t Position spmenu at the top of the screen\n"
"spmenu -b Position spmenu at the bottom of the screen\n" "spmenu -b Position spmenu at the bottom of the screen\n"
"spmenu -c Position spmenu at the center of the screen\n" "spmenu -c Position spmenu at the center of the screen\n"
@ -1785,7 +1789,7 @@ usage(void)
"spmenu -it Position the image at the top\n" "spmenu -it Position the image at the top\n"
"spmenu -ib Position the image at the bottom\n" "spmenu -ib Position the image at the bottom\n"
"spmenu -ic Position the image in the center\n" "spmenu -ic Position the image in the center\n"
"spmenu -itc Position the image in the top center\n" "spmenu -itc Position the image in the top center\n"
"spmenu -wm Spawn spmenu as a window manager controlled client/window. Useful for testing\n" "spmenu -wm Spawn spmenu as a window manager controlled client/window. Useful for testing\n"
"spmenu -v Print spmenu version to stdout\n" "spmenu -v Print spmenu version to stdout\n"
"\n", stdout); "\n", stdout);
@ -1886,6 +1890,10 @@ main(int argc, char *argv[])
menuposition = 0; menuposition = 0;
} else if (!strcmp(argv[i], "-t")) { /* appears at the top of the screen */ } else if (!strcmp(argv[i], "-t")) { /* appears at the top of the screen */
menuposition = 1; menuposition = 1;
} else if (!strcmp(argv[i], "-nm")) { /* normal mode */
mode = 0;
} else if (!strcmp(argv[i], "-im")) { /* insert mode */
mode = 1;
} else if (!strcmp(argv[i], "-c")) { /* appears at the center of the screen */ } else if (!strcmp(argv[i], "-c")) { /* appears at the center of the screen */
centered = 1; centered = 1;
} else if (!strcmp(argv[i], "-f")) { /* grabs keyboard before reading stdin */ } else if (!strcmp(argv[i], "-f")) { /* grabs keyboard before reading stdin */
@ -1969,8 +1977,12 @@ main(int argc, char *argv[])
dmw = atoi(argv[++i]); dmw = 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 */
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 */
strcpy(font, argv[++i]); /* font[0] = argv[++i]; */ strcpy(font, argv[++i]); /* font[0] = argv[++i]; */
else if (!strcmp(argv[i], "-nmt")) /* normal mode text */
strcpy(normtext, argv[++i]);
else if (!strcmp(argv[i], "-imt")) { /* insert mode text */
strcpy(instext, argv[++i]);
/* dmenu compatibility options */ /* dmenu compatibility options */
} else if (!strcmp(argv[i], "-nb")) { /* normal background color */ } else if (!strcmp(argv[i], "-nb")) { /* normal background color */
@ -2071,6 +2083,18 @@ main(int argc, char *argv[])
else else
usage(); usage();
if (mode) {
selkeys = 1;
allowkeys = !selkeys;
strcpy(modetext, instext);
} else {
selkeys = 0;
allowkeys = !selkeys;
strcpy(modetext, normtext);
}
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr); fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL))) if (!(dpy = XOpenDisplay(NULL)))

View file

@ -102,6 +102,8 @@ ResourcePref resources[] = {
{ "class", STRING, &class }, { "class", STRING, &class },
{ "leftarrow", STRING, &leftarrow }, { "leftarrow", STRING, &leftarrow },
{ "rightarrow", STRING, &rightarrow }, { "rightarrow", STRING, &rightarrow },
{ "normtext", STRING, &normtext },
{ "instext", STRING, &instext },
{ "bordercentered", INTEGER, &bordercentered }, { "bordercentered", INTEGER, &bordercentered },
{ "borderwidth", INTEGER, &borderwidth }, { "borderwidth", INTEGER, &borderwidth },
{ "lines", INTEGER, &lines }, { "lines", INTEGER, &lines },
@ -117,4 +119,5 @@ ResourcePref resources[] = {
{ "imagegaps", INTEGER, &imagegaps }, { "imagegaps", INTEGER, &imagegaps },
{ "imageposition", INTEGER, &imageposition }, { "imageposition", INTEGER, &imageposition },
{ "generatecache", INTEGER, &generatecache }, { "generatecache", INTEGER, &generatecache },
{ "mode", INTEGER, &mode },
}; };