Configurable settings with blisp

This commit is contained in:
Arthur Barraux
2025-06-02 10:31:31 +02:00
parent 19601a0078
commit bff3f84ecd
18 changed files with 446 additions and 119 deletions
+40
View File
@@ -0,0 +1,40 @@
#ifndef BUILTINS_H_
#define BUILTINS_H_
#include "../blisp/include/config_tools.h"
#include "../include/editor_op.h"
#include "../include/file_io.h"
#include "../include/output.h"
#include "../include/input.h"
#include "data.h"
#include "file_io.h"
// Function pointer type for commands
typedef void (*command_func_t)(struct editorConfig *E);
// Structure to hold function mappings
typedef struct {
const char *name;
command_func_t func;
} function_entry_t;
// Function registry
void init_function_registry(void);
int register_function(const char *name, command_func_t func);
command_func_t find_function(const char *name);
int execute_command(const char *name, struct editorConfig *E);
void moveCursorBeginLine(struct editorConfig *E);
void moveCursorEndLine(struct editorConfig *E);
void editorQuit(struct editorConfig *E);
void editorMoveCursorUp(struct editorConfig *E);
void editorMoveCursorDown(struct editorConfig *E);
void editorMoveCursorLeft(struct editorConfig *E);
void editorMoveCursorRight(struct editorConfig *E);
void deleteNextChar(struct editorConfig *E);
void editorMoveCursorPageUp(struct editorConfig *E);
void editorMoveCursorPageDown(struct editorConfig *E);
#endif
+11
View File
@@ -3,6 +3,7 @@
#include <termios.h>
#include <time.h>
#include "../blisp/include/data.h"
/**
* \struct erow
@@ -31,10 +32,12 @@ struct editorConfig {
int numrows; /**< Number of rows contained */
erow *row; /**< Store all the rows printed */
int dirty;
int quit_times;
char *filename;
char status_msg[80];
time_t status_msg_time;
struct termios orig_termios; /**< Terminal communication interface */
config_t *config;
};
/**
@@ -47,4 +50,12 @@ struct abuf {
int len; /**< Length of the text */
};
// Enhanced key sequence handling for multi-key bindings like "CTRL-f o"
typedef struct {
char sequence[64];
int sequence_len;
int last_key_time; // You might want to add timing if needed
} key_sequence_t;
#endif
+1 -1
View File
@@ -25,7 +25,7 @@ enum editorKey {
#define ABUF_INIT {NULL, 0}
#define BELUGA_VERSION "1.0"
#define TAB_LENGTH 4
#define TAB_LENGTH 2
#define QUIT_TIMES 1
#endif // DEFINE_H_
+5
View File
@@ -3,8 +3,13 @@
#include "data.h"
#include "terminal.h"
#include "builtins.h"
#include "../blisp/include/config_tools.h"
#include <stdio.h>
void getConfig();
/**
* \fn void initEditor()
* \brief Job's function is to initialize all the fields of editorConfig.
+8
View File
@@ -5,6 +5,8 @@
#include "define.h"
#include "output.h"
#include "terminal.h"
#include "builtins.h"
#include "../blisp/include/config_tools.h"
#include <unistd.h>
// KEYS keycode
@@ -19,6 +21,12 @@
// END \x1b[4~ || <esc>[8~ || <esc>[F || <esc>OF
// DELETE \x1b[3~
char *key_to_string(int key);
int execute_key_binding(config_t *config, const char *key_combo, void *context);
int handle_key_sequence(struct editorConfig *E, int key);
char *editorPrompt(struct editorConfig *E, char *prompt);
void editorMoveCursor(struct editorConfig *E, int key);
+2
View File
@@ -25,4 +25,6 @@ void editorRowAppendString(struct editorConfig *E, erow *row, char *s,
void editorRowDelchar(struct editorConfig *E, erow *row, int at);
void log_string(char * string);
#endif // ROW_OP_H_