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:
authorSybren A. Stüvel <sybren@blender.org>2019-08-13 16:35:48 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-08-14 17:59:37 +0300
commit05417b22206c479b5ebe8ac8e7dd73ae154c8c96 (patch)
treeaa11344ee7e5fa0bf8c95ce380e347d11a3df16f /source/blender/blenlib/intern/path_util.c
parent72eb70f93328e4e19a319aa199f6c46a0c8ab420 (diff)
Text editor: syntax highlighting + line numbers on by default
The most common use of the text editor seems to be for scripting. Having line numbers and syntax highlighting enabled by default seems sensible. Syntax highlighting is now enabled by default, but is automatically disabled when the datablock has a non-highlighted extension. Highlighting is enabled for filenames like: - Text - Text.001 - somefile.py and is automatically disabled when the datablock has an extension for which Blender has no syntax highlighter registered. Reviewers: billreynish, campbellbarton Subscribers: brecht, billreynish Differential Revision: https://developer.blender.org/D5472
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r--source/blender/blenlib/intern/path_util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 111b530a527..18acbca00a1 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1685,6 +1685,24 @@ void BLI_split_file_part(const char *string, char *file, const size_t filelen)
}
/**
+ * Returns a pointer to the last extension (e.g. the position of the last period).
+ * Returns NULL if there is no extension.
+ */
+const char *BLI_path_extension(const char *filepath)
+{
+ const char *extension = strrchr(filepath, '.');
+ if (extension == NULL) {
+ return NULL;
+ }
+ if (BLI_first_slash(extension) != NULL) {
+ /* There is a path separator in the extension, so the '.' was found in a
+ * directory component and not in the filename. */
+ return NULL;
+ }
+ return extension;
+}
+
+/**
* Append a filename to a dir, ensuring slash separates.
*/
void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__restrict file)