about summary refs log tree commit diff stats
path: root/src/ui/inputwin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwin.c')
-rw-r--r--src/ui/inputwin.c52
1 files changed, 11 insertions, 41 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index ac7cf817..6fffad22 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -588,7 +588,7 @@ _inp_rl_win_close_handler(int count, int key)
 }
 
 static int
-_inp_rl_tab_handler(int count, int key)
+_inp_rl_tab_com_handler(int count, int key, gboolean previous)
 {
     if (rl_point != rl_end || !rl_line_buffer) {
         return 0;
@@ -596,7 +596,7 @@ _inp_rl_tab_handler(int count, int key)
 
     if (strncmp(rl_line_buffer, "/", 1) == 0) {
         ProfWin* window = wins_get_current();
-        char* result = cmd_ac_complete(window, rl_line_buffer, FALSE);
+        char* result = cmd_ac_complete(window, rl_line_buffer, previous);
         if (result) {
             rl_replace_line(result, 1);
             rl_point = rl_end;
@@ -607,7 +607,7 @@ _inp_rl_tab_handler(int count, int key)
 
     if (strncmp(rl_line_buffer, ">", 1) == 0) {
         ProfWin* window = wins_get_current();
-        char* result = win_quote_autocomplete(window, rl_line_buffer, FALSE);
+        char* result = win_quote_autocomplete(window, rl_line_buffer, previous);
         if (result) {
             rl_replace_line(result, 1);
             rl_point = rl_end;
@@ -618,7 +618,7 @@ _inp_rl_tab_handler(int count, int key)
 
     ProfWin* current = wins_get_current();
     if (current->type == WIN_MUC) {
-        char* result = muc_autocomplete(current, rl_line_buffer, FALSE);
+        char* result = muc_autocomplete(current, rl_line_buffer, previous);
         if (result) {
             rl_replace_line(result, 1);
             rl_point = rl_end;
@@ -630,45 +630,15 @@ _inp_rl_tab_handler(int count, int key)
 }
 
 static int
-_inp_rl_shift_tab_handler(int count, int key)
+_inp_rl_tab_handler(int count, int key)
 {
-    if (rl_point != rl_end || !rl_line_buffer) {
-        return 0;
-    }
-
-    if (strncmp(rl_line_buffer, "/", 1) == 0) {
-        ProfWin* window = wins_get_current();
-        char* result = cmd_ac_complete(window, rl_line_buffer, TRUE);
-        if (result) {
-            rl_replace_line(result, 1);
-            rl_point = rl_end;
-            free(result);
-            return 0;
-        }
-    }
-
-    if (strncmp(rl_line_buffer, ">", 1) == 0) {
-        ProfWin* window = wins_get_current();
-        char* result = win_quote_autocomplete(window, rl_line_buffer, TRUE);
-        if (result) {
-            rl_replace_line(result, 1);
-            rl_point = rl_end;
-            free(result);
-            return 0;
-        }
-    }
-
-    ProfWin* current = wins_get_current();
-    if (current->type == WIN_MUC) {
-        char* result = muc_autocomplete(current, rl_line_buffer, TRUE);
-        if (result) {
-            rl_replace_line(result, 1);
-            rl_point = rl_end;
-            free(result);
-        }
-    }
+    return _inp_rl_tab_com_handler(count, key, FALSE);
+}
 
-    return 0;
+static int
+_inp_rl_shift_tab_handler(int count, int key)
+{
+    return _inp_rl_tab_com_handler(count, key, TRUE);
 }
 
 static void