mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Preference to show/hide tab number
This commit is contained in:
parent
e96af8537c
commit
6f5c0eb525
@ -797,6 +797,7 @@ cmd_ac_init(void)
|
||||
|
||||
statusbar_show_ac = autocomplete_new();
|
||||
autocomplete_add(statusbar_show_ac, "name");
|
||||
autocomplete_add(statusbar_show_ac, "number");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1358,8 +1358,8 @@ static struct cmd_t command_defs[] =
|
||||
CMD_TAGS(
|
||||
CMD_TAG_UI)
|
||||
CMD_SYN(
|
||||
"/statusbar show name",
|
||||
"/statusbar hide name",
|
||||
"/statusbar show name|number",
|
||||
"/statusbar hide name|number",
|
||||
"/statusbar maxtabs <value>",
|
||||
"/statusbar chat user|jid",
|
||||
"/statusbar room room|jid",
|
||||
@ -1370,6 +1370,7 @@ static struct cmd_t command_defs[] =
|
||||
CMD_ARGS(
|
||||
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10" },
|
||||
{ "show|hide name", "Show or hide names in tabs." },
|
||||
{ "show|hide number", "Show or hide numbers in tabs." },
|
||||
{ "chat user|jid", "Show only the users name, or the full jid if no nick is present for chat tabs." },
|
||||
{ "room room|jid", "Show only the rooms name, or the full jid for room tabs." },
|
||||
{ "up", "Move the status bar up the screen." },
|
||||
|
@ -5776,17 +5776,39 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "number") == 0) {
|
||||
prefs_set_boolean(PREF_STATUSBAR_SHOW_NUMBER, TRUE);
|
||||
cons_show("Enabled showing tab numbers.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "hide") == 0) {
|
||||
if (g_strcmp0(args[1], "name") == 0) {
|
||||
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER) == FALSE) {
|
||||
cons_show("Cannot disable both names and numbers in statusbar.");
|
||||
cons_show("Use '/statusbar maxtabs 0' to hide tabs.");
|
||||
return TRUE;
|
||||
}
|
||||
prefs_set_boolean(PREF_STATUSBAR_SHOW_NAME, FALSE);
|
||||
cons_show("Disabled showing tab names.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "number") == 0) {
|
||||
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME) == FALSE) {
|
||||
cons_show("Cannot disable both names and numbers in statusbar.");
|
||||
cons_show("Use '/statusbar maxtabs 0' to hide tabs.");
|
||||
return TRUE;
|
||||
}
|
||||
prefs_set_boolean(PREF_STATUSBAR_SHOW_NUMBER, FALSE);
|
||||
cons_show("Disabled showing tab numbers.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1587,6 +1587,7 @@ _get_group(preference_t pref)
|
||||
case PREF_CONSOLE_PRIVATE:
|
||||
case PREF_CONSOLE_CHAT:
|
||||
case PREF_STATUSBAR_SHOW_NAME:
|
||||
case PREF_STATUSBAR_SHOW_NUMBER:
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
return PREF_GROUP_UI;
|
||||
@ -1844,6 +1845,8 @@ _get_key(preference_t pref)
|
||||
return "rooms.cache";
|
||||
case PREF_STATUSBAR_SHOW_NAME:
|
||||
return "statusbar.show.name";
|
||||
case PREF_STATUSBAR_SHOW_NUMBER:
|
||||
return "statusbar.show.number";
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
return "statusbar.chat";
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
@ -1896,6 +1899,8 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_TRAY_READ:
|
||||
case PREF_BOOKMARK_INVITE:
|
||||
case PREF_ROOM_LIST_CACHE:
|
||||
case PREF_STATUSBAR_SHOW_NAME:
|
||||
case PREF_STATUSBAR_SHOW_NUMBER:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -144,6 +144,7 @@ typedef enum {
|
||||
PREF_PLUGINS_SOURCEPATH,
|
||||
PREF_ROOM_LIST_CACHE,
|
||||
PREF_STATUSBAR_SHOW_NAME,
|
||||
PREF_STATUSBAR_SHOW_NUMBER,
|
||||
PREF_STATUSBAR_CHAT,
|
||||
PREF_STATUSBAR_ROOM,
|
||||
} preference_t;
|
||||
|
@ -1746,6 +1746,11 @@ cons_statusbar_setting(void)
|
||||
} else {
|
||||
cons_show("Show tab names (/statusbar) : OFF");
|
||||
}
|
||||
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
|
||||
cons_show("Show tab numbers (/statusbar) : ON");
|
||||
} else {
|
||||
cons_show("Show tab numbers (/statusbar) : OFF");
|
||||
}
|
||||
|
||||
cons_show("Max tabs (/statusbar) : %d", prefs_get_statusbartabs());
|
||||
|
||||
|
@ -292,6 +292,7 @@ _status_bar_draw(void)
|
||||
pos = cols - _tabs_width();
|
||||
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
|
||||
|
||||
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
|
||||
@ -309,38 +310,28 @@ _status_bar_draw(void)
|
||||
}
|
||||
wattroff(statusbar_win, bracket_attrs);
|
||||
pos++;
|
||||
if (tab) {
|
||||
char *display_name = _display_name(tab);
|
||||
if (tab->highlight) {
|
||||
int status_attrs = theme_attrs(THEME_STATUS_NEW);
|
||||
wattron(statusbar_win, status_attrs);
|
||||
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
|
||||
if (show_name) {
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, display_name);
|
||||
pos += strlen(display_name) -1 ;
|
||||
}
|
||||
wattroff(statusbar_win, status_attrs);
|
||||
} else {
|
||||
int status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
|
||||
wattron(statusbar_win, status_attrs);
|
||||
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
|
||||
if (show_name) {
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, display_name);
|
||||
pos += strlen(display_name) - 1;
|
||||
}
|
||||
wattroff(statusbar_win, status_attrs);
|
||||
}
|
||||
free(display_name);
|
||||
char *display_name = _display_name(tab);
|
||||
int status_attrs = 0;
|
||||
if (tab->highlight) {
|
||||
status_attrs = theme_attrs(THEME_STATUS_NEW);
|
||||
} else {
|
||||
mvwprintw(statusbar_win, 0, pos, " ");
|
||||
status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
|
||||
}
|
||||
pos++;
|
||||
wattron(statusbar_win, status_attrs);
|
||||
if (show_number) {
|
||||
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
|
||||
pos++;
|
||||
}
|
||||
if (show_number && show_name) {
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
}
|
||||
if (show_name) {
|
||||
mvwprintw(statusbar_win, 0, pos, display_name);
|
||||
pos += strlen(display_name);
|
||||
}
|
||||
wattroff(statusbar_win, status_attrs);
|
||||
free(display_name);
|
||||
wattron(statusbar_win, bracket_attrs);
|
||||
if (i == statusbar->current_tab) {
|
||||
mvwprintw(statusbar_win, 0, pos, "-");
|
||||
@ -381,10 +372,11 @@ _destroy_tab(StatusBarTab *tab)
|
||||
static int
|
||||
_tabs_width(void)
|
||||
{
|
||||
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
|
||||
if (show_name) {
|
||||
if (show_name && show_number) {
|
||||
int width = 4;
|
||||
int i = 0;
|
||||
for (i = 1; i <= max_tabs; i++) {
|
||||
@ -397,9 +389,24 @@ _tabs_width(void)
|
||||
}
|
||||
}
|
||||
return width;
|
||||
} else {
|
||||
return g_hash_table_size(statusbar->tabs) * 3 + 4;
|
||||
}
|
||||
|
||||
if (show_name && !show_number) {
|
||||
int width = 4;
|
||||
int i = 0;
|
||||
for (i = 1; i <= max_tabs; i++) {
|
||||
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
char *display_name = _display_name(tab);
|
||||
width += strlen(display_name);
|
||||
width += 2;
|
||||
free(display_name);
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
return g_hash_table_size(statusbar->tabs) * 3 + 4;
|
||||
}
|
||||
|
||||
static char*
|
||||
|
Loading…
Reference in New Issue
Block a user