Blender  V2.93
BKE_text.h
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  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 #pragma once
20 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 struct Main;
30 struct Text;
31 struct TextLine;
32 
33 void BKE_text_free_lines(struct Text *text);
34 struct Text *BKE_text_add(struct Main *bmain, const char *name);
36 bool BKE_text_reload(struct Text *text);
37 struct Text *BKE_text_load_ex(struct Main *bmain,
38  const char *file,
39  const char *relpath,
40  const bool is_internal);
41 struct Text *BKE_text_load(struct Main *bmain, const char *file, const char *relpath);
42 void BKE_text_clear(struct Text *text);
43 void BKE_text_write(struct Text *text, const char *str);
44 int BKE_text_file_modified_check(struct Text *text);
45 void BKE_text_file_modified_ignore(struct Text *text);
46 
47 char *txt_to_buf(struct Text *text, int *r_buf_strlen);
48 void txt_clean_text(struct Text *text);
49 void txt_order_cursors(struct Text *text, const bool reverse);
50 int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
51 bool txt_has_sel(struct Text *text);
52 int txt_get_span(struct TextLine *from, struct TextLine *to);
53 void txt_move_up(struct Text *text, const bool sel);
54 void txt_move_down(struct Text *text, const bool sel);
55 void txt_move_left(struct Text *text, const bool sel);
56 void txt_move_right(struct Text *text, const bool sel);
57 void txt_jump_left(struct Text *text, const bool sel, const bool use_init_step);
58 void txt_jump_right(struct Text *text, const bool sel, const bool use_init_step);
59 void txt_move_bof(struct Text *text, const bool sel);
60 void txt_move_eof(struct Text *text, const bool sel);
61 void txt_move_bol(struct Text *text, const bool sel);
62 void txt_move_eol(struct Text *text, const bool sel);
63 void txt_move_toline(struct Text *text, unsigned int line, const bool sel);
64 void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, const bool sel);
65 void txt_pop_sel(struct Text *text);
66 void txt_delete_char(struct Text *text);
67 void txt_delete_word(struct Text *text);
68 void txt_delete_selected(struct Text *text);
69 void txt_sel_all(struct Text *text);
70 void txt_sel_clear(struct Text *text);
71 void txt_sel_line(struct Text *text);
72 void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc);
73 char *txt_sel_to_buf(struct Text *text, int *r_buf_strlen);
74 void txt_insert_buf(struct Text *text, const char *in_buffer);
75 void txt_split_curline(struct Text *text);
76 void txt_backspace_char(struct Text *text);
77 void txt_backspace_word(struct Text *text);
78 bool txt_add_char(struct Text *text, unsigned int add);
79 bool txt_add_raw_char(struct Text *text, unsigned int add);
80 bool txt_replace_char(struct Text *text, unsigned int add);
81 bool txt_unindent(struct Text *text);
82 void txt_comment(struct Text *text);
83 void txt_indent(struct Text *text);
84 bool txt_uncomment(struct Text *text);
85 void txt_move_lines(struct Text *text, const int direction);
86 void txt_duplicate_line(struct Text *text);
87 int txt_setcurr_tab_spaces(struct Text *text, int space);
88 bool txt_cursor_is_line_start(struct Text *text);
89 bool txt_cursor_is_line_end(struct Text *text);
90 
91 int txt_calc_tab_left(struct TextLine *tl, int ch);
92 int txt_calc_tab_right(struct TextLine *tl, int ch);
93 
94 /* utility functions, could be moved somewhere more generic but are python/text related */
95 int text_check_bracket(const char ch);
96 bool text_check_delim(const char ch);
97 bool text_check_digit(const char ch);
98 bool text_check_identifier(const char ch);
99 bool text_check_identifier_nodigit(const char ch);
100 bool text_check_whitespace(const char ch);
101 int text_find_identifier_start(const char *str, int i);
102 
103 /* defined in bpy_interface.c */
104 extern int text_check_identifier_unicode(const unsigned int ch);
105 extern int text_check_identifier_nodigit_unicode(const unsigned int ch);
106 
107 enum {
110 };
111 
112 /* Fast non-validating buffer conversion for undo. */
113 char *txt_to_buf_for_undo(struct Text *text, int *r_buf_len);
114 void txt_from_buf_for_undo(struct Text *text, const char *buf, int buf_len);
115 
116 #ifdef __cplusplus
117 }
118 #endif
void txt_move_eol(struct Text *text, const bool sel)
Definition: text.c:1063
char * txt_sel_to_buf(struct Text *text, int *r_buf_strlen)
Definition: text.c:1555
void txt_move_left(struct Text *text, const bool sel)
Definition: text.c:905
int BKE_text_file_modified_check(struct Text *text)
Definition: text.c:557
void txt_split_curline(struct Text *text)
Definition: text.c:1762
int txt_setcurr_tab_spaces(struct Text *text, int space)
Definition: text.c:2320
void txt_delete_selected(struct Text *text)
Definition: text.c:2038
void txt_delete_char(struct Text *text)
Definition: text.c:1871
void txt_clean_text(struct Text *text)
Definition: text.c:673
void txt_sel_line(struct Text *text)
Definition: text.c:1309
void txt_move_right(struct Text *text, const bool sel)
Definition: text.c:949
bool text_check_identifier(const char ch)
Definition: text.c:2426
bool txt_replace_char(struct Text *text, unsigned int add)
Definition: text.c:2044
void txt_backspace_char(struct Text *text)
Definition: text.c:1918
void txt_sel_clear(struct Text *text)
Definition: text.c:1301
bool txt_add_char(struct Text *text, unsigned int add)
Definition: text.c:2028
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
int txt_calc_tab_left(struct TextLine *tl, int ch)
Definition: text.c:864
void txt_delete_word(struct Text *text)
Definition: text.c:1911
int text_check_identifier_unicode(const unsigned int ch)
Definition: text.c:2470
struct Text * BKE_text_add(struct Main *bmain, const char *name)
Definition: text.c:292
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition: text.c:2033
bool txt_uncomment(struct Text *text)
Definition: text.c:2256
int txt_get_span(struct TextLine *from, struct TextLine *to)
Definition: text.c:716
void txt_jump_left(struct Text *text, const bool sel, const bool use_init_step)
Definition: text.c:993
char * txt_to_buf(struct Text *text, int *r_buf_strlen)
Definition: text.c:1478
void txt_move_bol(struct Text *text, const bool sel)
Definition: text.c:1041
int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition: text.c:1704
bool text_check_digit(const char ch)
Definition: text.c:2415
void BKE_text_free_lines(struct Text *text)
Definition: text.c:276
int txt_calc_tab_right(struct TextLine *tl, int ch)
Definition: text.c:884
void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, const bool sel)
Definition: text.c:1137
void txt_move_eof(struct Text *text, const bool sel)
Definition: text.c:1108
void txt_order_cursors(struct Text *text, const bool reverse)
Definition: text.c:1218
void txt_move_lines(struct Text *text, const int direction)
Definition: text.c:2289
void txt_backspace_word(struct Text *text)
Definition: text.c:1963
void txt_insert_buf(struct Text *text, const char *in_buffer)
Definition: text.c:1647
int text_check_bracket(const char ch)
Definition: text.c:2383
void txt_comment(struct Text *text)
Definition: text.c:2244
int text_check_identifier_nodigit_unicode(const unsigned int ch)
Definition: text.c:2475
bool text_check_delim(const char ch)
Definition: text.c:2402
void BKE_text_file_modified_ignore(struct Text *text)
Definition: text.c:591
char * txt_to_buf_for_undo(struct Text *text, int *r_buf_len)
Definition: text.c:1390
void txt_move_up(struct Text *text, const bool sel)
Definition: text.c:804
bool txt_has_sel(struct Text *text)
Definition: text.c:1242
void txt_sel_all(struct Text *text)
Definition: text.c:1287
void txt_move_bof(struct Text *text, const bool sel)
Definition: text.c:1085
void txt_move_down(struct Text *text, const bool sel)
Definition: text.c:834
void BKE_text_write(struct Text *text, const char *str)
Definition: text.c:545
bool txt_unindent(struct Text *text)
Definition: text.c:2278
struct Text * BKE_text_load_ex(struct Main *bmain, const char *file, const char *relpath, const bool is_internal)
Definition: text.c:476
void txt_indent(struct Text *text)
Definition: text.c:2267
void txt_duplicate_line(struct Text *text)
Definition: text.c:1854
@ TXT_MOVE_LINE_UP
Definition: BKE_text.h:108
@ TXT_MOVE_LINE_DOWN
Definition: BKE_text.h:109
bool txt_cursor_is_line_end(struct Text *text)
Definition: text.c:789
void txt_from_buf_for_undo(struct Text *text, const char *buf, int buf_len)
Definition: text.c:1410
void txt_pop_sel(struct Text *text)
Definition: text.c:1212
void txt_jump_right(struct Text *text, const bool sel, const bool use_init_step)
Definition: text.c:1017
bool text_check_whitespace(const char ch)
Definition: text.c:2481
int text_find_identifier_start(const char *str, int i)
Definition: text.c:2489
bool BKE_text_reload(struct Text *text)
Definition: text.c:431
bool txt_cursor_is_line_start(struct Text *text)
Definition: text.c:784
struct Text * BKE_text_load(struct Main *bmain, const char *file, const char *relpath)
Definition: text.c:533
bool text_check_identifier_nodigit(const char ch)
Definition: text.c:2449
int txt_extended_ascii_as_utf8(char **str)
Definition: text.c:307
void txt_move_toline(struct Text *text, unsigned int line, const bool sel)
Definition: text.c:1131
StackEntry * from
FILE * file
#define str(s)
static void add(GHash *messages, MemArena *memarena, const Message *msg)
Definition: msgfmt.c:268
static GPUContext * wrap(Context *ctx)
Definition: BKE_main.h:116