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:18:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-16 07:18:22 +0400
commita6d9bcd36d6e703b515e4d68dacdc9a0050b3719 (patch)
tree6b88d141fcc86f0e4d53764b10563e608d26506d /source/blender/editors/space_text/text_format.c
parente6e8bd5db42c8bc58aa5f439e2dbe479cb7e9834 (diff)
text syntax highlighting, add utility function 'text_format_fill()' which fills in the line with a formatting value.
this fixes a mistake in OSL lexer which would comment all lines after '//'
Diffstat (limited to 'source/blender/editors/space_text/text_format.c')
-rw-r--r--source/blender/editors/space_text/text_format.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c
index 294f94dd4b7..91e1376ee28 100644
--- a/source/blender/editors/space_text/text_format.c
+++ b/source/blender/editors/space_text/text_format.c
@@ -140,6 +140,35 @@ int text_check_format_len(TextLine *line, unsigned int len)
return 1;
}
+/**
+ * Fill the string with formatting constant,
+ * advancing \a str_p and \a fmt_p
+ *
+ * \param len length in bytes
+ */
+void text_format_fill(const char **str_p, char **fmt_p, const char type, const int len)
+{
+ const char *str = *str_p;
+ char *fmt = *fmt_p;
+ int i = 0;
+
+ while (i < len) {
+ const int size = BLI_str_utf8_size_safe(str);
+ *fmt++ = type;
+
+ str += size;
+ i += size;
+ }
+
+ str--;
+ fmt--;
+
+ BLI_assert(*str != '\0');
+
+ *str_p = str;
+ *fmt_p = fmt;
+}
+
/* *** Registration *** */
static ListBase tft_lb = {NULL, NULL};
void ED_text_format_register(TextFormatType *tft)