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 23:09:52 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-10-03 23:10:43 +0300
commitd289a2d4a973c3540a041cbf9c27d7b9aeb35f96 (patch)
treef848c3650abdffb6f61b13e3241679f073d22d58 /source/blender/makesrna/intern/rna_text_api.c
parentbf2d92b277b9be383b486f5c169a77399f69b6f0 (diff)
Text: add Text.cursor_set(...)
Place the cursor, optionally set selection.
Diffstat (limited to 'source/blender/makesrna/intern/rna_text_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_text_api.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_text_api.c b/source/blender/makesrna/intern/rna_text_api.c
index bcaa693524c..211f1bce442 100644
--- a/source/blender/makesrna/intern/rna_text_api.c
+++ b/source/blender/makesrna/intern/rna_text_api.c
@@ -52,6 +52,12 @@ static void rna_Text_select_set(Text *text, int startl, int startc, int endl, in
WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
}
+static void rna_Text_cursor_set(Text *text, int line, int ch, bool select)
+{
+ txt_move_to(text, line, ch, select);
+ WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
+}
+
#else
void RNA_api_text(StructRNA *srna)
@@ -87,6 +93,13 @@ void RNA_api_text(StructRNA *srna)
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);
+
+ func = RNA_def_function(srna, "cursor_set", "rna_Text_cursor_set");
+ RNA_def_function_ui_description(func, "Set cursor by line and (optionally) character index");
+ parm = RNA_def_int(func, "line", 0, 0, INT_MAX, "Line", "", 0, INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(func, "char", 0, 0, INT_MAX, "Character", "", 0, INT_MAX);
+ RNA_def_boolean(func, "select", false, "", "Select when moving the cursor");
}
#endif