-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.h
More file actions
83 lines (72 loc) · 1.71 KB
/
editor.h
File metadata and controls
83 lines (72 loc) · 1.71 KB
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
#ifndef EDITOR_H
#define EDITOR_H
// IMPORTS
void js_fill_rect(int x, int y, int w, int h, unsigned int colour);
void js_write_char(int x, int y, unsigned char c, unsigned int color, int size);
void js_unwrite_char(int x, int y, unsigned int color, int size);
void js_log(int msg);
void js_log_str(char* msg);
void js_dump_line(char* msg);
// EXPORTS
void editor_keypress(char c);
void editor_special_keypress(char c);
void editor_init(int w, int h, int font_size);
void editor_dump_text();
void editor_set_colours(int bgrd, int txt, int bgrd_margin, int txt_margin);
// DEFINITIONS
#define NULL (void*)0
#define LEN_MAX 80 * 100
#define FONT_HW_R 1.7
#define BGRD_COL 0xFF3c3836
#define TEXT_COL 0xFF548588
#define TEXT_COL_MARGIN 0xFF8ec07c
#define BGRD_COL_MARGIN 0xFFcc3836
// INTERNAL DECLARATIONS
enum KeysSpecial {
TAB = 9,
ENTER = 13,
LEFT = 37,
UP = 38,
RIGHT = 39,
DOWN = 40,
BSPACE = 8,
DELETE = 46,
};
typedef struct Colours {
int bgrd;
int txt;
int bgrd_margin;
int txt_margin;
} Colours;
typedef struct Screen {
int width_cs;
int height_cs;
int font_px;
int cursor;
int cursor_x_os;
int cursor_y_os;
int margin_w_cs;
char* text;
Colours colours;
} Screen;
typedef struct Coord {
int x;
int y;
} Coord;
// line
int line_get_end(int cur_pos);
int line_get_end_str(int cur_pos);
void line_clear_from(int cur_pos);
void line_render_from(int cur_pos);
void line_empty_from(int cur_pos);
void line_copy(int from_pos, int to_pos);
// cursor
Coord cursor_get_coord_px(int pos);
void cursor_clear();
void cursor_mov_lr(int d);
void cursor_render();
void cursor_mov_ud(int d);
// hack for global -> should probably make its own file with getters and
// setters.
static Screen SCREEN;
#endif