about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-03-10 22:16:52 +0000
committerJames Booth <boothj5@gmail.com>2018-03-10 22:16:52 +0000
commit95b639a21f77c825a36076562363154216cdad05 (patch)
tree9eda4cd8d11d08d6c0097124d679927fe15890aa /src/ui
parentb38f6ba5128a7ce091021537b2253da81f65cddb (diff)
downloadprofani-tty-95b639a21f77c825a36076562363154216cdad05.tar.gz
WIP add self prefs for statusbar
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c8
-rw-r--r--src/ui/core.c16
-rw-r--r--src/ui/inputwin.c4
-rw-r--r--src/ui/statusbar.c78
-rw-r--r--src/ui/statusbar.h8
5 files changed, 46 insertions, 68 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 60c5c8f5..26c830fc 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1754,6 +1754,14 @@ cons_statusbar_setting(void)
 
     cons_show("Max tabs (/statusbar)               : %d", prefs_get_statusbartabs());
 
+    char *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);
+    }
+    prefs_free_string(pref_self);
+
     char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
     cons_show("Chat tab display (/statusbar)       : %s", pref_chat);
     prefs_free_string(pref_chat);
diff --git a/src/ui/core.c b/src/ui/core.c
index af0d55a9..a0ca8495 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -137,7 +137,7 @@ ui_update(void)
         _ui_draw_term_title();
     }
     title_bar_update_virtual();
-    status_bar_update_virtual();
+    status_bar_draw();
     inp_put_back();
     doupdate();
 
@@ -388,8 +388,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured)
     title_bar_set_connected(TRUE);
     title_bar_set_tls(secured);
 
-    status_bar_print_message(connection_get_fulljid());
-    status_bar_update_virtual();
+    status_bar_set_prompt(connection_get_fulljid());
 }
 
 void
@@ -482,8 +481,7 @@ ui_disconnected(void)
     title_bar_set_connected(FALSE);
     title_bar_set_tls(FALSE);
     title_bar_set_presence(CONTACT_OFFLINE);
-    status_bar_clear_message();
-    status_bar_update_virtual();
+    status_bar_clear_prompt();
     ui_hide_roster();
 }
 
@@ -975,15 +973,14 @@ ui_win_unread(int index)
 char*
 ui_ask_password(void)
 {
-    status_bar_get_password();
-    status_bar_update_virtual();
+    status_bar_set_prompt("Enter password:");
     return inp_get_password();
 }
 
 char*
 ui_get_line(void)
 {
-    status_bar_update_virtual();
+    status_bar_draw();
     return inp_get_line();
 }
 
@@ -1006,8 +1003,7 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail)
 
     ui_update();
 
-    status_bar_get_password();
-    status_bar_update_virtual();
+    status_bar_set_prompt("Enter password:");
     return inp_get_password();
 }
 
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 0173a201..654a4602 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -251,7 +251,7 @@ inp_get_line(void)
         line = inp_readline();
         ui_update();
     }
-    status_bar_clear();
+    status_bar_clear_prompt();
     return line;
 }
 
@@ -269,7 +269,7 @@ inp_get_password(void)
         ui_update();
     }
     get_password = FALSE;
-    status_bar_clear();
+    status_bar_clear_prompt();
     return password;
 }
 
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index af6f49a2..28b20f01 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -61,7 +61,7 @@ typedef struct _status_bar_tab_t {
 
 typedef struct _status_bar_t {
     gchar *time;
-    char *message;
+    char *prompt;
     GHashTable *tabs;
     int current_tab;
 } StatusBar;
@@ -70,9 +70,8 @@ static GTimeZone *tz;
 static StatusBar *statusbar;
 static WINDOW *statusbar_win;
 
-static void _status_bar_draw(void);
 static int _status_bar_draw_time(int pos);
-static void _status_bar_draw_message(int pos);
+static void _status_bar_draw_prompt(int pos);
 static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
 static int _status_bar_draw_extended_tabs(int pos);
 static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num);
@@ -88,7 +87,7 @@ status_bar_init(void)
 
     statusbar = malloc(sizeof(StatusBar));
     statusbar->time = NULL;
-    statusbar->message = NULL;
+    statusbar->prompt = NULL;
     statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
     StatusBarTab *console = malloc(sizeof(StatusBarTab));
     console->window_type = WIN_CONSOLE;
@@ -100,7 +99,7 @@ status_bar_init(void)
     int cols = getmaxx(stdscr);
     statusbar_win = newwin(1, cols, row, 0);
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
@@ -113,20 +112,14 @@ status_bar_close(void)
         if (statusbar->time) {
             g_free(statusbar->time);
         }
-        if (statusbar->message) {
-            free(statusbar->message);
+        if (statusbar->prompt) {
+            free(statusbar->prompt);
         }
         free(statusbar);
     }
 }
 
 void
-status_bar_update_virtual(void)
-{
-    _status_bar_draw();
-}
-
-void
 status_bar_resize(void)
 {
     int cols = getmaxx(stdscr);
@@ -135,7 +128,7 @@ status_bar_resize(void)
     mvwin(statusbar_win, row, 0);
     wresize(statusbar_win, 1, cols);
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
@@ -153,7 +146,7 @@ status_bar_current(int i)
         statusbar->current_tab = i;
     }
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
@@ -166,7 +159,7 @@ status_bar_inactive(const int win)
 
     g_hash_table_remove(statusbar->tabs, GINT_TO_POINTER(true_win));
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
@@ -183,7 +176,7 @@ status_bar_active(const int win, win_type_t wintype, char *identifier)
     tab->window_type = wintype;
     g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
@@ -200,51 +193,34 @@ status_bar_new(const int win, win_type_t wintype, char* identifier)
     tab->window_type = wintype;
     g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
 
-    _status_bar_draw();
-}
-
-void
-status_bar_get_password(void)
-{
-    status_bar_print_message("Enter password:");
+    status_bar_draw();
 }
 
 void
-status_bar_print_message(const char *const msg)
+status_bar_set_prompt(const char *const prompt)
 {
-    if (statusbar->message) {
-        free(statusbar->message);
-        statusbar->message = NULL;
+    if (statusbar->prompt) {
+        free(statusbar->prompt);
+        statusbar->prompt = NULL;
     }
-    statusbar->message = strdup(msg);
+    statusbar->prompt = strdup(prompt);
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
-status_bar_clear(void)
+status_bar_clear_prompt(void)
 {
-    if (statusbar->message) {
-        free(statusbar->message);
-        statusbar->message = NULL;
+    if (statusbar->prompt) {
+        free(statusbar->prompt);
+        statusbar->prompt = NULL;
     }
 
-    _status_bar_draw();
+    status_bar_draw();
 }
 
 void
-status_bar_clear_message(void)
-{
-    if (statusbar->message) {
-        free(statusbar->message);
-        statusbar->message = NULL;
-    }
-
-    _status_bar_draw();
-}
-
-static void
-_status_bar_draw(void)
+status_bar_draw(void)
 {
     werase(statusbar_win);
     wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
@@ -253,7 +229,7 @@ _status_bar_draw(void)
 
     pos = _status_bar_draw_time(pos);
 
-    _status_bar_draw_message(pos);
+    _status_bar_draw_prompt(pos);
 
     pos = getmaxx(stdscr) - _tabs_width();
     gint max_tabs = prefs_get_statusbartabs();
@@ -413,10 +389,10 @@ _status_bar_draw_time(int pos)
 }
 
 static void
-_status_bar_draw_message(int pos)
+_status_bar_draw_prompt(int pos)
 {
-    if (statusbar->message) {
-        mvwprintw(statusbar_win, 0, pos, statusbar->message);
+    if (statusbar->prompt) {
+        mvwprintw(statusbar_win, 0, pos, statusbar->prompt);
     }
 }
 
diff --git a/src/ui/statusbar.h b/src/ui/statusbar.h
index 370b4bbb..ce1f5482 100644
--- a/src/ui/statusbar.h
+++ b/src/ui/statusbar.h
@@ -36,13 +36,11 @@
 #define UI_STATUSBAR_H
 
 void status_bar_init(void);
+void status_bar_draw(void);
 void status_bar_close(void);
-void status_bar_update_virtual(void);
 void status_bar_resize(void);
-void status_bar_clear(void);
-void status_bar_clear_message(void);
-void status_bar_get_password(void);
-void status_bar_print_message(const char *const msg);
+void status_bar_clear_prompt(void);
+void status_bar_set_prompt(const char *const prompt);
 void status_bar_current(int i);
 
 #endif