+/Femto

toy text editor

git clone https://git.julia.blue/+/Femto

Joseph RyanFixup973c5b9

master
1.2 KiB77 linesraw
1#ifndef DISPLAY_H
2#define DISPLAY_H
3
4#include <stdio.h>
5
6#include "abuf.h"
7#include "editor.h"
8
9#define NUM_SYNTAX 2
10#define SETTING_NUMBER (1 << 0)
11#define SETTING_STRING (1 << 1)
12
13struct erow;
14
15/**
16 * Contains parameters for syntax highlighting of a given language.
17 */
18struct editorSyntax {
19    char* filetype;
20    char* filematch;
21    char* slCommentStart;
22    char* mlCommentStart;
23    char* mlCommentEnd;
24    char** keywords;
25    int flags;
26};
27
28extern struct editorSyntax HL_SETTINGS[NUM_SYNTAX];
29
30enum highlight {
31    HL_NORMAL = 0,
32    HL_NUMBER,
33    HL_STRING,
34    HL_COMMENT,
35    HL_MLCOMMENT,
36    HL_ESCAPE,
37    HL_KEYWORD_1,
38    HL_KEYWORD_2,
39    HL_MATCH
40};
41
42/**
43 * Defines syntax of the supported languages.
44 */
45void initDisplay();
46
47int is_separator(int c);
48
49/**
50 * Performs highlighting on a given row.
51 */
52void renderRow(struct erow* row);
53
54/**
55 * Maps color enum to ansi codes.
56 */
57int getColor(int hl);
58
59/**
60 * Updates view of the editor based on cursor position.
61 */
62void scroll();
63
64void drawWelcome(abuf* ab);
65
66void drawStatus(abuf* ab);
67
68void drawMessageBar(abuf* ab);
69
70void drawRows(abuf* ab);
71
72/**
73 * Drives the drawing of the display.
74 */
75void refresh();
76
77#endif