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/makesrna/intern
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/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_space.c17
-rw-r--r--source/blender/makesrna/intern/rna_text.c2
-rw-r--r--source/blender/makesrna/intern/rna_text_api.c10
3 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 6dc0cf045cd..28f64e4e1f0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -32,6 +32,8 @@
#include "BKE_studiolight.h"
#include "BKE_sequencer.h"
+#include "ED_text.h"
+
#include "BLI_math.h"
#include "DNA_action_types.h"
@@ -1504,6 +1506,11 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr,
WM_main_add_notifier(NC_TEXT | NA_SELECTED, st->text);
}
+static bool rna_SpaceTextEditor_text_is_syntax_highlight_supported(struct SpaceText *space)
+{
+ return ED_text_is_syntax_highlight_supported(space->text);
+}
+
static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -4539,6 +4546,7 @@ static void rna_def_space_text(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "SpaceTextEditor", "Space");
RNA_def_struct_sdna(srna, "SpaceText");
@@ -4568,6 +4576,15 @@ static void rna_def_space_text(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_LINENUMBERS_ON, 0);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL);
+ func = RNA_def_function(srna,
+ "is_syntax_highlight_supported",
+ "rna_SpaceTextEditor_text_is_syntax_highlight_supported");
+ RNA_def_function_return(func,
+ RNA_def_boolean(func, "is_syntax_highlight_supported", false, "", ""));
+ RNA_def_function_ui_description(func,
+ "Returns True if the editor supports syntax highlighting "
+ "for the current text datablock");
+
prop = RNA_def_property(srna, "show_syntax_highlight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0);
RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting");
diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c
index b09b5327f57..64a23dfa985 100644
--- a/source/blender/makesrna/intern/rna_text.c
+++ b/source/blender/makesrna/intern/rna_text.c
@@ -27,6 +27,8 @@
#include "BKE_text.h"
+#include "ED_text.h"
+
#include "RNA_define.h"
#include "rna_internal.h"
diff --git a/source/blender/makesrna/intern/rna_text_api.c b/source/blender/makesrna/intern/rna_text_api.c
index 4ca48226ee9..524dcfa9ad7 100644
--- a/source/blender/makesrna/intern/rna_text_api.c
+++ b/source/blender/makesrna/intern/rna_text_api.c
@@ -23,6 +23,8 @@
#include "BLI_utildefines.h"
+#include "ED_text.h"
+
#include "RNA_define.h"
#include "rna_internal.h" /* own include */
@@ -59,6 +61,14 @@ void RNA_api_text(StructRNA *srna)
func, "write text at the cursor location and advance to the end of the text block");
parm = RNA_def_string(func, "text", "Text", 0, "", "New text for this data-block");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ func = RNA_def_function(
+ srna, "is_syntax_highlight_supported", "ED_text_is_syntax_highlight_supported");
+ RNA_def_function_return(func,
+ RNA_def_boolean(func, "is_syntax_highlight_supported", false, "", ""));
+ RNA_def_function_ui_description(func,
+ "Returns True if the editor supports syntax highlighting "
+ "for the current text datablock");
}
#endif