add the ability to enable/disable powerline for each powerlined part,

and also allow styling them
This commit is contained in:
speedie 2023-04-07 21:20:43 +02:00
parent 073b38faac
commit 9e2d297742
7 changed files with 72 additions and 11 deletions

View file

@ -52,6 +52,14 @@ spmenu.col_sgrcolor13: #ff00ff
spmenu.col_sgrcolor14: #00ffff spmenu.col_sgrcolor14: #00ffff
spmenu.col_sgrcolor15: #ffffff spmenu.col_sgrcolor15: #ffffff
!! Powerline
spmenu.powerlineprompt: 1
spmenu.powerlinecount: 1
spmenu.powerlinemode: 1
spmenu.promptpwlstyle: 0
spmenu.matchcountpwlstyle: 0
spmenu.modepwlstyle: 0
!! Misc color !! Misc color
spmenu.globalcolors: 1 spmenu.globalcolors: 1
spmenu.alpha: 1 spmenu.alpha: 1

View file

@ -82,6 +82,15 @@ spmenu =
coloritems = 1; coloritems = 1;
} ); } );
// Powerline options
powerline = ( { promptstyle = 0;
matchcountstyle = 0;
modestyle = 0;
prompt = 1;
matchcount = 1;
mode = 1;
} );
// Hide options // Hide options
hide = ( { input = 0; hide = ( { input = 0;
larrow = 0; larrow = 0;

View file

@ -100,6 +100,26 @@ conf_init(void)
} }
} }
// load options spmenu.powerline
setting = config_lookup(&cfg, "spmenu.powerline");
if (setting != NULL) {
unsigned int i = 0;
conflength = config_setting_length(setting);
for (i = 0; i < conflength; ++i) {
config_setting_t *conf = config_setting_get_elem(setting, i);
// look up
config_setting_lookup_int(conf, "promptstyle", &promptpwlstyle); // spmenu.powerline.promptstyle
config_setting_lookup_int(conf, "matchcountstyle", &matchcountpwlstyle); // spmenu.powerline.matchcountstyle
config_setting_lookup_int(conf, "modestyle", &modepwlstyle); // spmenu.powerline.modestyle
config_setting_lookup_int(conf, "prompt", &powerlineprompt); // spmenu.powerline.prompt
config_setting_lookup_int(conf, "matchcount", &powerlinecount); // spmenu.powerline.matchcount
config_setting_lookup_int(conf, "mode", &powerlinemode); // spmenu.powerline.mode
}
}
// load options spmenu.center // load options spmenu.center
setting = config_lookup(&cfg, "spmenu.center"); setting = config_lookup(&cfg, "spmenu.center");
if (setting != NULL) { if (setting != NULL) {

View file

@ -252,9 +252,9 @@ drawprompt(int x, int y, int w)
x = drw_text(drw, x, y, w, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False); x = drw_text(drw, x, y, w, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False);
if (!hidepowerline) { if (!hidepowerline && powerlineprompt) {
drw_settrans(drw, scheme[SchemePrompt], scheme[SchemeMenu]); drw_settrans(drw, scheme[SchemePrompt], scheme[SchemeMenu]);
drw_arrow(drw, x, y, plw, bh, 1, 0); drw_arrow(drw, x, y, plw, bh, 1, promptpwlstyle);
x += plw; x += plw;
} }
@ -333,14 +333,19 @@ drawnumber(int x, int y, int w)
{ {
if (hidematchcount) return x; if (hidematchcount) return x;
drw_setscheme(drw, scheme[SchemeNumber]); int powerlinewidth = 0;
drw_text(drw, x, y, w, bh, lrpad / 2 + plw / 2, numbers, 0, pango_numbers ? True : False); if (!hidepowerline && powerlinecount) {
powerlinewidth = plw / 2;
}
drw_setscheme(drw, scheme[SchemeNumber]);
drw_text(drw, x, y, w, bh, lrpad / 2 + powerlinewidth, numbers, 0, pango_numbers ? True : False);
// draw powerline for match count // draw powerline for match count
if (!hidepowerline) { if (!hidepowerline && powerlinecount) {
drw_settrans(drw, scheme[SchemeNumber], scheme[SchemeMenu]); drw_settrans(drw, scheme[SchemeNumber], scheme[SchemeMenu]);
drw_arrow(drw, x, y, plw, bh, 0, 0); drw_arrow(drw, x, y, plw, bh, 0, matchcountpwlstyle);
x += plw; x += plw;
} }
@ -352,14 +357,19 @@ int
drawmode(int x, int y, int w) drawmode(int x, int y, int w)
{ {
if (!hidemode) { // draw mode indicator if (!hidemode) { // draw mode indicator
drw_setscheme(drw, scheme[SchemeMode]); int powerlinewidth = 0;
drw_text(drw, x, y, w, bh, lrpad / 2 + plw / 2, modetext, 0, pango_mode ? True : False); if (!hidepowerline && powerlinemode) {
powerlinewidth = plw / 2;
}
drw_setscheme(drw, scheme[SchemeMode]);
drw_text(drw, x, y, w, bh, lrpad / 2 + powerlinewidth, modetext, 0, pango_mode ? True : False);
// draw powerline for match count // draw powerline for match count
if (!hidepowerline) { if (!hidepowerline && powerlinemode) {
drw_settrans(drw, scheme[SchemeMode], hidematchcount ? scheme[SchemeMenu] : scheme[SchemeNumber]); drw_settrans(drw, scheme[SchemeMode], hidematchcount ? scheme[SchemeMenu] : scheme[SchemeNumber]);
drw_arrow(drw, x, y, plw, bh, 0, 0); drw_arrow(drw, x, y, plw, bh, 0, modepwlstyle);
x += plw; x += plw;
} }

View file

@ -83,7 +83,7 @@ buttonpress(XEvent *e)
click = clickwindow; click = clickwindow;
// check if we clicked on the prompt or the input // check if we clicked on the prompt or the input
if (ev->x < x + promptw + plw) { if (ev->x < x + promptw + powerlineprompt ? plw : 0) {
click = clickprompt; click = clickprompt;
} else if (ev->x > mw - modeWidth - 2 * sp - 2 * borderwidth) { } else if (ev->x > mw - modeWidth - 2 * sp - 2 * borderwidth) {
click = clickmode; click = clickmode;

View file

@ -48,6 +48,12 @@ ResourcePref resources[] = {
{ "col_sgrcolor15", STRING, &col_sgrcolor15 }, { "col_sgrcolor15", STRING, &col_sgrcolor15 },
// General options // General options
{ "promptpwlstyle", INTEGER, &promptpwlstyle },
{ "matchcountpwlstyle", INTEGER, &matchcountpwlstyle },
{ "modepwlstyle", INTEGER, &modepwlstyle },
{ "powerlineprompt", INTEGER, &powerlineprompt },
{ "powerlinecount", INTEGER, &powerlinecount },
{ "powerlinemode", INTEGER, &powerlinemode },
{ "dockproperty", INTEGER, &dockproperty }, { "dockproperty", INTEGER, &dockproperty },
{ "globalcolors", INTEGER, &globalcolors }, { "globalcolors", INTEGER, &globalcolors },
{ "coloritems", INTEGER, &coloritems }, { "coloritems", INTEGER, &coloritems },

View file

@ -23,6 +23,14 @@ static int xpos = 0; /* X position to offset spmenu */
static int ypos = 0; /* Y position to offset spmenu */ static int ypos = 0; /* Y position to offset spmenu */
static int managed = 0; /* Let your window manager manage spmenu? */ static int managed = 0; /* Let your window manager manage spmenu? */
/* Powerline options */
static int powerlineprompt = 0; /* Enable powerline for the prompt */
static int powerlinecount = 0; /* Enable powerline for the match count */
static int powerlinemode = 0; /* Enable powerline for the mode indicator */
static int promptpwlstyle = 0; /* Prompt powerline style (0: >, 1: \) */
static int matchcountpwlstyle = 0; /* Match count powerline style (0: <, 1: /) */
static int modepwlstyle = 0; /* Mode indicator powerline style (0: <, 1: /) */
/* Window properties */ /* Window properties */
static int dockproperty = 1; /* Set _NET_WM_WINDOW_TYPE_DOCK */ static int dockproperty = 1; /* Set _NET_WM_WINDOW_TYPE_DOCK */