Made Editor Config global

This commit is contained in:
Arthur Barraux
2025-09-19 14:31:12 +02:00
parent 91e247d1de
commit 8ce621dfde
17 changed files with 235 additions and 215 deletions
+6
View File
@@ -1,6 +1,7 @@
#ifndef DATA_H_
#define DATA_H_
#include "../lisp-interpreter/dist/lisp.h"
#include <termios.h>
#include <time.h>
@@ -35,6 +36,9 @@ struct editorConfig {
char status_msg[80];
time_t status_msg_time;
struct termios orig_termios; /**< Terminal communication interface */
LispContext ctx; /** Lisp context */
Lisp ctx_data; /** Lisp data context */
LispError ctx_error; /** Lisp ctx error */
};
/**
@@ -47,4 +51,6 @@ struct abuf {
int len; /**< Length of the text */
};
extern struct editorConfig E;
#endif
+3 -3
View File
@@ -2,10 +2,10 @@
#define EDITOR_OP_H_
#include "data.h"
void editorInsertChar(struct editorConfig *E, int c);
void editorInsertChar(int c);
void editorInsertNewLine(struct editorConfig *E);
void editorInsertNewLine();
void editorDelChar(struct editorConfig *E);
void editorDelChar();
#endif // EDITOR_OP_H_
+3 -3
View File
@@ -8,10 +8,10 @@
#include <stdlib.h>
#include <sys/types.h>
char *editorRowsToString(struct editorConfig *E, int *buffer_len);
char *editorRowsToString(int *buffer_len);
void editorOpen(struct editorConfig *E, char *filename);
void editorOpen(char *filename);
void editorSave(struct editorConfig *E);
void editorSave();
#endif // FILE_IO_H_
+1 -1
View File
@@ -10,6 +10,6 @@
* \brief Job's function is to initialize all the fields of editorConfig.
* */
void initEditor(struct editorConfig *E);
void initEditor();
#endif // INIT_H_
+3 -3
View File
@@ -19,15 +19,15 @@
// END \x1b[4~ || <esc>[8~ || <esc>[F || <esc>OF
// DELETE \x1b[3~
char *editorPrompt(struct editorConfig *E, char *prompt);
char *editorPrompt(char *prompt);
void editorMoveCursor(struct editorConfig *E, int key);
void editorMoveCursor(int key);
/**
* \fn void editorProcessKeypress()
* \brief Get the last key input and do the proper action.
*/
void editorProcessKeypress(struct editorConfig *E);
void editorProcessKeypress();
#endif // INPUT_H_
+6 -6
View File
@@ -13,16 +13,16 @@
* \brief Draws left rows of the editor.
*/
void editorDrawRows(struct editorConfig *E, struct abuf *ab);
void editorDrawRows(struct abuf *ab);
void editorRefreshScreen(struct editorConfig *E);
void editorRefreshScreen();
void editorScroll(struct editorConfig *E);
void editorScroll();
void editorDrawStatusBar(struct editorConfig *E, struct abuf *ab);
void editorDrawStatusBar(struct abuf *ab);
void editorDrawMessageBar(struct editorConfig *E, struct abuf *ab);
void editorDrawMessageBar(struct abuf *ab);
void editorSetStatusMessage(struct editorConfig *E, const char *fmt, ...);
void editorSetStatusMessage(const char *fmt, ...);
#endif // OUTPUT_H_
+5 -6
View File
@@ -12,17 +12,16 @@ int editorRowCxToRx(erow *row, int cursor_x);
void editorUpdateRow(erow *row);
void editorInsertRow(struct editorConfig *E, int at, char *s, size_t len);
void editorInsertRow(int at, char *s, size_t len);
void editorFreeRow(erow *row);
void editorDelRow(struct editorConfig *E, int at);
void editorDelRow(int at);
void editorRowInsertChar(struct editorConfig *E, erow *row, int at, int c);
void editorRowInsertChar(erow *row, int at, int c);
void editorRowAppendString(struct editorConfig *E, erow *row, char *s,
size_t len);
void editorRowAppendString(erow *row, char *s, size_t len);
void editorRowDelchar(struct editorConfig *E, erow *row, int at);
void editorRowDelchar(erow *row, int at);
#endif // ROW_OP_H_
+2 -2
View File
@@ -21,9 +21,9 @@
void die(const char *s);
void disableRawMode(struct editorConfig *E);
void disableRawMode();
void enableRawMode(struct editorConfig *E);
void enableRawMode();
int editorReadKey();