about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c4
-rw-r--r--src/ui/confwin.c48
-rw-r--r--src/ui/console.c14
-rw-r--r--src/ui/notifier.c2
-rw-r--r--src/ui/statusbar.c132
5 files changed, 123 insertions, 77 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index ff425c0f..0c540998 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -246,10 +246,10 @@ chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* da
         win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid);
         break;
     case PROF_OTR_SMP_AUTH:
-        win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid);
+        win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s…", chatwin->barejid);
         break;
     case PROF_OTR_SMP_AUTH_WAIT:
-        win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid);
+        win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s…", chatwin->barejid);
         break;
     default:
         break;
diff --git a/src/ui/confwin.c b/src/ui/confwin.c
index d74c6d86..85abe748 100644
--- a/src/ui/confwin.c
+++ b/src/ui/confwin.c
@@ -215,8 +215,8 @@ _confwin_form_field(ProfWin* window, char* tag, FormField* field)
         win_append(window, THEME_DEFAULT, ": ");
     }
 
-    GSList* values = field->values;
-    GSList* curr_value = values;
+    GSList* curr_value = field->values;
+    GSList* curr_option;
 
     switch (field->type_t) {
     case FIELD_HIDDEN:
@@ -272,36 +272,30 @@ _confwin_form_field(ProfWin* window, char* tag, FormField* field)
         }
         break;
     case FIELD_LIST_SINGLE:
-        if (curr_value) {
-            win_newline(window);
-            char* value = curr_value->data;
-            GSList* options = field->options;
-            GSList* curr_option = options;
-            while (curr_option) {
-                FormOption* option = curr_option->data;
-                if (g_strcmp0(option->value, value) == 0) {
-                    win_println(window, THEME_ONLINE, "-", "  [%s] %s", option->value, option->label);
-                } else {
-                    win_println(window, THEME_OFFLINE, "-", "  [%s] %s", option->value, option->label);
-                }
-                curr_option = g_slist_next(curr_option);
+        win_newline(window);
+        char* value = curr_value ? curr_value->data : NULL;
+        curr_option = field->options;
+        while (curr_option) {
+            FormOption* option = curr_option->data;
+            if (g_strcmp0(option->value, value) == 0) {
+                win_println(window, THEME_ONLINE, "-", "  [%s] %s", option->value, option->label);
+            } else {
+                win_println(window, THEME_OFFLINE, "-", "  [%s] %s", option->value, option->label);
             }
+            curr_option = g_slist_next(curr_option);
         }
         break;
     case FIELD_LIST_MULTI:
-        if (curr_value) {
-            win_newline(window);
-            GSList* options = field->options;
-            GSList* curr_option = options;
-            while (curr_option) {
-                FormOption* option = curr_option->data;
-                if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) {
-                    win_println(window, THEME_ONLINE, "-", "  [%s] %s", option->value, option->label);
-                } else {
-                    win_println(window, THEME_OFFLINE, "-", "  [%s] %s", option->value, option->label);
-                }
-                curr_option = g_slist_next(curr_option);
+        win_newline(window);
+        curr_option = field->options;
+        while (curr_option) {
+            FormOption* option = curr_option->data;
+            if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) {
+                win_println(window, THEME_ONLINE, "-", "  [%s] %s", option->value, option->label);
+            } else {
+                win_println(window, THEME_OFFLINE, "-", "  [%s] %s", option->value, option->label);
             }
+            curr_option = g_slist_next(curr_option);
         }
         break;
     case FIELD_JID_SINGLE:
diff --git a/src/ui/console.c b/src/ui/console.c
index 12b126c3..d26e559f 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -293,7 +293,7 @@ cons_show_typing(const char* const barejid)
         display_usr = barejid;
     }
 
-    win_println(console, THEME_TYPING, "-", "!! %s is typing a message...", display_usr);
+    win_println(console, THEME_TYPING, "-", "!! %s is typing a message…", display_usr);
     cons_alert(NULL);
 }
 
@@ -2008,21 +2008,21 @@ cons_statusbar_setting(void)
         cons_show("Max tab length (/statusbar)                 : %d", pref_len);
     }
 
-    char* pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
+    auto_gchar gchar* pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
     if (g_strcmp0(pref_self, "off") == 0) {
         cons_show("Self statusbar display (/statusbar)         : OFF");
     } else {
         cons_show("Self statusbar display (/statusbar)         : %s", pref_self);
     }
-    g_free(pref_self);
 
-    char* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
+    auto_gchar gchar* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
     cons_show("Chat tab display (/statusbar)               : %s", pref_chat);
-    g_free(pref_chat);
 
-    char* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
+    auto_gchar gchar* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
     cons_show("Room tab display (/statusbar)               : %s", pref_room);
-    g_free(pref_room);
+
+    auto_gchar gchar* pref_tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
+    cons_show("Tab mode (/statusbar)                       : %s", pref_tabmode);
 }
 
 void
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 07a542af..36ed73c4 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -77,7 +77,7 @@ notifier_uninit(void)
 void
 notify_typing(const char* const name)
 {
-    gchar* message = g_strdup_printf("%s: typing...", name);
+    gchar* message = g_strdup_printf("%s: typing…", name);
     notify(message, 10000, "Incoming message");
     g_free(message);
 }
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index e447e7d5..38d28c31 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -79,14 +79,15 @@ static StatusBar* statusbar;
 static WINDOW* statusbar_win;
 
 static int _status_bar_draw_time(int pos);
-static void _status_bar_draw_maintext(int pos);
-static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
+static int _status_bar_draw_maintext(int pos);
+static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
 static int _status_bar_draw_extended_tabs(int pos);
 static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num);
 static void _destroy_tab(StatusBarTab* tab);
 static int _tabs_width(void);
 static char* _display_name(StatusBarTab* tab);
 static gboolean _extended_new(void);
+static gboolean _tabmode_is_actlist(void);
 
 void
 status_bar_init(void)
@@ -289,21 +290,59 @@ status_bar_draw(void)
 
     pos = _status_bar_draw_time(pos);
 
-    _status_bar_draw_maintext(pos);
+    pos = _status_bar_draw_maintext(pos);
 
-    pos = getmaxx(stdscr) - _tabs_width();
-    if (pos < 0) {
-        pos = 0;
-    }
-    gint max_tabs = prefs_get_statusbartabs();
-    for (int i = 1; i <= max_tabs; i++) {
-        StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
-        if (tab) {
-            pos = _status_bar_draw_tab(tab, pos, i);
+    if (!_tabmode_is_actlist()) {
+        pos = getmaxx(stdscr) - _tabs_width();
+        if (pos < 0) {
+            pos = 0;
+        }
+        gint max_tabs = prefs_get_statusbartabs();
+        for (int i = 1; i <= max_tabs; i++) {
+            StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+            if (tab) {
+                pos = _status_bar_draw_tab(tab, pos, i);
+            }
         }
-    }
 
-    _status_bar_draw_extended_tabs(pos);
+        _status_bar_draw_extended_tabs(pos);
+    } else {
+        pos++;
+        guint print_act = 0;
+        guint tabnum = g_hash_table_size(statusbar->tabs);
+        for (guint i = 1; i <= tabnum; ++i) {
+            StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+            if (tab && tab->highlight) {
+                print_act++;
+            }
+        }
+        if (print_act) {
+            pos = _status_bar_draw_bracket(FALSE, pos, "[");
+            mvwprintw(statusbar_win, 0, pos, "Act: ");
+            pos += 5;
+            int status_attrs = theme_attrs(THEME_STATUS_NEW);
+
+            wattron(statusbar_win, status_attrs);
+            for (guint i = 1; i <= tabnum && print_act; ++i) {
+                StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+                if (tab && tab->highlight) {
+                    if (print_act == 1) {
+                        mvwprintw(statusbar_win, 0, pos, "%d", i);
+                        pos++;
+                    } else {
+                        mvwprintw(statusbar_win, 0, pos, "%d,", i);
+                        pos += 2;
+                    }
+                    for (guint limit = 10; i >= limit; limit *= 10) {
+                        pos++;
+                    }
+                    print_act--;
+                }
+            }
+            wattroff(statusbar_win, status_attrs);
+            pos = _status_bar_draw_bracket(FALSE, pos, "]");
+        }
+    }
 
     wnoutrefresh(statusbar_win);
     inp_put_back();
@@ -410,7 +449,7 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
 }
 
 static int
-_status_bar_draw_bracket(gboolean current, int pos, char* ch)
+_status_bar_draw_bracket(gboolean current, int pos, const char* ch)
 {
     int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
     wattron(statusbar_win, bracket_attrs);
@@ -466,39 +505,52 @@ _status_bar_draw_time(int pos)
     return pos;
 }
 
-static void
+static gboolean
+_tabmode_is_actlist(void)
+{
+    auto_char char* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
+    return g_strcmp0(tabmode, "actlist") == 0;
+}
+
+static int
 _status_bar_draw_maintext(int pos)
 {
+    const char* maintext = NULL;
+    auto_jid Jid* jidp = NULL;
+    auto_char char* self = prefs_get_string(PREF_STATUSBAR_SELF);
     if (statusbar->prompt) {
         mvwprintw(statusbar_win, 0, pos, "%s", statusbar->prompt);
-        return;
+        return utf8_display_len(statusbar->prompt);
+    } else if (g_strcmp0(self, "off") == 0) {
+        return pos;
+    } else if (statusbar->fulljid) {
+        jidp = jid_create(statusbar->fulljid);
+        if (g_strcmp0(self, "user") == 0) {
+            maintext = jidp->localpart;
+        } else if (g_strcmp0(self, "barejid") == 0) {
+            maintext = jidp->barejid;
+        } else {
+            maintext = statusbar->fulljid;
+        }
     }
 
-    gboolean stop = FALSE;
-
-    if (statusbar->fulljid) {
-        char* pref = prefs_get_string(PREF_STATUSBAR_SELF);
-
-        if (g_strcmp0(pref, "off") == 0) {
-            stop = true;
-        } else if (g_strcmp0(pref, "user") == 0) {
-            Jid* jidp = jid_create(statusbar->fulljid);
-            mvwprintw(statusbar_win, 0, pos, "%s", jidp->localpart);
-            jid_destroy(jidp);
-            stop = true;
-        } else if (g_strcmp0(pref, "barejid") == 0) {
-            Jid* jidp = jid_create(statusbar->fulljid);
-            mvwprintw(statusbar_win, 0, pos, "%s", jidp->barejid);
-            jid_destroy(jidp);
-            stop = true;
-        }
+    if (maintext == NULL) {
+        return pos;
+    }
 
-        g_free(pref);
-        if (stop) {
-            return;
-        }
-        mvwprintw(statusbar_win, 0, pos, "%s", statusbar->fulljid);
+    gboolean actlist_tabmode = _tabmode_is_actlist();
+    auto_gchar gchar* maintext_ = NULL;
+    if (actlist_tabmode) {
+        pos = _status_bar_draw_bracket(FALSE, pos, "[");
+        maintext_ = g_strdup_printf("%d:%s", statusbar->current_tab, maintext);
+        maintext = maintext_;
     }
+    mvwprintw(statusbar_win, 0, pos, "%s", maintext);
+    pos += utf8_display_len(maintext);
+    if (actlist_tabmode) {
+        pos = _status_bar_draw_bracket(FALSE, pos, "]");
+    }
+    return pos;
 }
 
 static void