Add powerline for items

Currently does not work with !lines, and as such it has been disabled
for the time being.
This commit is contained in:
speedie 2023-06-18 18:05:42 +02:00
parent 3b10355e5a
commit aa62ca8cdd
8 changed files with 34 additions and 4 deletions

View file

@ -104,10 +104,12 @@ spmenu.powerlineprompt: 1
spmenu.powerlinecount: 1
spmenu.powerlinemode: 1
spmenu.powerlinecaps: 1
spmenu.powerlineitems: 1
spmenu.promptpwlstyle: 2
spmenu.matchcountpwlstyle: 2
spmenu.modepwlstyle: 2
spmenu.capspwlstyle: 2
spmenu.itempwlstyle: 2
!! Misc color
spmenu.globalcolors: 1

View file

@ -144,10 +144,12 @@ spmenu = {
matchcountstyle = 2; // Match count powerline style (0: <, 1: /, 2: ()
modestyle = 2; // Mode indicator powerline style (0: <, 1: /, 2: ()
capsstyle = 2; // Caps lock indicator powerline style (0: <, 1: /, 2: ()
itemstyle = 2; // Item powerline style (0: <, 1: /, 2: ()
prompt = 1; // Enable prompt powerline (0/1)
matchcount = 1; // Enable match count powerline (0/1)
mode = 1; // Enable mode indicator powerline (0/1)
caps = 1; // Enable caps lock indicator powerline (0/1)
item = 1; // Enable item powerline (0/1)
} );
/* Hide options */

View file

@ -108,10 +108,12 @@ void conf_init(void) {
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, "capsstyle", &capspwlstyle); // spmenu.powerline.capsstyle
config_setting_lookup_int(conf, "itemstyle", &itempwlstyle); // spmenu.powerline.itemstyle
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
config_setting_lookup_int(conf, "caps", &powerlinecaps); // spmenu.powerline.caps
config_setting_lookup_int(conf, "item", &powerlineitems); // spmenu.powerline.item
}
}

View file

@ -92,6 +92,7 @@ int drawitemtext(struct item *item, int x, int y, int w) {
}
if (is_selected(item->index)) {
selitem = 1;
bgcol = col_itemmarkedbg;
fgcol = col_itemmarkedfg;
fga = alpha_itemmarkedfg;
@ -115,6 +116,14 @@ int drawitemtext(struct item *item, int x, int y, int w) {
fga = itemn ? alpha_itemnormfg2 : alpha_itemnormfg;
}
if (!hidepowerline && powerlineitems && selitem && lines > 0) {
if (itempwlstyle == 2) {
drw_circle(drw, x - plw, y, plw, bh, 0, col_menu, bgcol, alpha_menu, bga);
} else {
drw_arrow(drw, x - plw, y, plw, bh, 0, itempwlstyle, col_menu, bgcol, alpha_menu, bga);
}
}
// parse item text
for (wr = 0, rd = 0; item->text[rd]; rd++) {
if (item->text[rd] == '' && item->text[rd + 1] == '[') {
@ -215,6 +224,7 @@ int drawitemtext(struct item *item, int x, int y, int w) {
}
if (is_selected(item->index)) {
selitem = 1;
bgcol = col_itemmarkedbg;
fgcol = col_itemmarkedfg;
fga = alpha_itemmarkedfg;
@ -252,6 +262,14 @@ int drawitemtext(struct item *item, int x, int y, int w) {
item->clntext = malloc(sizeof(buffer));
memcpy(item->clntext, buffer, sizeof(buffer));
if (!hidepowerline && powerlineitems && selitem && lines > 0) {
if (itempwlstyle == 2) {
drw_circle(drw, r, y, plw, bh, 1, col_menu, bgcol, alpha_menu, bga);
} else {
drw_arrow(drw, r, y, plw, bh, 1, itempwlstyle, col_menu, bgcol, alpha_menu, bga);
}
}
return r;
}
@ -303,10 +321,10 @@ int drawitem(int x, int y, int w) {
for (item = curr; item != next; item = item->right, i++) {
x = drawitemtext(
item,
rx + ((i / lines) * ((mw - rx) / columns)),
rx + ((i / lines) * ((mw - rx) / columns)) + (powerlineitems ? plw : 0),
y + (((i % lines) + 1) * bh),
(mw - rx) / columns
);
(mw - rx) / columns - (powerlineitems ? 2 * plw : 0)
);
if (item == sel && itemoverride) {
itemnumber = i;

View file

@ -40,10 +40,12 @@ static int powerlineprompt = 1; /* Enable powerline for the prompt *
static int powerlinecount = 1; /* Enable powerline for the match count */
static int powerlinemode = 1; /* Enable powerline for the mode indicator */
static int powerlinecaps = 1; /* Enable powerline for the caps lock indicator */
static int powerlineitems = 1; /* Enable powerline for the items */
static int promptpwlstyle = 2; /* Prompt powerline style (0: >, 1: \, 2: )) */
static int matchcountpwlstyle = 2; /* Match count powerline style (0: <, 1: /, 2: () */
static int modepwlstyle = 2; /* Mode indicator powerline style (0: <, 1: /, 2: () */
static int capspwlstyle = 2; /* Caps lock indicator powerline style (0: <, 1: /, 2: () */
static int itempwlstyle = 2; /* Item powerline style (0: <>, 1: /\, 2: ()) */
/* Window properties */
static int dockproperty = 1; /* Set _NET_WM_WINDOW_TYPE_DOCK */

View file

@ -98,10 +98,12 @@ void theme_load(void) {
config_setting_lookup_int(conf, "matchcountstyle", &matchcountpwlstyle); // theme.powerline.matchcountstyle
config_setting_lookup_int(conf, "modestyle", &modepwlstyle); // theme.powerline.modestyle
config_setting_lookup_int(conf, "capsstyle", &capspwlstyle); // theme.powerline.capsstyle
config_setting_lookup_int(conf, "itemstyle", &itempwlstyle); // theme.powerline.itemstyle
config_setting_lookup_int(conf, "prompt", &powerlineprompt); // theme.powerline.prompt
config_setting_lookup_int(conf, "matchcount", &powerlinecount); // theme.powerline.matchcount
config_setting_lookup_int(conf, "mode", &powerlinemode); // theme.powerline.mode
config_setting_lookup_int(conf, "caps", &powerlinecaps); // theme.powerline.caps
config_setting_lookup_int(conf, "item", &powerlineitems); // theme.powerline.item
}
}

View file

@ -98,10 +98,12 @@ ResourcePref resources[] = {
{ "matchcountpwlstyle", INTEGER, &matchcountpwlstyle },
{ "modepwlstyle", INTEGER, &modepwlstyle },
{ "capspwlstyle", INTEGER, &capspwlstyle },
{ "itempwlstyle", INTEGER, &itempwlstyle },
{ "powerlineprompt", INTEGER, &powerlineprompt },
{ "powerlinecount", INTEGER, &powerlinecount },
{ "powerlinemode", INTEGER, &powerlinemode },
{ "powerlinecaps", INTEGER, &powerlinecaps },
{ "powerlineitems", INTEGER, &powerlineitems },
{ "dockproperty", INTEGER, &dockproperty },
{ "globalcolors", INTEGER, &globalcolors },
{ "coloritems", INTEGER, &coloritems },

View file

@ -337,7 +337,7 @@ void calcoffsets(void) {
if (!strcmp(capstext, ""))
capsWidth = 0;
n = mw - (promptw + inputw + larrowWidth + rarrowWidth + modeWidth + numberWidth + capsWidth + menumarginv);
n = mw - (promptw + inputw + larrowWidth + rarrowWidth + modeWidth + numberWidth + capsWidth + menumarginh);
}
// calculate which items will begin the next page