From 381ce702120fb03c3820b9689f8c659accc916c7 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 23 Dec 2022 18:02:18 +0200 Subject: [PATCH] =?UTF-8?q?backslash+enter=20=E2=86=92=20literal=20newline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.c b/src/main.c index c8558049..3f4e18e6 100644 --- a/src/main.c +++ b/src/main.c @@ -342,6 +342,14 @@ static bool isCmd(char* s, char** e, const char* cmd) { } return REPLXX_ACTION_RESULT_CONTINUE; } + ReplxxActionResult enter_replxx(int code, void* data) { + if (inBackslash()) { + setState(insertChar('\n', false)); + stopBackslash(); + return REPLXX_ACTION_RESULT_CONTINUE; + } + return REPLXX_ACTION_RESULT_RETURN; + } static NOINLINE bool slice_equal(B a, usz as, B b, usz bs, usz l) { B ac = vec_slice(a, as, l); B bc = vec_slice(b, bs, l); @@ -857,6 +865,7 @@ int main(int argc, char* argv[]) { replxx_set_completion_callback(replxx, complete_replxx, NULL); replxx_enable_bracketed_paste(replxx); replxx_bind_key(replxx, '\\', backslash_replxx, NULL); + replxx_bind_key(replxx, REPLXX_KEY_ENTER, enter_replxx, NULL); replxx_set_modify_callback(replxx, modified_replxx, NULL); replxx_bind_key_internal(replxx, REPLXX_KEY_CONTROL('N'), "history_next"); replxx_bind_key_internal(replxx, REPLXX_KEY_CONTROL('P'), "history_previous");