Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-01-16 07:43:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-16 07:43:09 +0400
commit6fd5645d56b9e2d34a683fa21139d975c8be02aa (patch)
tree8824fa077e8fdcf764880b780036fb58412f0be1 /source/blender/editors/space_text/text_format.c
parentc42054762530d2ca347078a8d70cd9eac379439d (diff)
patch [#33888] Syntax Highlighting Changes
from Benjamin Tolputt (btolputt), (with minor changes) adds support for LUA syntax highlighting.
Diffstat (limited to 'source/blender/editors/space_text/text_format.c')
-rw-r--r--source/blender/editors/space_text/text_format.c27
1 files changed, 22 insertions, 5 deletions
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;
}
}