2018-10-18 12:00:56 +02:00
|
|
|
#ifndef _FN_H
|
|
|
|
#define _FN_H
|
|
|
|
|
2018-10-25 12:17:28 +02:00
|
|
|
#include <bits/types/time_t.h> // for time_t
|
|
|
|
#include <termios.h> // for termios
|
|
|
|
|
2018-10-18 12:00:56 +02:00
|
|
|
#define FN_VERSION "0.2"
|
|
|
|
#define FN_TAB_STOP 4
|
|
|
|
|
|
|
|
#define CTRL_KEY(k) ((k) & 0x1f)
|
|
|
|
|
|
|
|
enum editorKey {
|
|
|
|
BACKSPACE = 127,
|
|
|
|
ARROW_LEFT = 1000,
|
|
|
|
ARROW_RIGHT,
|
|
|
|
ARROW_UP,
|
|
|
|
ARROW_DOWN,
|
|
|
|
DEL_KEY,
|
|
|
|
HOME_KEY,
|
|
|
|
END_KEY,
|
|
|
|
PAGE_UP,
|
|
|
|
PAGE_DOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
enum editorHighlight {
|
|
|
|
HL_NORMAL = 0,
|
|
|
|
HL_COMMENT,
|
|
|
|
HL_MLCOMMENT,
|
|
|
|
HL_KEYWORD1,
|
|
|
|
HL_KEYWORD2,
|
|
|
|
HL_STRING,
|
|
|
|
HL_NUMBER,
|
|
|
|
HL_MATCH
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HL_HIGHLIGHT_NUMBERS (1<<0)
|
|
|
|
#define HL_HIGHLIGHT_STRINGS (1<<1)
|
|
|
|
|
|
|
|
struct editorSyntax {
|
|
|
|
char *filetype;
|
|
|
|
char **filematch;
|
|
|
|
char **keywords;
|
|
|
|
char *singleline_comment_start;
|
|
|
|
char *multiline_comment_start;
|
|
|
|
char *multiline_comment_end;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct erow {
|
|
|
|
int idx;
|
|
|
|
int size;
|
|
|
|
int rsize;
|
|
|
|
char *chars;
|
|
|
|
char *render;
|
|
|
|
unsigned char *hl;
|
|
|
|
int hl_open_comment;
|
|
|
|
} erow;
|
|
|
|
|
|
|
|
struct editorConfig {
|
|
|
|
int cx, cy;
|
|
|
|
int rx; // The x position in the rendered line (for tabs)
|
|
|
|
int rowoff;
|
|
|
|
int coloff;
|
|
|
|
int screenrows;
|
|
|
|
int screencols;
|
|
|
|
int numrows;
|
|
|
|
erow *row;
|
|
|
|
int dirty;
|
|
|
|
char *filename;
|
|
|
|
char statusmsg[80];
|
|
|
|
time_t statusmsg_time;
|
|
|
|
struct editorSyntax *syntax;
|
|
|
|
struct termios orig_termios;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct editorConfig E;
|
|
|
|
|
2018-10-19 13:24:58 +02:00
|
|
|
struct abuf {
|
|
|
|
char *b;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
2018-10-18 12:00:56 +02:00
|
|
|
|
2018-10-25 13:35:06 +02:00
|
|
|
void windowResizeCallback(int signum);
|
|
|
|
void initEditor();
|
|
|
|
void exitEditor();
|
|
|
|
|
2018-10-18 12:00:56 +02:00
|
|
|
void editorSetStatusMessage(const char *fmt, ...);
|
|
|
|
void editorRefreshScreen();
|
|
|
|
char *editorPrompt(char *prompt, void (*callback)(char *, int));
|
|
|
|
|
|
|
|
#endif
|