2024-06-30 20:55:59 +02:00
|
|
|
#ifndef VIP_H_
|
|
|
|
#define VIP_H_
|
|
|
|
|
|
|
|
#include <termios.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2024-07-03 03:41:28 +02:00
|
|
|
#define VERSION "0.0.1"
|
|
|
|
|
2024-07-03 14:12:41 +02:00
|
|
|
#define COLOR_LEN 19
|
|
|
|
|
2024-07-03 12:11:48 +02:00
|
|
|
enum keys {
|
|
|
|
BACKSPACE = 127,
|
|
|
|
ARROW_LEFT = 1000,
|
|
|
|
ARROW_RIGHT,
|
|
|
|
ARROW_UP,
|
|
|
|
ARROW_DOWN,
|
|
|
|
DEL_KEY,
|
|
|
|
HOME_KEY,
|
|
|
|
END_KEY,
|
|
|
|
PAGE_UP,
|
|
|
|
PAGE_DOWN
|
|
|
|
};
|
|
|
|
|
2024-07-03 14:12:41 +02:00
|
|
|
enum modes {
|
|
|
|
NORMAL,
|
|
|
|
INSERT,
|
|
|
|
VISUAL,
|
|
|
|
COMMAND
|
|
|
|
};
|
|
|
|
|
|
|
|
enum highlight {
|
2024-07-04 18:00:13 +02:00
|
|
|
DEFAULT = 0,
|
|
|
|
COMMENT,
|
|
|
|
MLCOMMENT,
|
|
|
|
KEYWORD1, /* default */
|
|
|
|
KEYWORD2, /* types */
|
|
|
|
STRING,
|
|
|
|
NUMBER,
|
|
|
|
MATCH,
|
|
|
|
RESET
|
2024-07-03 14:12:41 +02:00
|
|
|
};
|
|
|
|
|
2024-07-04 18:00:13 +02:00
|
|
|
#include "row.h"
|
|
|
|
#include "syntax.h"
|
|
|
|
#include "config.h"
|
2024-06-30 20:55:59 +02:00
|
|
|
|
|
|
|
typedef struct editor {
|
|
|
|
int cx, cy; /* chars x, y */
|
2024-07-03 14:12:41 +02:00
|
|
|
int rx; /* render x */
|
2024-06-30 20:55:59 +02:00
|
|
|
int rowoff;
|
|
|
|
int coloff;
|
|
|
|
int screenrows, screencols;
|
|
|
|
int rows;
|
|
|
|
row *row;
|
2024-07-02 23:56:09 +02:00
|
|
|
int dirty;
|
2024-07-03 03:41:28 +02:00
|
|
|
int mode;
|
2024-06-30 20:55:59 +02:00
|
|
|
char *filename;
|
|
|
|
char statusmsg[80];
|
|
|
|
time_t statusmsg_time;
|
2024-07-04 18:00:13 +02:00
|
|
|
language *syntax;
|
2024-06-30 20:55:59 +02:00
|
|
|
struct termios termios;
|
|
|
|
} editor;
|
|
|
|
|
|
|
|
struct abuf {
|
|
|
|
char *b;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ABUF_INIT { NULL, 0 }
|
|
|
|
void abAppend(struct abuf *ab, const char *s, int len);
|
2024-07-04 18:00:13 +02:00
|
|
|
void abFree(struct abuf *ab);
|
2024-07-01 21:40:07 +02:00
|
|
|
|
2024-06-30 20:55:59 +02:00
|
|
|
extern editor vip;
|
|
|
|
|
|
|
|
#endif
|