-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtakdit.h
107 lines (94 loc) · 2.16 KB
/
takdit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef _TAKDIT_H
#define _TAKDIT_H
#define TAKDIT_VERSION "0.0.3"
#define _BSD_SOURCE
#define _GNU_SOURCE
#include <termios.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdarg.h>
#include <fcntl.h>
#include <time.h>
#include <pwd.h>
#include <assert.h>
#include "modules/syntax/syntax.h"
#define EDIT_MODE 0
#define SELECTION_MODE 1
#define NORMAL_MODE 2
typedef struct erow {
int idx;
int size;
int rsize;
char *chars;
char *render;
unsigned char *hl;
int hl_oc;
} erow;
typedef struct colourMap {
int hl_comment_colour;
int hl_mlcomment_colour;
int hl_keyword_cond_colour;
int hl_keyword_type_colour;
int hl_keyword_pp_colour;
int hl_keyword_return_colour;
int hl_keyword_adapter_colour;
int hl_keyword_loop_colour;
int hl_string_colour;
int hl_number_colour;
int hl_match_colour;
int hl_background_colour;
int hl_default_colour;
} colourMap;
// configuration structure for the editor
struct editorConfig {
int cx, cy;
int rx;
int rowoff;
int coloff;
int screenrows;
int screencols;
int numrows;
int rawmode;
erow *row;
int dirty;
char *filename;
colourMap colours;
char statusmsg[80];
time_t statusmsg_time;
struct editorSyntax *syntax;
struct termios orig_termios;
};
#define CTRL_KEY(k) ((k) & 0x1f)
enum KEY_ACTION {
KEY_NULL = 0, /* NULL */
CTRL_C = 3, /* Ctrl-c */
CTRL_D = 4, /* Ctrl-d */
CTRL_F = 6, /* Ctrl-f */
CTRL_H = 8, /* Ctrl-h */
TAB = 9, /* Tab */
CTRL_L = 12, /* Ctrl+l */
ENTER = 13, /* Enter */
CTRL_Q = 17, /* Ctrl-q */
CTRL_S = 19, /* Ctrl-s */
CTRL_U = 21, /* Ctrl-u */
ESC = 27, /* Escape */
BACKSPACE = 127, /* Backspace */
ARROW_LEFT = 1000,
ARROW_RIGHT,
ARROW_UP,
ARROW_DOWN,
DEL_KEY,
HOME_KEY,
END_KEY,
PAGE_UP,
PAGE_DOWN
};
void editorSetStatusMessage(const char *fmt, ...);
#endif