2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-09-16 06:02:56 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-09-16 06:02:56 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2009-09-16 06:02:56 +00:00
|
|
|
#include <stdio.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdlib.h>
|
2009-09-16 06:02:56 +00:00
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2019-08-13 15:35:48 +02:00
|
|
|
#include "ED_text.h"
|
|
|
|
|
|
2009-09-16 06:02:56 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2012-09-24 22:39:45 +00:00
|
|
|
#include "rna_internal.h" /* own include */
|
|
|
|
|
|
2009-09-16 06:02:56 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
2011-11-15 19:46:56 +00:00
|
|
|
# include "WM_api.h"
|
|
|
|
|
# include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
static void rna_Text_clear(Text *text)
|
|
|
|
|
{
|
2019-07-11 15:25:52 +10:00
|
|
|
BKE_text_clear(text);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
|
2011-11-15 19:46:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Text_write(Text *text, const char *str)
|
|
|
|
|
{
|
2019-07-11 15:25:52 +10:00
|
|
|
BKE_text_write(text, str);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
|
2011-11-15 19:46:56 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-04 05:56:41 +10:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 06:09:52 +10:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-16 06:02:56 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
void RNA_api_text(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
PropertyRNA *parm;
|
2009-09-16 06:02:56 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "rna_Text_clear");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "clear the text block");
|
2009-09-16 06:02:56 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "write", "rna_Text_write");
|
2014-01-05 01:12:48 +11:00
|
|
|
RNA_def_function_ui_description(
|
|
|
|
|
func, "write text at the cursor location and advance to the end of the text block");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
parm = RNA_def_string(func, "text", "Text", 0, "", "New text for this data-block");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2019-08-13 15:35:48 +02:00
|
|
|
|
|
|
|
|
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");
|
2019-10-04 05:56:41 +10:00
|
|
|
|
|
|
|
|
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);
|
2019-10-04 06:09:52 +10:00
|
|
|
|
|
|
|
|
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);
|
2019-10-04 06:12:27 +10:00
|
|
|
parm = RNA_def_int(func, "character", 0, 0, INT_MAX, "Character", "", 0, INT_MAX);
|
2019-10-04 06:09:52 +10:00
|
|
|
RNA_def_boolean(func, "select", false, "", "Select when moving the cursor");
|
2009-09-16 06:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|