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:
authorKai Jægersen <kaio>2019-10-03 22:56:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-10-03 23:00:08 +0300
commitbf2d92b277b9be383b486f5c169a77399f69b6f0 (patch)
tree056ea8e6ca782a92cf6c94bcfdb02f4d52527012 /source/blender/makesrna
parent2ba8adca4ffd0df0c537fcdf991c56bd6d5b7def (diff)
Text: add Text.select_set(...)
Support setting the selection for a text buffer with support for negative indices, select_set(1, 1, -1, -1) selects the entire buffer.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_text_api.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_text_api.c b/source/blender/makesrna/intern/rna_text_api.c
index 524dcfa9ad7..bcaa693524c 100644
--- a/source/blender/makesrna/intern/rna_text_api.c
+++ b/source/blender/makesrna/intern/rna_text_api.c
@@ -46,6 +46,12 @@ static void rna_Text_write(Text *text, const char *str)
WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
}
+static void rna_Text_select_set(Text *text, int startl, int startc, int endl, int endc)
+{
+ txt_sel_set(text, startl, startc, endl, endc);
+ WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
+}
+
#else
void RNA_api_text(StructRNA *srna)
@@ -69,6 +75,18 @@ void RNA_api_text(StructRNA *srna)
RNA_def_function_ui_description(func,
"Returns True if the editor supports syntax highlighting "
"for the current text datablock");
+
+ func = RNA_def_function(srna, "select_set", "rna_Text_select_set");
+ RNA_def_function_ui_description(func, "Set selection range by line and character index");
+ parm = RNA_def_int(func, "line_start", 0, INT_MIN, INT_MAX, "Start Line", "", INT_MIN, INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(
+ func, "char_start", 0, INT_MIN, INT_MAX, "Start Character", "", INT_MIN, INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(func, "line_end", 0, INT_MIN, INT_MAX, "End Line", "", INT_MIN, INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(func, "char_end", 0, INT_MIN, INT_MAX, "End Character", "", INT_MIN, INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
#endif