Blender  V2.93
rna_text_api.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "BLI_utildefines.h"
25 
26 #include "ED_text.h"
27 
28 #include "RNA_define.h"
29 
30 #include "rna_internal.h" /* own include */
31 
32 #ifdef RNA_RUNTIME
33 
34 # include "WM_api.h"
35 # include "WM_types.h"
36 
37 static void rna_Text_clear(Text *text)
38 {
39  BKE_text_clear(text);
41 }
42 
43 static void rna_Text_write(Text *text, const char *str)
44 {
45  BKE_text_write(text, str);
47 }
48 
49 static void rna_Text_select_set(Text *text, int startl, int startc, int endl, int endc)
50 {
51  txt_sel_set(text, startl, startc, endl, endc);
53 }
54 
55 static void rna_Text_cursor_set(Text *text, int line, int ch, bool select)
56 {
57  txt_move_to(text, line, ch, select);
59 }
60 
61 #else
62 
64 {
65  FunctionRNA *func;
66  PropertyRNA *parm;
67 
68  func = RNA_def_function(srna, "clear", "rna_Text_clear");
69  RNA_def_function_ui_description(func, "clear the text block");
70 
71  func = RNA_def_function(srna, "write", "rna_Text_write");
73  func, "write text at the cursor location and advance to the end of the text block");
74  parm = RNA_def_string(func, "text", "Text", 0, "", "New text for this data-block");
76 
77  func = RNA_def_function(
78  srna, "is_syntax_highlight_supported", "ED_text_is_syntax_highlight_supported");
80  RNA_def_boolean(func, "is_syntax_highlight_supported", false, "", ""));
82  "Returns True if the editor supports syntax highlighting "
83  "for the current text datablock");
84 
85  func = RNA_def_function(srna, "select_set", "rna_Text_select_set");
86  RNA_def_function_ui_description(func, "Set selection range by line and character index");
87  parm = RNA_def_int(func, "line_start", 0, INT_MIN, INT_MAX, "Start Line", "", INT_MIN, INT_MAX);
89  parm = RNA_def_int(
90  func, "char_start", 0, INT_MIN, INT_MAX, "Start Character", "", INT_MIN, INT_MAX);
92  parm = RNA_def_int(func, "line_end", 0, INT_MIN, INT_MAX, "End Line", "", INT_MIN, INT_MAX);
94  parm = RNA_def_int(func, "char_end", 0, INT_MIN, INT_MAX, "End Character", "", INT_MIN, INT_MAX);
96 
97  func = RNA_def_function(srna, "cursor_set", "rna_Text_cursor_set");
98  RNA_def_function_ui_description(func, "Set cursor by line and (optionally) character index");
99  parm = RNA_def_int(func, "line", 0, 0, INT_MAX, "Line", "", 0, INT_MAX);
101  parm = RNA_def_int(func, "character", 0, 0, INT_MAX, "Character", "", 0, INT_MAX);
102  RNA_def_boolean(func, "select", false, "", "Select when moving the cursor");
103 }
104 
105 #endif
void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc)
Definition: text.c:1320
void BKE_text_clear(struct Text *text)
Definition: text.c:538
void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, const bool sel)
Definition: text.c:1137
void BKE_text_write(struct Text *text, const char *str)
Definition: text.c:545
@ PARM_REQUIRED
Definition: RNA_types.h:337
#define NA_EDITED
Definition: WM_types.h:462
#define NC_TEXT
Definition: WM_types.h:287
#define str(s)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void RNA_api_text(StructRNA *srna)
Definition: rna_text_api.c:63
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
void WM_main_add_notifier(unsigned int type, void *reference)