From 214d61642088ae92809463b4c9bb9bb0d99d5bd8 Mon Sep 17 00:00:00 2001 From: savalet Date: Fri, 23 May 2025 17:15:20 +0200 Subject: [PATCH] Add paste buffer filling with ctrl+k --- src/repl/key_control_edit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/repl/key_control_edit.c b/src/repl/key_control_edit.c index b1145bd..906f399 100644 --- a/src/repl/key_control_edit.c +++ b/src/repl/key_control_edit.c @@ -5,6 +5,7 @@ ** _ */ +#include #include #include "key_handler.h" @@ -35,8 +36,12 @@ bool handle_key_ctrl_f(readline_helper_t *rh, exec_ctx_t *ec, buff_t *buff) bool handle_key_ctrl_k(readline_helper_t *rh, exec_ctx_t *, buff_t *buff) { - if (!buff->sz && !rh->cursor) + if (!buff->sz || !rh->cursor || rh->cursor == buff->sz) return false; + rh->ec->paste_buff = u_strndup(buff->str + rh->cursor, + buff->sz - rh->cursor); + if (rh->ec->paste_buff == nullptr) + return true; buff->sz = rh->cursor; refresh_line(rh); return false;