Selbar/Conf: Add max_lenght option to cut title lenght (requested by Erus)
This commit is contained in:
parent
c7824780fa
commit
49b9a08fab
@ -193,6 +193,7 @@ conf_bar_section(void)
|
|||||||
|
|
||||||
conf.selbar.bg = getcolor(fetch_opt_first(selbar, barbg, "bg").str);
|
conf.selbar.bg = getcolor(fetch_opt_first(selbar, barbg, "bg").str);
|
||||||
conf.selbar.fg = fetch_opt_first(selbar, conf.colors.text, "fg").str;
|
conf.selbar.fg = fetch_opt_first(selbar, conf.colors.text, "fg").str;
|
||||||
|
conf.selbar.maxlenght = fetch_opt_first(selbar, "-1", "max_lenght").num;
|
||||||
|
|
||||||
mouse = fetch_section(selbar, "mouse");
|
mouse = fetch_section(selbar, "mouse");
|
||||||
|
|
||||||
|
|||||||
@ -171,10 +171,12 @@ infobar_draw_layout(int sc)
|
|||||||
void
|
void
|
||||||
infobar_draw_selbar(int sc)
|
infobar_draw_selbar(int sc)
|
||||||
{
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
|
||||||
if(!conf.bars.selbar)
|
if(!conf.bars.selbar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!sel && infobar[sc].selbar->mapped)
|
if(!sel)
|
||||||
{
|
{
|
||||||
barwin_unmap(infobar[sc].selbar);
|
barwin_unmap(infobar[sc].selbar);
|
||||||
return;
|
return;
|
||||||
@ -182,17 +184,27 @@ infobar_draw_selbar(int sc)
|
|||||||
else if(sel && !infobar[sc].selbar->mapped)
|
else if(sel && !infobar[sc].selbar->mapped)
|
||||||
barwin_map(infobar[sc].selbar);
|
barwin_map(infobar[sc].selbar);
|
||||||
|
|
||||||
|
if(conf.selbar.maxlenght >= 0 && sel)
|
||||||
|
{
|
||||||
|
str = emalloc(conf.selbar.maxlenght + 4, sizeof(char));
|
||||||
|
strncpy(str, sel->title, conf.selbar.maxlenght);
|
||||||
|
strcat(str, "...");
|
||||||
|
}
|
||||||
|
|
||||||
|
barwin_resize(infobar[sc].selbar, textw(str ? str : sel->title) + PAD, infobar[sc].geo.height - 2);
|
||||||
|
|
||||||
barwin_move(infobar[sc].selbar,
|
barwin_move(infobar[sc].selbar,
|
||||||
((conf.layout_placement)
|
((conf.layout_placement)
|
||||||
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
|
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
|
||||||
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);
|
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);
|
||||||
|
|
||||||
barwin_resize(infobar[sc].selbar, textw(sel ? sel->title : NULL) + PAD, infobar[sc].geo.height - 2);
|
|
||||||
barwin_refresh_color(infobar[sc].selbar);
|
barwin_refresh_color(infobar[sc].selbar);
|
||||||
barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, (sel) ? sel->title : NULL);
|
barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, ((str) ? str : sel->title));
|
||||||
|
|
||||||
barwin_refresh(infobar[sc].selbar);
|
barwin_refresh(infobar[sc].selbar);
|
||||||
|
|
||||||
|
IFREE(str);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -376,6 +376,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
char *fg;
|
char *fg;
|
||||||
uint bg;
|
uint bg;
|
||||||
|
int maxlenght;
|
||||||
MouseBinding *mouse;
|
MouseBinding *mouse;
|
||||||
int nmouse;
|
int nmouse;
|
||||||
} selbar;
|
} selbar;
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
bg = "#191919"
|
bg = "#191919"
|
||||||
fg = "#D4D4ff"
|
fg = "#D4D4ff"
|
||||||
|
|
||||||
|
# Cut title lenght
|
||||||
|
# max_lenght = 25
|
||||||
|
|
||||||
[mouse] button = "3" func = "clientlist" [/mouse]
|
[mouse] button = "3" func = "clientlist" [/mouse]
|
||||||
[mouse] button = "4" func = "client_next" [/mouse]
|
[mouse] button = "4" func = "client_next" [/mouse]
|
||||||
[mouse] button = "5" func = "client_prev" [/mouse]
|
[mouse] button = "5" func = "client_prev" [/mouse]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user