Patch path complete and read char lisp function
Build project / build (push) Has been cancelled

This commit is contained in:
arthur
2025-11-07 16:23:56 +01:00
parent 5588b0a8d7
commit c06c820dfb
4 changed files with 16 additions and 2 deletions
+2
View File
@@ -35,4 +35,6 @@ Lisp editorDelRow_L(Lisp args, LispError *e, LispContext ctx);
Lisp editorFind_L(Lisp args, LispError *e, LispContext ctx);
Lisp editorReadChar_L(Lisp args, LispError *e, LispContext ctx);
#endif
+6
View File
@@ -166,3 +166,9 @@ Lisp editorFind_L(Lisp args, LispError *e, LispContext ctx) {
editorFind();
return lisp_null();
}
Lisp editorReadChar_L(Lisp args, LispError *e, LispContext ctx) {
fprintf(stderr, "char read : %c\n", E.row[E.cursor_y].render[E.cursor_x]);
return lisp_make_char(E.row[E.cursor_y].render[E.cursor_x]);
}
+1
View File
@@ -34,6 +34,7 @@ void initBuiltins() {
registerBuiltin("ADD-PACKAGE", addPackage);
registerBuiltin("EDITOR-DEL-ROW", editorDelRow_L);
registerBuiltin("EDITOR-FIND", editorFind_L);
registerBuiltin("EDITOR-READ-CHAR", editorReadChar_L);
}
void initEditor() {
+7 -2
View File
@@ -18,7 +18,11 @@ char * file_completion(const char *path) {
struct dirent *entry;
char directory[128];
char predict[128];
size_t predict_len;
int predict_len = 0;
if (path[strlen(path) - 1] == '/') {
return path;
}
// Find dir name
char * last_slash = strrchr(path, '/');
@@ -28,12 +32,13 @@ char * file_completion(const char *path) {
predict_len = strlen(path) - dir_len - 1;
strncpy(predict, last_slash + 1, predict_len);
directory[dir_len] = '\0';
fprintf(stderr, "%s %s\n", directory, predict);
predict[predict_len] = '\0';
fprintf(stderr, "%s %s\n", directory, predict);
} else {
return NULL;
}
dir = opendir(directory);
if (!dir)
return NULL;