From 91195d34e1f71246cadc41705004d66ab647087e Mon Sep 17 00:00:00 2001 From: cflip Date: Sun, 8 Jan 2023 14:15:01 -0700 Subject: Initial import of existing source code This is based off of snaptoken's "Build Your Own Text Editor" tutorial at https://viewsourcecode.org/snaptoken/kilo/. --- syntax.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 syntax.h (limited to 'syntax.h') diff --git a/syntax.h b/syntax.h new file mode 100644 index 0000000..0cb673e --- /dev/null +++ b/syntax.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include "editor.h" +#include "row.h" + +#define HIGHLIGHT_FLAG_NUMBERS (1 << 0) +#define HIGHLIGHT_FLAG_STRINGS (1 << 1) + +struct editor_syntax { + char* filetype; + char** filetype_match; + char** keywords; + char* single_line_comment_start; + char* multi_line_comment_start; + char* multi_line_comment_end; + int flags; +}; + +enum editor_highlight { + HIGHLIGHT_NORMAL = 0, + HIGHLIGHT_COMMENT, + HIGHLIGHT_MULTILINE_COMMENT, + HIGHLIGHT_KEYWORD1, + HIGHLIGHT_KEYWORD2, + HIGHLIGHT_STRING, + HIGHLIGHT_NUMBER, + HIGHLIGHT_MATCH +}; + +#define HIGHLIGHT_DATABASE_ENTRY_COUNT (sizeof(highlight_database) / sizeof(highlight_database[0])) + +void editor_update_syntax(struct editor_state* editor, struct editor_row* row); +int editor_syntax_to_colour(int highlight); +void editor_select_syntax_highlight(struct editor_state* editor); -- cgit v1.2.3