copy paste functions
Build project / build (push) Has been cancelled

This commit is contained in:
2026-05-26 08:28:38 +02:00
parent 777dc5cb74
commit 3d49a0e2eb
23 changed files with 369 additions and 288 deletions
+49 -4
View File
@@ -13,8 +13,9 @@
#include "../include/editor_op.h"
#include "../include/file_io.h"
#include "../include/input.h"
#include "../include/row_op.h"
#include "../include/terminal.h"
#include "../include/split_screen.h"
#include "../include/completion.h"
#include <stdio.h>
#include <stdlib.h>
@@ -223,8 +224,6 @@ Lisp l_editorInsertNewLine(Lisp args, LispError *e, LispContext ctx) {
* @note Uses E.constantes.TAB_LENGTH for indentation width
*/
Lisp l_editorInserTab(Lisp args, LispError *e, LispContext ctx) {
EditorPane *active = splitScreenGetActivePane();
struct buffer_t *buf = bufferFindById(active->buffer_id);
for (int i = 0; i < E.constantes.TAB_LENGTH; ++i) {
bufferInsertBytes(" ", 1);
}
@@ -359,7 +358,7 @@ Lisp editorOpenFile(Lisp args, LispError *e, LispContext ctx) {
* @note Uses first character of the string argument
*/
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx) {
char *src = lisp_string(lisp_car(args));
const char *src = lisp_string(lisp_car(args));
bufferInsertBytes(src, strlen(src));
return lisp_null();
}
@@ -514,3 +513,49 @@ Lisp editorPrefix(Lisp args, LispError *e, LispContext ctx) {
64);
return lisp_null();
}
Lisp editorPaste(Lisp args, LispError *e, LispContext ctx)
{
const char *char_to_paste = editorGetClipboard();
appDebug("editor-paste, %s\n", char_to_paste);
bufferInsertBytes(char_to_paste, (int) strlen(char_to_paste));
return lisp_null();
}
Lisp editorCutEndLine(Lisp args, LispError *e, LispContext ctx)
{
EditorPane *active = splitScreenGetActivePane();
struct buffer_t *buffer = bufferFindById(active->buffer_id);
int bytes_to_delete = buffer->row[buffer->y].size - buffer->x;
editorSetClipboard(&buffer->row[buffer->y].chars[buffer->x], bytes_to_delete);
buffer->x = buffer->row[buffer->y].size;
while (bytes_to_delete--)
{
bufferDelBytes();
}
return lisp_null();
}
Lisp editorMoveBegBuffer(Lisp args, LispError *e, LispContext ctx)
{
EditorPane *active = splitScreenGetActivePane();
struct buffer_t *buffer = bufferFindById(active->buffer_id);
buffer->x = 0;
buffer->y = 0;
return lisp_null();
}
Lisp editorMoveEndBuffer(Lisp args, LispError *e, LispContext ctx)
{
EditorPane *active = splitScreenGetActivePane();
struct buffer_t *buffer = bufferFindById(active->buffer_id);
buffer->x = buffer->row[buffer->numrows-1].size;
buffer->y = buffer->numrows-1;
return lisp_null();
}
Lisp editorAutoComplete(Lisp args, LispError *e, LispContext ctx)
{
createContextBuffer(E.cursor_x - 2, E.cursor_y + 1, "hello");
return lisp_null();
}