+/Femto
toy text editor
git clone https://git.julia.blue/+/Femto
973c5b9
master
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 { 19char * filetype ; 20char * filematch ; 21char * slCommentStart ; 22char * mlCommentStart ; 23char * mlCommentEnd ; 24char ** keywords ; 25int flags ; 26}; 27 28extern struct editorSyntax HL_SETTINGS [NUM_SYNTAX ]; 29 30enum highlight { 31HL_NORMAL = 0 , 32HL_NUMBER , 33HL_STRING , 34HL_COMMENT , 35HL_MLCOMMENT , 36HL_ESCAPE , 37HL_KEYWORD_1 , 38HL_KEYWORD_2 , 39HL_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