mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
Add paste buffer filling with ctrl+k
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user