+3
-62
@@ -5,7 +5,6 @@
|
||||
#include "include/data.h"
|
||||
#include "include/buffer.h"
|
||||
#include "include/data.h"
|
||||
#include "include/row_op.h"
|
||||
#include "include/split_screen.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -41,7 +40,7 @@ extern struct editorConfig E;
|
||||
* @note Caller is responsible for freeing the returned string
|
||||
* @note Uses static buffer internally; may return stale pointers across calls
|
||||
*/
|
||||
const char *file_completion(const char *path) {
|
||||
const char *fileCompletion(const char *path) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
char directory[256];
|
||||
@@ -153,7 +152,7 @@ char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) {
|
||||
}
|
||||
memset(buf, 0, 256);
|
||||
buf_len = 0;
|
||||
char * buf_complete = (char *) file_completion(path);
|
||||
char * buf_complete = (char *) fileCompletion(path);
|
||||
strcpy(buf, buf_complete);
|
||||
free(buf_complete);
|
||||
buf_len = strlen(buf);
|
||||
@@ -170,65 +169,7 @@ char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Moves the cursor based on arrow key input
|
||||
* @details Updates cursor position (E.cursor_x, E.cursor_y) based on the given
|
||||
* key direction. Handles line wrapping and boundary conditions. Prevents cursor
|
||||
* from exceeding line lengths.
|
||||
* @param key The arrow key code (ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT)
|
||||
* @return 1 if cursor movement was valid, 0 if cursor was constrained to line boundary
|
||||
* @note Updates global editor state E
|
||||
*/
|
||||
int editorMoveCursor(int key) {
|
||||
EditorPane *active = splitScreenGetActivePane();
|
||||
struct buffer_t *buf = bufferFindById(active->buffer_id);
|
||||
row_t *row = &buf->row[buf->y];
|
||||
switch (key) {
|
||||
case ARROW_RIGHT:
|
||||
if (row && buf->x < row->size) {
|
||||
int len = utf8Seqlen(row->chars[buf->x]);
|
||||
buf->x += len;
|
||||
} else if (row && buf->y < buf->numrows) {
|
||||
buf->y++;
|
||||
buf->x = 0;
|
||||
}
|
||||
break;
|
||||
case ARROW_DOWN:
|
||||
if (buf->y < buf->numrows) {
|
||||
|
||||
buf->y++;
|
||||
}
|
||||
break;
|
||||
case ARROW_UP:
|
||||
if (buf->y != 0) {
|
||||
--buf->y;
|
||||
}
|
||||
break;
|
||||
case ARROW_LEFT:
|
||||
if (buf->x != 0) {
|
||||
--buf->x;
|
||||
} else if (buf->y > 0) {
|
||||
--buf->y;
|
||||
buf->x = buf->row[buf->y].size;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
fprintf(stderr, "acx: %d acy %d aox %d aoy %d bx %d by %d ah %d aw %d\n",
|
||||
active->cursor_x,
|
||||
active->cursor_y,
|
||||
active->x_offset,
|
||||
active->y_offset,
|
||||
buf->x,
|
||||
buf->y,
|
||||
active->height,
|
||||
active->width
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Executes the command bound to a key sequence
|
||||
@@ -272,7 +213,7 @@ void editorProcessKeypress() {
|
||||
int c = editorReadKey();
|
||||
char key_sequence[8];
|
||||
|
||||
if (executeKeyBind(key_to_string(c))) {
|
||||
if (executeKeyBind(keyToString(c))) {
|
||||
return;
|
||||
}
|
||||
int seq_len = utf8Encode(c, key_sequence);
|
||||
|
||||
Reference in New Issue
Block a user