Cleanup: formatting for text highlighter

This commit is contained in:
Campbell Barton 2019-10-05 02:43:03 +10:00
parent dfcda05242
commit fc517cb079
5 changed files with 29 additions and 37 deletions

View File

@ -48,7 +48,7 @@ static int txtfmt_lua_find_keyword(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
@ -66,8 +66,7 @@ static int txtfmt_lua_find_keyword(const char *string)
} else if (STR_LITERAL_STARTSWITH(string, "then", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "until", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
} else { i = 0;
}
} else { i = 0; }
/* clang-format on */
@ -96,7 +95,7 @@ static int txtfmt_lua_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
@ -124,8 +123,7 @@ static int txtfmt_lua_find_specialvar(const char *string)
} else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) { i = len;
} else { i = 0;
}
} else { i = 0; }
/* clang-format on */
@ -140,18 +138,13 @@ static int txtfmt_lua_find_bool(const char *string)
{
int i, len;
if (STR_LITERAL_STARTSWITH(string, "nil", len)) {
i = len;
}
else if (STR_LITERAL_STARTSWITH(string, "true", len)) {
i = len;
}
else if (STR_LITERAL_STARTSWITH(string, "false", len)) {
i = len;
}
else {
i = 0;
}
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "nil", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
} else { i = 0; }
/* clang-format on */
@ -169,10 +162,9 @@ static char txtfmt_lua_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
if ((txtfmt_lua_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
if ((txtfmt_lua_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
} else if ((txtfmt_lua_find_keyword(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
} else { fmt = FMT_TYPE_DEFAULT;
}
} else { fmt = FMT_TYPE_DEFAULT; }
/* clang-format on */

View File

@ -40,7 +40,7 @@ static int txtfmt_osl_find_builtinfunc(const char *string)
/* list is from
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "closure", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "color", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "continue", len)) { i = len;
@ -86,7 +86,7 @@ static int txtfmt_osl_find_reserved(const char *string)
/* list is from...
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
if (STR_LITERAL_STARTSWITH(string, "bool", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "bool", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "catch", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "char", len)) { i = len;
@ -149,7 +149,7 @@ static int txtfmt_osl_find_specialvar(const char *string)
/* clang-format off */
/* OSL shader types */
if (STR_LITERAL_STARTSWITH(string, "shader", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "shader", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "surface", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "volume", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) { i = len;
@ -189,7 +189,7 @@ static char txtfmt_osl_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
if ((txtfmt_osl_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
if ((txtfmt_osl_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
} else if ((txtfmt_osl_find_builtinfunc(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
} else if ((txtfmt_osl_find_reserved(str)) != -1) { fmt = FMT_TYPE_RESERVED;
} else if ((txtfmt_osl_find_preprocessor(str)) != -1) { fmt = FMT_TYPE_DIRECTIVE;
@ -323,7 +323,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_osl_format_identifier()' */
if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
} else if ((i = txtfmt_osl_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
} else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;

View File

@ -48,7 +48,7 @@ static int txtfmt_pov_find_keyword(const char *string)
int i, len;
/* Language Directives */
if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "version", len)) { i = len;
@ -101,7 +101,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
/* clang-format off */
/* Float Functions */
if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) { i = len;
@ -261,7 +261,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
/* clang-format off */
/* Language Keywords */
if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) { i = len;
@ -500,7 +500,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
{
int i, len;
/* Modifiers */
if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) { i = len;
@ -710,7 +710,7 @@ static int txtfmt_pov_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;

View File

@ -49,7 +49,7 @@ static int txtfmt_ini_find_keyword(const char *string)
/* clang-format off */
/* Language Directives */
if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "declare", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
@ -111,7 +111,7 @@ static int txtfmt_ini_find_reserved(const char *string)
* list is from...
* http://www.povray.org/documentation/view/3.7.0/212/
*/
if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) { i = len;
@ -321,7 +321,7 @@ static int txtfmt_ini_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;

View File

@ -58,7 +58,7 @@ static int txtfmt_py_find_builtinfunc(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "async", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "await", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
@ -114,7 +114,7 @@ static int txtfmt_py_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "def", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "def", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "class", len)) { i = len;
} else { i = 0;
}
@ -155,7 +155,7 @@ static int txtfmt_py_find_bool(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "None", len)) { i = len;
if (STR_LITERAL_STARTSWITH(string, "None", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "True", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "False", len)) { i = len;
} else { i = 0;