[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53838] trunk/blender/source/blender/ editors/space_text: text syntax highlighting: don' t use utf8 stepping if we know the text is ascii

Campbell Barton ideasman42 at gmail.com
Wed Jan 16 05:05:08 CET 2013


Revision: 53838
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53838
Author:   campbellbarton
Date:     2013-01-16 04:05:01 +0000 (Wed, 16 Jan 2013)
Log Message:
-----------
text syntax highlighting: don't use utf8 stepping if we know the text is ascii

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_text/text_format.c
    trunk/blender/source/blender/editors/space_text/text_format.h
    trunk/blender/source/blender/editors/space_text/text_format_lua.c
    trunk/blender/source/blender/editors/space_text/text_format_osl.c
    trunk/blender/source/blender/editors/space_text/text_format_py.c

Modified: trunk/blender/source/blender/editors/space_text/text_format.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_format.c	2013-01-16 03:43:09 UTC (rev 53837)
+++ trunk/blender/source/blender/editors/space_text/text_format.c	2013-01-16 04:05:01 UTC (rev 53838)
@@ -168,7 +168,26 @@
 	*str_p = str;
 	*fmt_p = fmt;
 }
+/**
+ * ascii version of #text_format_fill,
+ * use when we no the text being stepped over is ascii (as is the case for most keywords)
+ */
+void text_format_fill_ascii(const char **str_p, char **fmt_p, const char type, const int len)
+{
+	const char *str = *str_p;
+	char *fmt = *fmt_p;
 
+	memset(fmt, type, len);
+
+	str += len - 1;
+	fmt += len - 1;
+
+	BLI_assert(*str != '\0');
+
+	*str_p = str;
+	*fmt_p = fmt;
+}
+
 /* *** Registration *** */
 static ListBase tft_lb = {NULL, NULL};
 void ED_text_format_register(TextFormatType *tft)

Modified: trunk/blender/source/blender/editors/space_text/text_format.h
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_format.h	2013-01-16 03:43:09 UTC (rev 53837)
+++ trunk/blender/source/blender/editors/space_text/text_format.h	2013-01-16 04:05:01 UTC (rev 53838)
@@ -60,6 +60,7 @@
 
 int  text_check_format_len(TextLine *line, unsigned int len);
 void text_format_fill(const char **str_p, char **fmt_p, const char type, const int len);
+void text_format_fill_ascii(const char **str_p, char **fmt_p, const char type, const int len);
 
 /* *** Generalize Formatting *** */
 typedef struct TextFormatType {

Modified: trunk/blender/source/blender/editors/space_text/text_format_lua.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_format_lua.c	2013-01-16 03:43:09 UTC (rev 53837)
+++ trunk/blender/source/blender/editors/space_text/text_format_lua.c	2013-01-16 04:05:01 UTC (rev 53838)
@@ -258,7 +258,7 @@
 			/* Booleans */
 			else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_lua_find_bool(str)) != -1) {
 				if (i > 0) {
-					text_format_fill(&str, &fmt, FMT_TYPE_NUMERAL, i);
+					text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
 				}
 				else {
 					str += BLI_str_utf8_size_safe(str) - 1;
@@ -282,7 +282,7 @@
 				else if ((i = txtfmt_lua_find_keyword(str))      != -1) prev = FMT_TYPE_KEYWORD;
 
 				if (i > 0) {
-					text_format_fill(&str, &fmt, prev, i);
+					text_format_fill_ascii(&str, &fmt, prev, i);
 				}
 				else {
 					str += BLI_str_utf8_size_safe(str) - 1;

Modified: trunk/blender/source/blender/editors/space_text/text_format_osl.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_format_osl.c	2013-01-16 03:43:09 UTC (rev 53837)
+++ trunk/blender/source/blender/editors/space_text/text_format_osl.c	2013-01-16 04:05:01 UTC (rev 53838)
@@ -295,7 +295,12 @@
 				else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
 
 				if (i > 0) {
-					text_format_fill(&str, &fmt, prev, i);
+					if (prev == FMT_TYPE_DIRECTIVE) {  /* can contain utf8 */
+						text_format_fill(&str, &fmt, prev, i);
+					}
+					else {
+						text_format_fill_ascii(&str, &fmt, prev, i);
+					}
 				}
 				else {
 					str += BLI_str_utf8_size_safe(str) - 1;

Modified: trunk/blender/source/blender/editors/space_text/text_format_py.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_format_py.c	2013-01-16 03:43:09 UTC (rev 53837)
+++ trunk/blender/source/blender/editors/space_text/text_format_py.c	2013-01-16 04:05:01 UTC (rev 53838)
@@ -259,7 +259,7 @@
 			/* Booleans */
 			else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_py_find_bool(str)) != -1) {
 				if (i > 0) {
-					text_format_fill(&str, &fmt, FMT_TYPE_NUMERAL, i);
+					text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
 				}
 				else {
 					str += BLI_str_utf8_size_safe(str) - 1;
@@ -284,7 +284,12 @@
 				else if ((i = txtfmt_py_find_decorator(str))    != -1) prev = FMT_TYPE_DIRECTIVE;
 
 				if (i > 0) {
-					text_format_fill(&str, &fmt, prev, i);
+					if (prev == FMT_TYPE_DIRECTIVE) {  /* can contain utf8 */
+						text_format_fill(&str, &fmt, prev, i);
+					}
+					else {
+						text_format_fill_ascii(&str, &fmt, prev, i);
+					}
 				}
 				else {
 					str += BLI_str_utf8_size_safe(str) - 1;




More information about the Bf-blender-cvs mailing list