organisation des des fichiers

This commit is contained in:
Arthur Barraux
2024-09-23 17:51:59 +02:00
parent ca215da58e
commit c613eb6978
20 changed files with 538 additions and 449 deletions
+12
View File
@@ -0,0 +1,12 @@
#ifndef APPEND_BUFFER_H_
#define APPEND_BUFFER_H_
#include "data.h"
#include <stdlib.h>
#include <string.h>
void abAppend(struct abuf *ab, const char *s, int len);
void abFree(struct abuf *ab);
#endif // APPEND_BUFFER_H_
+30
View File
@@ -0,0 +1,30 @@
#ifndef DATA_H_
#define DATA_H_
#include <termios.h>
typedef struct erow {
int size;
char *chars;
} erow;
/**
* \struct editorConfig
* \brief Containing our editor state.
*/
struct editorConfig {
int cursor_x, cursor_y;
int row_offset;
int screenrows;
int screencols;
int numrows;
erow *row;
struct termios orig_termios;
};
struct abuf {
char *b;
int len;
};
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef DEFINE_H_
#define DEFINE_H_
#define CTRL_KEY(k) ((k) & 0x1f)
#define CURSOR_TOP_LEFT "\x1b[H"
#define HIDE_CURSOR "\x1b[?25l"
#define SHOW_CURSOR "\x1b[?25h"
#define ERASE_END_LINE "\x1b[K"
enum editorKey {
CURSOR_LEFT = 1000,
CURSOR_RIGHT,
CURSOR_UP,
CURSOR_DOWN,
BEG_LINE,
DELETE,
END_LINE,
PAGE_UP,
PAGE_DOWN,
};
#define ABUF_INIT {NULL, 0}
#define BELUGA_VERSION "0.1"
#endif // DEFINE_H_
+13
View File
@@ -0,0 +1,13 @@
#ifndef FILE_IO_H_
#define FILE_IO_H_
#include "data.h"
#include "row_op.h"
#include "terminal.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
void editorOpen(struct editorConfig *E, char *filename);
#endif // FILE_IO_H_
+15
View File
@@ -0,0 +1,15 @@
#ifndef INIT_H_
#define INIT_H_
#include "data.h"
#include "terminal.h"
#include <stdio.h>
/**
* \fn void initEditor()
* \brief Job's function is to initialize all the fields of editorConfig.
* */
void initEditor(struct editorConfig *E);
#endif // INIT_H_
+18
View File
@@ -0,0 +1,18 @@
#ifndef INPUT_H_
#define INPUT_H_
#include "data.h"
#include "define.h"
#include "terminal.h"
#include <unistd.h>
void editorMoveCursor(struct editorConfig *E, int key);
/**
* \fn void editorProcessKeypress()
* \brief Get the last key input and do the proper action.
*/
void editorProcessKeypress(struct editorConfig *E);
#endif // INPUT_H_
+19
View File
@@ -0,0 +1,19 @@
#ifndef OUTPUT_H_
#define OUTPUT_H_
#include "append_buffer.h"
#include "data.h"
#include "define.h"
#include <stdio.h>
#include <unistd.h>
/**
* \fn void editorDrawRows(struct editorConfig *E, struct abuf *ab)
* \brief Draws left rows of the editor.
*/
void editorDrawRows(struct editorConfig *E, struct abuf *ab);
void editorRefreshScreen(struct editorConfig *E);
#endif // OUTPUT_H_
+11
View File
@@ -0,0 +1,11 @@
#ifndef ROW_OP_H_
#define ROW_OP_H_
#include "data.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void editorAppendRow(struct editorConfig *E, char *s, size_t len);
#endif // ROW_OP_H_
+34
View File
@@ -0,0 +1,34 @@
#ifndef TERMINAL_H_
#define TERMINAL_H_
/* includes */
#include "data.h"
#include "define.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
/**
* \fn void die(const char *s)
* \brief Exit program and return s error message.
* \param *s Error string
* */
void die(const char *s);
void disableRawMode(struct editorConfig *E);
void enableRawMode(struct editorConfig *E);
int editorReadKey();
int getCursorPosition(int *rows, int *cols);
int getWindowSize(int *rows, int *cols);
#endif