Text: add Text.cursor_set(...)

Place the cursor, optionally set selection.
This commit is contained in:
Kai Jægersen 2019-10-04 06:09:52 +10:00 committed by Campbell Barton
parent bf2d92b277
commit d289a2d4a9
1 changed files with 13 additions and 0 deletions

View File

@ -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