add an option to display SGR sequences as plain text

This commit is contained in:
speedie 2023-04-20 19:16:16 +02:00
parent 64e0334b62
commit a2c28dbfdd
7 changed files with 14 additions and 8 deletions

View file

@ -83,7 +83,6 @@ spmenu.alpha_caretfgbg: 200
spmenu.alpha_modefg: 255
spmenu.alpha_modebg: 200
!! Powerline
spmenu.powerlineprompt: 1
spmenu.powerlinecount: 1
@ -135,6 +134,7 @@ spmenu.fast: 0
spmenu.managed: 0
spmenu.mon: -1
spmenu.coloritems: 1
spmenu.sgr: 1
!! Image
spmenu.imagewidth: 200

View file

@ -83,6 +83,7 @@ spmenu =
sgr14 = "#00ffff";
sgr15 = "#ffffff";
coloritems = 1;
sgr = 1;
} );
// Alpha options

View file

@ -367,6 +367,7 @@ conf_init(void)
// coloritems int
config_setting_lookup_int(conf, "coloritems", &coloritems);
config_setting_lookup_int(conf, "sgr", &sgr);
}
}

View file

@ -73,7 +73,7 @@ drawitemtext(struct item *item, int x, int y, int w)
for (wr = 0, rd = 0; item->text[rd]; rd++) {
if (item->text[rd] == '' && item->text[rd + 1] == '[') {
size_t alen = strspn(item->text + rd + 2, "0123456789;");
if (item->text[rd + alen + 2] == 'm') { // last character in sequence is always 'm'
if (item->text[rd + alen + 2] == 'm' && sgr) { // last character in sequence is always 'm'
buffer[wr] = '\0';
if (!lines) {

View file

@ -88,6 +88,7 @@ ResourcePref resources[] = {
{ "dockproperty", INTEGER, &dockproperty },
{ "globalcolors", INTEGER, &globalcolors },
{ "coloritems", INTEGER, &coloritems },
{ "sgr", INTEGER, &sgr },
{ "menuposition", INTEGER, &menuposition },
{ "xpos", INTEGER, &xpos },
{ "ypos", INTEGER, &ypos },

View file

@ -210,4 +210,5 @@ static int pango_password = 0; /* Enable support for pango markup f
/* Misc */
static int coloritems = 1; /* Color items or not */
static int sgr = 1; /* Support SGR sequences or not */
static char *worddelimiters = " "; /* Word delimiters used for keybinds that change words, " " is default. */

View file

@ -1,7 +1,9 @@
/* spmenu dmenu theme
*
* This config should match vanilla dmenu as closely as possible. I am unable to tell the difference between the two. It should be noted though that SGR sequences are still displayed, so for this reason I've set them all to white.
* Also note that this config disables .Xresources, you can reenable it below if you want.
*
* Also note that this config disables .Xresources, Pango and SGR sequence support, you can reenable it below if you want.
* For perfect dmenu compatibility, you may want to remap keybindings, making sure all of them work in "any mode".
*/
spmenu = {
@ -65,6 +67,7 @@ spmenu = {
sgr14 = "#bbbbbb";
sgr15 = "#bbbbbb";
coloritems = 1;
sgr = 0;
} );
// Alpha options
@ -134,11 +137,10 @@ spmenu = {
} );
// Pango
// For perfect dmenu compatibility, you may want to disable pango
pango = ( { item = 1;
highlight = 1;
prompt = 1;
input = 1;
pango = ( { item = 0;
highlight = 0;
prompt = 0;
input = 0;
leftarrow = 0;
rightarrow = 0;
numbers = 0;