about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--input_win.c2
-rw-r--r--profanity.c5
-rw-r--r--windows.c126
-rw-r--r--windows.h5
4 files changed, 72 insertions, 66 deletions
diff --git a/input_win.c b/input_win.c
index fc242c99..06540bf1 100644
--- a/input_win.c
+++ b/input_win.c
@@ -76,7 +76,7 @@ void inp_block(void)
     wtimeout(inp_win, -1);
 }
 
-void inp_poll_char(int *ch, char *input, int *size)
+void inp_get_char(int *ch, char *input, int *size)
 {
     int inp_y = 0;
     int inp_x = 0;
diff --git a/profanity.c b/profanity.c
index 5f07b8a8..ab54439d 100644
--- a/profanity.c
+++ b/profanity.c
@@ -47,9 +47,8 @@ void profanity_run(void)
         while(ch != '\n') {
             gui_refresh();
             jabber_process_events();
-            win_handle_switch(&ch);
-            win_handle_page(&ch);
-            inp_poll_char(&ch, inp, &size);
+            win_handle_special_keys(&ch);
+            inp_get_char(&ch, inp, &size);
         }
 
         inp[size++] = '\0';
diff --git a/windows.c b/windows.c
index 3083531b..11c880fa 100644
--- a/windows.c
+++ b/windows.c
@@ -55,6 +55,8 @@ static void _show_status_string(WINDOW *win, const char * const from,
     const char * const default_show);
 static void _cons_show_incoming_message(const char * const short_from, 
     const int win_index);
+static void _win_handle_switch(const int * const ch);
+static void _win_handle_page(const int * const ch);
 
 void gui_init(void)
 {
@@ -302,29 +304,10 @@ void cons_bad_message(void)
     cons_show("Usage: /msg user@host message");
 }
 
-void win_handle_switch(const int * const ch)
+void win_handle_special_keys(const int * const ch)
 {
-    if (*ch == KEY_F(1)) {
-        _win_switch_if_active(0);
-    } else if (*ch == KEY_F(2)) {
-        _win_switch_if_active(1);
-    } else if (*ch == KEY_F(3)) {
-        _win_switch_if_active(2);
-    } else if (*ch == KEY_F(4)) {
-        _win_switch_if_active(3);
-    } else if (*ch == KEY_F(5)) {
-        _win_switch_if_active(4);
-    } else if (*ch == KEY_F(6)) {
-        _win_switch_if_active(5);
-    } else if (*ch == KEY_F(7)) {
-        _win_switch_if_active(6);
-    } else if (*ch == KEY_F(8)) {
-        _win_switch_if_active(7);
-    } else if (*ch == KEY_F(9)) {
-        _win_switch_if_active(8);
-    } else if (*ch == KEY_F(10)) {
-        _win_switch_if_active(9);
-    }
+    _win_handle_switch(ch);
+    _win_handle_page(ch);
 }
 
 void win_page_off(void)
@@ -345,43 +328,6 @@ void win_page_off(void)
     dirty = TRUE;
 }
 
-void win_handle_page(const int * const ch)
-{
-    int rows, cols, y, x;
-    getmaxyx(stdscr, rows, cols);
-    getyx(_wins[_curr_prof_win].win, y, x);
-
-    int page_space = rows - 4;
-    int *page_start = &_wins[_curr_prof_win].y_pos;
-    
-    // page up
-    if (*ch == KEY_PPAGE) {
-        *page_start -= page_space;
-    
-        // went past beginning, show first page
-        if (*page_start < 0)
-            *page_start = 0;
-       
-        _wins[_curr_prof_win].paged = 1;
-        dirty = TRUE;
-
-    // page down
-    } else if (*ch == KEY_NPAGE) {
-        *page_start += page_space;
-
-        // only got half a screen, show full screen
-        if ((y - (*page_start)) < page_space)
-            *page_start = y - page_space;
-
-        // went past end, show full screen
-        else if (*page_start >= y)
-            *page_start = y - page_space;
-           
-        _wins[_curr_prof_win].paged = 1;
-        dirty = TRUE;
-    }
-}
-
 static void _create_windows(void)
 {
     int rows, cols;
@@ -533,3 +479,65 @@ static void _cons_show_incoming_message(const char * const short_from, const int
     wattroff(_cons_win, COLOR_PAIR(8));
 }
 
+static void _win_handle_switch(const int * const ch)
+{
+    if (*ch == KEY_F(1)) {
+        _win_switch_if_active(0);
+    } else if (*ch == KEY_F(2)) {
+        _win_switch_if_active(1);
+    } else if (*ch == KEY_F(3)) {
+        _win_switch_if_active(2);
+    } else if (*ch == KEY_F(4)) {
+        _win_switch_if_active(3);
+    } else if (*ch == KEY_F(5)) {
+        _win_switch_if_active(4);
+    } else if (*ch == KEY_F(6)) {
+        _win_switch_if_active(5);
+    } else if (*ch == KEY_F(7)) {
+        _win_switch_if_active(6);
+    } else if (*ch == KEY_F(8)) {
+        _win_switch_if_active(7);
+    } else if (*ch == KEY_F(9)) {
+        _win_switch_if_active(8);
+    } else if (*ch == KEY_F(10)) {
+        _win_switch_if_active(9);
+    }
+}
+
+static void _win_handle_page(const int * const ch)
+{
+    int rows, cols, y, x;
+    getmaxyx(stdscr, rows, cols);
+    getyx(_wins[_curr_prof_win].win, y, x);
+
+    int page_space = rows - 4;
+    int *page_start = &_wins[_curr_prof_win].y_pos;
+    
+    // page up
+    if (*ch == KEY_PPAGE) {
+        *page_start -= page_space;
+    
+        // went past beginning, show first page
+        if (*page_start < 0)
+            *page_start = 0;
+       
+        _wins[_curr_prof_win].paged = 1;
+        dirty = TRUE;
+
+    // page down
+    } else if (*ch == KEY_NPAGE) {
+        *page_start += page_space;
+
+        // only got half a screen, show full screen
+        if ((y - (*page_start)) < page_space)
+            *page_start = y - page_space;
+
+        // went past end, show full screen
+        else if (*page_start >= y)
+            *page_start = y - page_space;
+           
+        _wins[_curr_prof_win].paged = 1;
+        dirty = TRUE;
+    }
+}
+
diff --git a/windows.h b/windows.h
index 3c2ada95..077e0667 100644
--- a/windows.h
+++ b/windows.h
@@ -57,8 +57,7 @@ char *win_get_recipient(void);
 void win_show_incomming_msg(const char * const from, const char * const message);
 void win_show_outgoing_msg(const char * const from, const char * const to, 
     const char * const message);
-void win_handle_switch(const int * const ch);
-void win_handle_page(const int * const ch);
+void win_handle_special_keys(const int * const ch);
 void win_page_off(void);
 void win_contact_online(const char * const from, const char * const show, 
     const char * const status);
@@ -87,7 +86,7 @@ void status_bar_active(const int win);
 void status_bar_update_time(void);
 
 // input window actions
-void inp_poll_char(int *ch, char *input, int *size);
+void inp_get_char(int *ch, char *input, int *size);
 void inp_clear(void);
 void inp_put_back(void);
 void inp_non_block(void);