From 6fd5645d56b9e2d34a683fa21139d975c8be02aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Jan 2013 03:43:09 +0000 Subject: patch [#33888] Syntax Highlighting Changes from Benjamin Tolputt (btolputt), (with minor changes) adds support for LUA syntax highlighting. --- source/blender/editors/space_text/text_format.c | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_text/text_format.c') diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c index 91e1376ee28..fc8002ba0e4 100644 --- a/source/blender/editors/space_text/text_format.c +++ b/source/blender/editors/space_text/text_format.c @@ -178,14 +178,31 @@ void ED_text_format_register(TextFormatType *tft) TextFormatType *ED_text_format_get(Text *text) { - /* NOTE: once more types are added we'll need to return some type based on 'text' - * for now this function is more of a placeholder */ + TextFormatType* tft; + + if (text) { + const char *text_ext = strchr(text->id.name + 2, '.'); + if (text_ext) { + text_ext++; /* skip the '.' */ + /* Check all text formats in the static list */ + for (tft = tft_lb.first; tft; tft = tft->next) { + /* All formats should have an ext, but just in case */ + const char **ext; + for (ext = tft->ext; *ext; ext++) { + /* If extension matches text name, return the matching tft */ + if (BLI_strcasecmp(text_ext, *ext) == 0) { + return tft; + } + } + } + } - /* XXX, wrong, but OK for testing */ - if (text && BLI_testextensie(text->id.name + 2, ".osl")) { - return tft_lb.last; + /* If we make it here we never found an extension that worked - return + * the "default" text format */ + return tft_lb.first; } else { + /* Return the "default" text format */ return tft_lb.first; } } -- cgit v1.2.3