about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-15 22:21:24 +0000
committerJames Booth <boothj5@gmail.com>2015-01-15 22:21:24 +0000
commit82c986775d0ece765b483256c218e0c42c6b14fc (patch)
treefb0e2a41ad10457078f5ca0e23aa3ff097c395b8 /src/ui
parentb43252a6b3d4302f63e4210f5f9445e8110a78e5 (diff)
downloadprofani-tty-82c986775d0ece765b483256c218e0c42c6b14fc.tar.gz
Moved input to ui module, renamed ui_readline
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c25
-rw-r--r--src/ui/ui.h2
2 files changed, 19 insertions, 8 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 8b89b12e..f1a563d7 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -73,6 +73,8 @@
 #include "xmpp/xmpp.h"
 
 static char *win_title;
+
+static char input[INP_WIN_MAX];
 static int inp_size;
 
 #ifdef HAVE_LIBXSS
@@ -176,14 +178,24 @@ ui_close(void)
     endwin();
 }
 
-gboolean
-ui_get_char(char *input)
+char*
+ui_readline(void)
 {
     int result = 0;
+    gboolean return_line = FALSE;
+
     wint_t ch = inp_get_char(input, &inp_size, &result);
+    if (ch == '\n') {
+        input[inp_size++] = '\0';
+        inp_size = 0;
+        return_line = TRUE;
+    }
+
     _win_handle_switch(ch);
+
     ProfWin *current = wins_get_current();
     win_handle_page(current, ch, result);
+
     if (ch == KEY_RESIZE) {
         ui_resize();
     }
@@ -195,12 +207,11 @@ ui_get_char(char *input)
         ui_input_nonblocking(FALSE);
     }
 
-    if (ch == '\n') {
-        input[inp_size++] = '\0';
-        inp_size = 0;
+    if (return_line) {
+        return input;
+    } else {
+        return NULL;
     }
-
-    return (ch != '\n');
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 8141ed2a..be6d2fd0 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -229,7 +229,7 @@ void ui_update_presence(const resource_presence_t resource_presence,
 void ui_about(void);
 void ui_statusbar_new(const int win);
 
-gboolean ui_get_char(char *input);
+char * ui_readline(void);
 void ui_input_clear(void);
 void ui_input_nonblocking(gboolean);
 void ui_replace_input(char *input, const char * const new_input, int *size);