Add paste buffer filling with ctrl+k

This commit is contained in:
savalet
2025-05-23 17:15:20 +02:00
parent a32fa30729
commit 214d616420

View File

@@ -5,6 +5,7 @@
** _
*/
#include <string.h>
#include <unistd.h>
#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;