forked from speedie/spmenu
Merge pull request 'Add powerline for items' (#7) from powerline-items into master
Reviewed-on: speedie/spmenu#7
This commit is contained in:
commit
618dc15530
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
24
libs/draw.c
24
libs/draw.c
|
@ -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) {
|
||||
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) {
|
||||
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,9 +321,9 @@ 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) {
|
||||
|
@ -329,7 +347,7 @@ int drawitem(int x, int y, int w) {
|
|||
int itemoverride = 1;
|
||||
|
||||
for (item = curr; item != next; item = item->right) { // draw items
|
||||
x = drawitemtext(item, x, y, MIN(pango_item ? TEXTWM(item->text) : TEXTW(item->text),
|
||||
x = drawitemtext(item, x + (powerlineitems ? plw : 0), y, MIN(pango_item ? TEXTWM(item->text) : TEXTW(item->text),
|
||||
mw - x -
|
||||
rarrowWidth -
|
||||
numberWidth -
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 },
|
||||
|
|
6
spmenu.c
6
spmenu.c
|
@ -337,17 +337,17 @@ 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
|
||||
for (i = 0, next = curr; next; next = next->right)
|
||||
if ((i += (lines > 0) ? bh : MIN(TEXTWM(next->text), n)) > n)
|
||||
if ((i += (lines > 0) ? bh : MIN(TEXTWM(next->text) + (powerlineitems ? !lines ? 2 * plw : 0 : 0), n)) > n)
|
||||
break;
|
||||
|
||||
// calculate which items will begin the previous page
|
||||
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
|
||||
if ((i += (lines > 0) ? bh : MIN(TEXTWM(prev->left->text), n)) > n)
|
||||
if ((i += (lines > 0) ? bh : MIN(TEXTWM(prev->left->text) + (powerlineitems ? !lines ? 2 * plw : 0 : 0), n)) > n)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue