about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-28 22:11:44 +0100
committerJames Booth <boothj5@gmail.com>2013-08-28 22:11:44 +0100
commitb7e7cb9c689ad1e8dcc334aa01576c8ce95206b0 (patch)
treecfc2c3dcec8868afadcd5256ed9323affb3d7d4e /src
parent30a4054937a56d8efcfccb3ba095d16c7c4d8800 (diff)
downloadprofani-tty-b7e7cb9c689ad1e8dcc334aa01576c8ce95206b0.tar.gz
Refactor updating window statuses
Diffstat (limited to 'src')
-rw-r--r--src/ui/statusbar.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index 46824fbe..49cb0eae 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -45,6 +45,7 @@ static int dirty;
 static GDateTime *last_time;
 
 static void _status_bar_update_time(void);
+static void _update_win_statuses(void);
 
 void
 create_status_bar(void)
@@ -87,13 +88,7 @@ status_bar_refresh(void)
 
     if (dirty) {
         _status_bar_update_time();
-        int i;
-        for(i = 1; i < 12; i++) {
-            if (is_new[i])
-                status_bar_new(i);
-            else if (is_active[i])
-                status_bar_active(i);
-        }
+        _update_win_statuses();
         wrefresh(status_bar);
         inp_put_back();
         dirty = FALSE;
@@ -105,7 +100,7 @@ status_bar_refresh(void)
 void
 status_bar_resize(void)
 {
-    int rows, cols, i;
+    int rows, cols;
     getmaxyx(stdscr, rows, cols);
 
     mvwin(status_bar, rows-2, 0);
@@ -116,12 +111,7 @@ status_bar_resize(void)
     mvwprintw(status_bar, 0, cols - 34, _active);
     wattroff(status_bar, COLOUR_STATUS_BRACKET);
 
-    for(i = 1; i < 12; i++) {
-        if (is_new[i])
-            status_bar_new(i);
-        else if (is_active[i])
-            status_bar_active(i);
-    }
+    _update_win_statuses();
 
     if (message != NULL)
         mvwprintw(status_bar, 0, 10, message);
@@ -236,14 +226,7 @@ status_bar_print_message(const char * const msg)
     mvwprintw(status_bar, 0, cols - 34, _active);
     wattroff(status_bar, COLOUR_STATUS_BRACKET);
 
-    int i;
-    for(i = 1; i < 12; i++) {
-        if (is_new[i])
-            status_bar_new(i);
-        else if (is_active[i])
-            status_bar_active(i);
-    }
-
+    _update_win_statuses();
     dirty = TRUE;
 }
 
@@ -290,14 +273,7 @@ status_bar_clear_message(void)
     mvwprintw(status_bar, 0, cols - 34, _active);
     wattroff(status_bar, COLOUR_STATUS_BRACKET);
 
-    int i;
-    for(i = 1; i < 12; i++) {
-        if (is_new[i])
-            status_bar_new(i);
-        else if (is_active[i])
-            status_bar_active(i);
-    }
-
+    _update_win_statuses();
     dirty = TRUE;
 }
 
@@ -319,3 +295,15 @@ _status_bar_update_time(void)
 
     dirty = TRUE;
 }
+
+static void
+_update_win_statuses(void)
+{
+    int i;
+    for(i = 1; i < 12; i++) {
+        if (is_new[i])
+            status_bar_new(i);
+        else if (is_active[i])
+            status_bar_active(i);
+    }
+}