about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input_win.c18
-rw-r--r--src/profanity.c2
-rw-r--r--src/ui.h2
3 files changed, 18 insertions, 4 deletions
diff --git a/src/input_win.c b/src/input_win.c
index 44c77302..25a65213 100644
--- a/src/input_win.c
+++ b/src/input_win.c
@@ -51,7 +51,6 @@
 #include "command.h"
 
 static WINDOW *inp_win;
-static int MAX_INP_SIZE = 1000;
 static int pad_start = 0;
 
 static int _handle_edit(const int ch, char *input, int *size);
@@ -63,7 +62,7 @@ void create_input_window(void)
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
 
-    inp_win = newpad(1, MAX_INP_SIZE);
+    inp_win = newpad(1, INP_WIN_MAX);
     wbkgd(inp_win, COLOR_PAIR(1));
     keypad(inp_win, TRUE);
     wmove(inp_win, 0, 0);
@@ -78,7 +77,10 @@ void inp_win_resize(const char * const input, const int size)
     
     // if lost cursor off screen, move contents to show it
     if (inp_x >= pad_start + cols) {
-        pad_start = inp_x - 10;
+        pad_start = inp_x - (cols / 2);
+        if (pad_start < 0) {
+            pad_start = 0;
+        }
     }
 
     prefresh(inp_win, pad_start, 0, rows-1, 0, rows-1, cols-1);
@@ -213,6 +215,16 @@ static int _handle_edit(const int ch, char *input, int *size)
                     waddch(inp_win, input[i]);
                 wmove(inp_win, 0, inp_x -1);
             }
+
+            // if gone off screen to left, jump left (half a screen worth)
+            if (inp_x <= pad_start) {
+                pad_start = pad_start - (cols / 2);
+                if (pad_start < 0) {
+                    pad_start = 0;
+                }
+
+                prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
+            }
         }
         return 1;
 
diff --git a/src/profanity.c b/src/profanity.c
index 7df6ba3a..bba4ebb6 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -41,7 +41,7 @@ void profanity_run(void)
     inp_non_block();
     while(cmd_result == TRUE) {
         int ch = ERR;
-        char inp[200];
+        char inp[INP_WIN_MAX];
         int size = 0;
 
         while(ch != '\n') {
diff --git a/src/ui.h b/src/ui.h
index 5bdda9a8..6e33efc6 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -28,6 +28,8 @@
 #include "common.h"
 #include "contact_list.h"
 
+#define INP_WIN_MAX 1000
+
 struct prof_win {
     char from[100];
     WINDOW *win;