about summary refs log tree commit diff stats
path: root/src/ui/core.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-12 23:41:15 +0000
committerJames Booth <boothj5@gmail.com>2015-01-12 23:41:15 +0000
commita39ac6cd07d18770b53075c6c0cde4435c13b726 (patch)
tree0cc223bbfab022fff7fcc6f8290f2875300b5a93 /src/ui/core.c
parenta564d01b47420544179119b4f96f42c01219ff96 (diff)
parent34148e21012289b8ebf4ba5a3e2aa8b65051fd55 (diff)
downloadprofani-tty-a39ac6cd07d18770b53075c6c0cde4435c13b726.tar.gz
Merge remote-tracking branch 'savar/dynamic_input_block'
Diffstat (limited to 'src/ui/core.c')
-rw-r--r--src/ui/core.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index be16dfad..e0f46f6e 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -180,7 +180,11 @@ ui_get_char(char *input, int *size, int *result)
     wint_t ch = inp_get_char(input, size, result);
     if (ch != ERR && *result != ERR) {
         ui_reset_idle_time();
+        ui_input_nonblocking(TRUE);
+    } else {
+        ui_input_nonblocking(FALSE);
     }
+
     return ch;
 }
 
@@ -197,9 +201,34 @@ ui_replace_input(char *input, const char * const new_input, int *size)
 }
 
 void
-ui_input_nonblocking(void)
+ui_input_nonblocking(gboolean reset)
 {
-    inp_non_block();
+    static gint timeout = 0;
+    static gint no_input_count = 0;
+
+    if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) {
+        inp_non_block(prefs_get_inpblock());
+        return;
+    }
+
+    if (reset) {
+        timeout = 0;
+        no_input_count = 0;
+    }
+
+    if (timeout < prefs_get_inpblock()) {
+        no_input_count++;
+
+        if (no_input_count % 10 == 0) {
+            timeout += no_input_count;
+
+            if (timeout > prefs_get_inpblock()) {
+                timeout = prefs_get_inpblock();
+            }
+        }
+    }
+
+    inp_non_block(timeout);
 }
 
 void
@@ -2218,7 +2247,7 @@ ui_ask_password(void)
   status_bar_update_virtual();
   inp_block();
   inp_get_password(passwd);
-  inp_non_block();
+  inp_non_block(prefs_get_inpblock());
 
   return passwd;
 }