Fully fonctional editing

This commit is contained in:
Arthur Barraux
2024-10-10 02:09:48 +02:00
parent 1c22c3beca
commit a6f32d4c49
15 changed files with 249 additions and 47 deletions
+1
View File
@@ -30,6 +30,7 @@ struct editorConfig {
int screencols; /**< Terminal width*/
int numrows; /**< Number of rows contained */
erow *row; /**< Store all the rows printed */
int dirty;
char *filename;
char status_msg[80];
time_t status_msg_time;
+9 -7
View File
@@ -3,6 +3,7 @@
#define CTRL_KEY(k) ((k) & 0x1f)
#define ESCAPE '\x1b'
#define CURSOR_TOP_LEFT "\x1b[H"
#define HIDE_CURSOR "\x1b[?25l"
#define SHOW_CURSOR "\x1b[?25h"
@@ -10,12 +11,12 @@
enum editorKey {
BACKSPACE = 127,
CURSOR_LEFT = 1000,
CURSOR_RIGHT,
CURSOR_UP,
CURSOR_DOWN,
ARROW_LEFT = 1000,
ARROW_RIGHT,
ARROW_UP,
ARROW_DOWN,
DEL_KEY,
BEG_LINE,
DELETE,
END_LINE,
PAGE_UP,
PAGE_DOWN,
@@ -23,7 +24,8 @@ enum editorKey {
#define ABUF_INIT {NULL, 0}
#define BELUGA_VERSION "0.1"
#define TAB_LENGTH 8
#define BELUGA_VERSION "1.0"
#define TAB_LENGTH 4
#define QUIT_TIMES 1
#endif // DEFINE_H_
+4
View File
@@ -4,4 +4,8 @@
#include "data.h"
void editorInsertChar(struct editorConfig *E, int c);
void editorInsertNewLine(struct editorConfig *E);
void editorDelChar(struct editorConfig *E);
#endif // EDITOR_OP_H_
+3
View File
@@ -3,6 +3,7 @@
#include "data.h"
#include "define.h"
#include "output.h"
#include "terminal.h"
#include <unistd.h>
@@ -18,6 +19,8 @@
// END \x1b[4~ || <esc>[8~ || <esc>[F || <esc>OF
// DELETE \x1b[3~
char *editorPrompt(struct editorConfig *E, char *prompt);
void editorMoveCursor(struct editorConfig *E, int key);
/**
+12 -2
View File
@@ -5,14 +5,24 @@
#include "define.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int editorRowCxToRx(erow *row, int cursor_x);
void editorUpdateRow(erow *row);
void editorAppendRow(struct editorConfig *E, char *s, size_t len);
void editorInsertRow(struct editorConfig *E, int at, char *s, size_t len);
void editorRowInsertChar(erow *row, int at, int c);
void editorFreeRow(erow *row);
void editorDelRow(struct editorConfig *E, int at);
void editorRowInsertChar(struct editorConfig *E, erow *row, int at, int c);
void editorRowAppendString(struct editorConfig *E, erow *row, char *s,
size_t len);
void editorRowDelchar(struct editorConfig *E, erow *row, int at);
#endif // ROW_OP_H_