]> git.saurik.com Git - cycript.git/commitdiff
Commit line on return inside single-line commands.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 9 Dec 2015 20:51:16 +0000 (12:51 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 9 Dec 2015 20:51:16 +0000 (12:51 -0800)
Console.cpp

index 164438c8228e72be21ae62683403c5476f96fd2c..b16431b097c835777f47d5d703303901bffb48e3 100644 (file)
@@ -381,13 +381,26 @@ class History {
     }
 };
 
+static int CYConsoleKeyBypass(int count, int key) {
+    rl_point = rl_end;
+    rl_insert(count, '\n');
+    return rl_newline(count, key);
+}
+
 static int CYConsoleKeyReturn(int count, int key) {
+    if (rl_point != rl_end) {
+        if (memchr(rl_line_buffer, '\n', rl_end) == NULL)
+            return CYConsoleKeyBypass(count, key);
+        rl_insert(count, '\n');
+        return 0;
+    }
+
     rl_insert(count, '\n');
 
     bool done(false);
-    if (rl_end != 0 && rl_point == rl_end && rl_line_buffer[0] == '?')
+    if (rl_line_buffer[0] == '?')
         done = true;
-    else if (rl_point == rl_end) {
+    else {
         std::string command(rl_line_buffer, rl_end);
         std::istringstream stream(command);
 
@@ -525,10 +538,13 @@ static void Console(CYOptions &options) {
             continue;
         }
 
-        if (bypass)
-            rl_bind_key('\r', &rl_newline);
-        else
+        if (bypass) {
+            rl_bind_key('\r', &CYConsoleKeyBypass);
+            rl_bind_key('\n', &CYConsoleKeyBypass);
+        } else {
             rl_bind_key('\r', &CYConsoleKeyReturn);
+            rl_bind_key('\n', &CYConsoleKeyReturn);
+        }
 
         mode_ = Parsing;
         char *line(readline("cy# "));