about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-04-22 20:59:36 +0100
committerJames Booth <boothj5@gmail.com>2012-04-22 20:59:36 +0100
commit6f69ce267b89fe998adfcf722f985378ec75cf8b (patch)
tree3ac1858c84087faa2cefc8d849af08bece696ba1
parente5d4e09f6a9b3f3e81f917bd2c93472d63347c4f (diff)
downloadprofani-tty-6f69ce267b89fe998adfcf722f985378ec75cf8b.tar.gz
Moved windows on resize
-rw-r--r--input_win.c21
-rw-r--r--profanity.c9
-rw-r--r--status_bar.c4
-rw-r--r--title_bar.c3
-rw-r--r--windows.c3
-rw-r--r--windows.h2
6 files changed, 24 insertions, 18 deletions
diff --git a/input_win.c b/input_win.c
index db13e7ab..f0cd364f 100644
--- a/input_win.c
+++ b/input_win.c
@@ -60,6 +60,15 @@ void create_input_window(void)
     wrefresh(inp_win);
 }
 
+void inp_win_resize(const char * const input, const int size)
+{
+    int rows, cols;
+    getmaxyx(stdscr, rows, cols);
+    mvwin(inp_win, rows-1, 0);
+    wresize(inp_win, 1, cols);
+    wrefresh(inp_win);
+}
+
 void inp_clear(void)
 {
     wclear(inp_win);
@@ -83,7 +92,8 @@ void inp_get_char(int *ch, char *input, int *size)
     int inp_x = 0;
     int i;
 
-    // echo off, and get some more input
+    
+// echo off, and get some more input
     noecho();
     *ch = wgetch(inp_win);
 
@@ -131,15 +141,6 @@ void inp_put_back(void)
     wrefresh(inp_win);
 }
 
-void inp_win_write(const char * const new_input, const int size)
-{
-    int i;
-    inp_clear();
-    for (i = 0; i < size; i++)
-        waddch(inp_win, new_input[i]);
-}
-
-
 /*
  * Deal with command editing, return 1 if ch was an edit
  * key press: up, down, left, right or backspace
diff --git a/profanity.c b/profanity.c
index 11dd0e0c..61dcac5b 100644
--- a/profanity.c
+++ b/profanity.c
@@ -45,13 +45,16 @@ void profanity_run(void)
         int size = 0;
 
         while(ch != '\n') {
-            gui_refresh();
-            jabber_process_events();
-            inp_get_char(&ch, inp, &size);
             win_handle_special_keys(&ch);
+
             if (ch == KEY_RESIZE) {
                 gui_resize(ch, inp, size);
             }
+            
+            gui_refresh();
+            jabber_process_events();
+            
+            inp_get_char(&ch, inp, &size);
         }
 
         inp[size++] = '\0';
diff --git a/status_bar.c b/status_bar.c
index c5045db6..ec8ee4d6 100644
--- a/status_bar.c
+++ b/status_bar.c
@@ -80,8 +80,10 @@ void status_bar_resize(void)
     int rows, cols, i;
     getmaxyx(stdscr, rows, cols);
 
-    status_bar = newwin(1, cols, rows-2, 0);
+    mvwin(status_bar, rows-2, 0);
+    wresize(status_bar, 1, cols);
     wbkgd(status_bar, COLOR_PAIR(3));
+    wclear(status_bar);
     wattron(status_bar, COLOR_PAIR(4));
     mvwprintw(status_bar, 0, cols - 29, _active);
     wattroff(status_bar, COLOR_PAIR(4));
diff --git a/title_bar.c b/title_bar.c
index 598622b1..113895d8 100644
--- a/title_bar.c
+++ b/title_bar.c
@@ -68,8 +68,9 @@ void title_bar_resize(void)
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
 
-    title_bar = newwin(1, cols, 0, 0);
+    wresize(title_bar, 1, cols);
     wbkgd(title_bar, COLOR_PAIR(3));
+    wclear(title_bar);
     _title_bar_draw_title();
     _title_bar_draw_status();
     dirty = TRUE;
diff --git a/windows.c b/windows.c
index aa690432..ee7ad59f 100644
--- a/windows.c
+++ b/windows.c
@@ -110,9 +110,8 @@ void gui_resize(const int ch, const char * const input, const int size)
 {
     title_bar_resize();
     status_bar_resize();
-    create_input_window();
-    inp_win_write(input, size);
     _current_window_refresh();
+    inp_win_resize(input, size);
     dirty = TRUE;
 }
 
diff --git a/windows.h b/windows.h
index bfb3157b..20914b07 100644
--- a/windows.h
+++ b/windows.h
@@ -94,10 +94,10 @@ void status_bar_update_time(void);
 // input window actions
 void inp_get_char(int *ch, char *input, int *size);
 void inp_clear(void);
+void inp_win_resize(const char * input, const int size);
 void inp_put_back(void);
 void inp_non_block(void);
 void inp_block(void);
 void inp_get_password(char *passwd);
-void inp_win_write(const char * const new_input, const int size);
 
 #endif