about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-05 22:45:34 +0000
committerJames Booth <boothj5@gmail.com>2013-01-05 22:45:34 +0000
commitad000db663d363e64b8ab8cd0a56f9e79255c7f6 (patch)
treef852032c1d4ee09410ab56ad0c0a99f46896be87 /src
parent893b6f863a359ad81236990a4f27c38c747f7210 (diff)
downloadprofani-tty-ad000db663d363e64b8ab8cd0a56f9e79255c7f6.tar.gz
Added _got_to_end() function
Diffstat (limited to 'src')
-rw-r--r--src/input_win.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/input_win.c b/src/input_win.c
index 9292b818..5e8e674b 100644
--- a/src/input_win.c
+++ b/src/input_win.c
@@ -68,6 +68,7 @@ static int _handle_edit(const wint_t ch, char *input, int *size);
 static int _printable(const wint_t ch);
 static gboolean _special_key(const wint_t ch);
 static void _inp_clear_no_pad(void);
+static void _go_to_end(int inp_y, int display_size, int rows, int cols);
 
 void
 create_input_window(void)
@@ -447,11 +448,7 @@ _handle_edit(const wint_t ch, char *input, int *size)
         if (prev) {
             inp_replace_input(input, prev, size);
             display_size = g_utf8_strlen(input, *size);
-            wmove(inp_win, inp_y, display_size);
-            if (display_size > cols-2) {
-                pad_start = display_size - cols + 1;
-                prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
-            }
+            _go_to_end(inp_y, display_size, rows, cols);
         }
         return 1;
 
@@ -460,11 +457,7 @@ _handle_edit(const wint_t ch, char *input, int *size)
         if (next) {
             inp_replace_input(input, next, size);
             display_size = g_utf8_strlen(input, *size);
-            wmove(inp_win, inp_y, display_size);
-            if (display_size > cols-2) {
-                pad_start = display_size - cols + 1;
-                prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
-            }
+            _go_to_end(inp_y, display_size, rows, cols);
         }
         return 1;
 
@@ -475,11 +468,7 @@ _handle_edit(const wint_t ch, char *input, int *size)
         return 1;
 
     case KEY_END:
-        wmove(inp_win, inp_y, display_size);
-        if (display_size > cols-2) {
-            pad_start = display_size - cols + 1;
-            prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
-        }
+        _go_to_end(inp_y, display_size, rows, cols);
         return 1;
 
     case 9: // tab
@@ -491,6 +480,16 @@ _handle_edit(const wint_t ch, char *input, int *size)
     }
 }
 
+static void
+_go_to_end(int inp_y, int display_size, int rows, int cols)
+{
+    wmove(inp_win, inp_y, display_size);
+    if (display_size > cols-2) {
+        pad_start = display_size - cols + 1;
+        prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
+    }
+}
+
 static int
 _printable(const wint_t ch)
 {