From f3a71ba5180226ef3d6dabb22b31ccfe9623cd99 Mon Sep 17 00:00:00 2001 From: xolatile Date: Tue, 12 Sep 2023 05:04:54 -0400 Subject: [PATCH] Synchronized changes with xyntax... --- xighlight.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/xighlight.c b/xighlight.c index 6065b51..14df5f3 100644 --- a/xighlight.c +++ b/xighlight.c @@ -14,23 +14,10 @@ int main (void) { int offset = 0; int word = 0; - int index = 0; + int select = 0; int length = 0; char * buffer = NULL; - int whitespace = 0; - int preprocessor = 0; - int line_comment = 0; - int multiline_comment = 0; - int character = 0; - int string = 0; - int operator = 0; - int keyword = 0; - int digit = 0; - int uppercase = 0; - int lowercase = 0; - int underscore = 0; - char * separator = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n"; char * c_keywords [32] = { @@ -40,32 +27,32 @@ int main (void) { "char", "short", "int", "long", "signed", "unsigned", "float", "double" }; - syntax_define (& whitespace, 1, 0, " \t\r\n", "", '\0', COLOUR_WHITE, EFFECT_NORMAL); - syntax_define (& preprocessor, 0, 0, "#", "\n", '\\', COLOUR_PINK, EFFECT_BOLD); - syntax_define (& line_comment, 0, 0, "//", "\n", '\0', COLOUR_GREY, EFFECT_BOLD); - syntax_define (& multiline_comment, 0, 0, "/*", "*/", '\0', COLOUR_GREY, EFFECT_BOLD); - syntax_define (& character, 0, 0, "'", "'", '\\', COLOUR_RED, EFFECT_NORMAL); - syntax_define (& string, 0, 0, "\"", "\"", '\\', COLOUR_RED, EFFECT_BOLD); - syntax_define (& operator, 1, 0, ".,:;<=>+-*/%!&~^?|()[]{}", "", '\0', COLOUR_CYAN, EFFECT_NORMAL); + (void) syntax_define (1, 0, " \t\r\n", "", '\0', COLOUR_WHITE, EFFECT_NORMAL); + (void) syntax_define (0, 0, "#", "\n", '\\', COLOUR_PINK, EFFECT_BOLD); + (void) syntax_define (0, 0, "//", "\n", '\0', COLOUR_GREY, EFFECT_BOLD); + (void) syntax_define (0, 0, "/*", "*/", '\0', COLOUR_GREY, EFFECT_BOLD); + (void) syntax_define (0, 0, "'", "'", '\\', COLOUR_RED, EFFECT_NORMAL); + (void) syntax_define (0, 0, "\"", "\"", '\\', COLOUR_RED, EFFECT_BOLD); + (void) syntax_define (1, 0, ".,:;<=>+-*/%!&~^?|()[]{}", "", '\0', COLOUR_CYAN, EFFECT_NORMAL); for (word = 0; word != 32; ++word) { - syntax_define (& keyword, 0, 1, c_keywords [word], separator, '\0', COLOUR_BLUE, EFFECT_BOLD); + (void) syntax_define (0, 1, c_keywords [word], separator, '\0', COLOUR_BLUE, EFFECT_BOLD); } - syntax_define (& digit, 1, 1, "0123456789", separator, '\0', COLOUR_CYAN, EFFECT_BOLD); - syntax_define (& uppercase, 1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separator, '\0', COLOUR_PINK, EFFECT_ITALIC); - syntax_define (& lowercase, 1, 1, "abcdefghijklmnopqrstuvwxyz", separator, '\0', COLOUR_WHITE, EFFECT_ITALIC); - syntax_define (& underscore, 0, 1, "_", separator, '\0', COLOUR_PINK, EFFECT_BOLD); + (void) syntax_define (1, 1, "0123456789", separator, '\0', COLOUR_CYAN, EFFECT_BOLD); + (void) syntax_define (1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separator, '\0', COLOUR_PINK, EFFECT_ITALIC); + (void) syntax_define (1, 1, "abcdefghijklmnopqrstuvwxyz", separator, '\0', COLOUR_WHITE, EFFECT_ITALIC); + (void) syntax_define (0, 1, "_", separator, '\0', COLOUR_PINK, EFFECT_BOLD); buffer = record (); for (offset = 0; buffer [offset] != '\0'; offset += length) { - syntax_select (& buffer [offset], & index, & length); + select = syntax_select (& buffer [offset], & length); - if (index >= syntax_count) { + if (select >= syntax_count) { curses_style (EFFECT_NORMAL, COLOUR_WHITE); } else { - curses_style (syntax_effect [index], syntax_colour [index]); + curses_style (syntax_effect [select], syntax_colour [select]); } out (& buffer [offset], length);