c.h (5411B)
1 #include "handy_defines.h" 2 3 #ifdef macro_color 4 #define color_macro(_str) {COLOR_WORD,{_str}, macro_color} 5 #endif 6 7 const struct syntax_scheme_entry c_syntax[] = { 8 // Coloring type arguments Color 9 10 // strings 11 #ifdef string_color 12 {COLOR_AROUND_TO_LINE, {"\"", "\""}, string_color}, 13 {COLOR_STR, {"''"}, normal_color}, 14 {COLOR_AROUND_TO_LINE, {"'", "'"}, string_color}, 15 {COLOR_INSIDE_TO_LINE, {"#include <", ">"}, string_color}, 16 {COLOR_INSIDE_TO_LINE, {"#include<", ">"}, string_color}, 17 #endif 18 // comments 19 #ifdef comment_color 20 {COLOR_AROUND, {"/*", "*/"}, comment_color}, 21 {COLOR_AROUND, {"//", "\n"}, comment_color}, 22 #endif 23 // macros 24 #ifdef macro_color 25 #ifdef constants_color 26 {COLOR_STR_AFTER_WORD, {"#ifdef"}, constants_color}, 27 {COLOR_STR_AFTER_WORD, {"#ifndef"}, constants_color}, 28 {COLOR_STR_AFTER_WORD, {"#define"}, constants_color}, 29 {COLOR_STR_AFTER_WORD, {"#undef"}, constants_color}, 30 #endif // constants_color 31 #ifdef string_color 32 {COLOR_INSIDE_TO_LINE, {"#error ", "\n"}, string_color}, 33 #endif // string_color 34 {COLOR_WORD_STARTING_WITH_STR, {"#"}, {.fg = yellow, .mode = ATTR_BOLD}}, 35 color_macro("sizeof"), color_macro("alignof"), 36 color_macro("offsetof"), 37 {COLOR_STR_AFTER_WORD, {"defined"}, constants_color}, 38 color_macro("defined"), 39 #endif 40 // operators 41 #ifdef operator_color 42 {COLOR_STR, {"!="}, normal_color}, 43 {COLOR_STR, {"!"}, operator_color}, 44 {COLOR_STR, {"~"}, operator_color}, 45 {COLOR_STR, {"?"}, operator_color}, 46 #endif 47 // keywords 48 #ifdef keyword_color 49 {COLOR_STR, {"..."}, keyword_color}, 50 {COLOR_WORD_STR, {"struct", "{"},keyword_color}, 51 {COLOR_WORD_STR, {"union", "{"}, keyword_color}, 52 {COLOR_WORD_STR, {"enum", "{"}, keyword_color}, 53 {COLOR_STR_AFTER_WORD, {"struct"}, type_color}, 54 {COLOR_STR_AFTER_WORD, {"union"}, type_color}, 55 {COLOR_STR_AFTER_WORD, {"enum"}, type_color}, 56 {COLOR_STR_AFTER_WORD, {"goto"}, constants_color}, 57 {COLOR_WORD_INSIDE, {"}", ":"}, constants_color}, 58 {COLOR_WORD_INSIDE, {"{", ":"}, constants_color}, 59 {COLOR_WORD_INSIDE, {";", ":"}, constants_color}, 60 color_keyword("struct"), color_keyword("enum"), 61 color_keyword("union"), color_keyword("const"), 62 color_keyword("typedef"), color_keyword("extern"), 63 color_keyword("static"), color_keyword("inline"), 64 color_keyword("if"), color_keyword("else"), 65 color_keyword("for"), color_keyword("while"), 66 color_keyword("case"), color_keyword("switch"), 67 color_keyword("do"), color_keyword("return"), 68 color_keyword("break"), color_keyword("continue"), 69 color_keyword("goto"), color_keyword("restrict"), 70 color_keyword("register"), 71 #endif 72 // functions 73 #ifdef function_color 74 {COLOR_WORD_BEFORE_STR, {"("}, function_color}, 75 #endif 76 #ifdef constants_color 77 {COLOR_UPPER_CASE_WORD, {0}, constants_color}, 78 #endif 79 // types 80 #ifdef type_color 81 color_type("int"), color_type("unsigned"), 82 color_type("long"), color_type("short"), 83 color_type("char"), color_type("void"), 84 color_type("float"), color_type("double"), 85 color_type("complex"), color_type("bool"), 86 color_type("_Bool"), color_type("FILE"), 87 color_type("va_list"), 88 {COLOR_WORD_ENDING_WITH_STR, {"_t"}, type_color}, 89 {COLOR_WORD_ENDING_WITH_STR, {"_type"}, type_color}, 90 {COLOR_WORD_ENDING_WITH_STR, {"T"}, type_color}, 91 #endif 92 // numbers 93 #ifdef number_color 94 color_numbers(), 95 #endif 96 }; 97 98 #define c_word_seperators default_word_seperators 99 100 const struct indent_scheme_entry c_indent[] = { 101 {INDENT_REMOVE, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, 0, {"}", "{"} }, 102 {INDENT_NEW, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, -1, {"{", "}"} }, 103 104 {INDENT_NEW, INDENT_LINE_ONLY_CONTAINS_STR, -1, {"("} }, 105 {INDENT_KEEP_OPENER, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, -1, {"(", ")"} }, 106 {INDENT_REMOVE, INDENT_LINE_ONLY_CONTAINS_STR, 0, {")"} }, 107 {INDENT_REMOVE, INDENT_LINE_ONLY_CONTAINS_STR, 0, {");"} }, 108 {INDENT_RETURN_TO_OPENER_BASE_INDENT, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, -1, {")", "("} }, 109 110 {INDENT_NEW, INDENT_LINE_ONLY_CONTAINS_STR, -1, {"["} }, 111 {INDENT_REMOVE, INDENT_LINE_ONLY_CONTAINS_STR, 0, {"]"} }, 112 {INDENT_REMOVE, INDENT_LINE_ONLY_CONTAINS_STR, 0, {"];"} }, 113 {INDENT_KEEP_OPENER, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, -1, {"[", "]"} }, 114 {INDENT_RETURN_TO_OPENER_BASE_INDENT, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, -1, {"]", "["} }, 115 116 {INDENT_REMOVE, INDENT_LINE_ENDS_WITH_STR, 0, {":"} }, 117 {INDENT_NEW, INDENT_LINE_ENDS_WITH_STR, -1, {":"} }, 118 {INDENT_KEEP, INDENT_LINE_ENDS_WITH_STR, -1, {";"} }, 119 {INDENT_KEEP, INDENT_LINE_CONTAINS_STR_MORE_THAN_STR, 0, {"{", "}"} }, 120 {INDENT_NEW, INDENT_LINE_CONTAINS_WORD, -1, {"else"} }, 121 {INDENT_NEW, INDENT_LINE_CONTAINS_WORD, -1, {"if"} }, 122 {INDENT_NEW, INDENT_LINE_CONTAINS_WORD, -1, {"for"} }, 123 {INDENT_NEW, INDENT_LINE_CONTAINS_WORD, -1, {"while"} }, 124 125 };