about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-02 21:27:58 +0000
committerJames Booth <boothj5@gmail.com>2015-02-02 21:27:58 +0000
commit5954c0d2fe398213b29a8b4aa60340d49bf9946e (patch)
tree0077c528ecac213822d600c06ebad44cae46aa40 /src
parent51a54260064db3fc5d43456b15d821f192e9d12f (diff)
downloadprofani-tty-5954c0d2fe398213b29a8b4aa60340d49bf9946e.tar.gz
Readline osx compatibility
Diffstat (limited to 'src')
-rw-r--r--src/ui/core.c4
-rw-r--r--src/ui/inputwin.c18
2 files changed, 14 insertions, 8 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 47aa9d10..d6b45bde 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -94,6 +94,10 @@ ui_init(void)
 {
     log_info("Initialising UI");
     initscr();
+    nonl();
+    cbreak();
+    noecho();
+    leaveok(stdscr, FALSE);
     keypad(stdscr, TRUE);
     if (prefs_get_boolean(PREF_MOUSE)) {
         mousemask(ALL_MOUSE_EVENTS, NULL);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 4ac34c97..0c1c617e 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -92,10 +92,9 @@ _printable(const wint_t ch)
 static void
 cb_linehandler(char *line)
 {
-    if (*line) {
+    if (line && *line) {
         add_history(line);
     }
-    rl_redisplay();
     cmd_result = cmd_process_input(line);
     free(line);
 }
@@ -103,7 +102,7 @@ cb_linehandler(char *line)
 int
 prof_rl_getc(FILE *filein)
 {
-    int ch = rl_getc(filein);
+    int ch = getc(stdin);
     if (_printable(ch)) {
         cmd_reset_autocomplete();
     }
@@ -128,14 +127,12 @@ tab_handler(int count, int key)
         if (result) {
             rl_replace_line(result, 0);
             rl_point = rl_end;
-            inp_write(result, rl_point);
         }
     } else if (strncmp(rl_line_buffer, "/", 1) == 0) {
         char *result = cmd_autocomplete(rl_line_buffer);
         if (result) {
             rl_replace_line(result, 0);
             rl_point = rl_end;
-            inp_write(result, rl_point);
         }
     }
 
@@ -296,15 +293,19 @@ startup_hook(void)
 void
 create_input_window(void)
 {
+/*
 #ifdef NCURSES_REENTRANT
     set_escdelay(25);
 #else
     ESCDELAY = 25;
 #endif
+*/
 	p_rl_timeout.tv_sec = 0;
     p_rl_timeout.tv_usec = inp_timeout * 1000;
-    rl_startup_hook = startup_hook;
+
+    rl_readline_name = "profanity";
     rl_getc_function = prof_rl_getc;
+    rl_startup_hook = startup_hook;
     rl_callback_handler_install(NULL, cb_linehandler);
 
     signal(SIGWINCH, resize_signal_handler);
@@ -314,7 +315,6 @@ create_input_window(void)
     keypad(inp_win, TRUE);
     wmove(inp_win, 0, 0);
 
-
     _inp_win_update_virtual();
 }
 
@@ -433,6 +433,8 @@ inp_readline(void)
 
     if (FD_ISSET(fileno(rl_instream), &fds)) {
         rl_callback_read_char();
+        cons_debug("LINE: %s", rl_line_buffer);
+        cons_debug("POS : %d", rl_point);
 
         if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
             prof_handle_activity();
@@ -494,4 +496,4 @@ _inp_win_update_virtual(void)
     int wrows, wcols;
     getmaxyx(stdscr, wrows, wcols);
     pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2);
-}
\ No newline at end of file
+}