Blender  V3.3
BKE_text.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 #pragma once
4 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 struct Main;
14 struct Text;
15 struct TextLine;
16 
17 #include "BLI_compiler_attrs.h"
18 
22 void BKE_text_free_lines(struct Text *text);
23 struct Text *BKE_text_add(struct Main *bmain, const char *name);
29 bool BKE_text_reload(struct Text *text);
38 struct Text *BKE_text_load_ex(struct Main *bmain,
39  const char *filepath,
40  const char *relbase,
41  bool is_internal) ATTR_NONNULL(1, 2, 3);
47 struct Text *BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase)
48  ATTR_NONNULL(1, 2, 3);
49 void BKE_text_clear(struct Text *text) ATTR_NONNULL(1);
50 void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1, 2);
58 int BKE_text_file_modified_check(struct Text *text);
59 void BKE_text_file_modified_ignore(struct Text *text);
60 
61 char *txt_to_buf(struct Text *text, size_t *r_buf_strlen)
63 void txt_clean_text(struct Text *text);
64 void txt_order_cursors(struct Text *text, bool reverse);
65 int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
66 bool txt_has_sel(const struct Text *text);
67 int txt_get_span(struct TextLine *from, struct TextLine *to);
68 void txt_move_up(struct Text *text, bool sel);
69 void txt_move_down(struct Text *text, bool sel);
70 void txt_move_left(struct Text *text, bool sel);
71 void txt_move_right(struct Text *text, bool sel);
72 void txt_jump_left(struct Text *text, bool sel, bool use_init_step);
73 void txt_jump_right(struct Text *text, bool sel, bool use_init_step);
74 void txt_move_bof(struct Text *text, bool sel);
75 void txt_move_eof(struct Text *text, bool sel);
76 void txt_move_bol(struct Text *text, bool sel);
77 void txt_move_eol(struct Text *text, bool sel);
78 void txt_move_toline(struct Text *text, unsigned int line, bool sel);
82 void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel);
83 void txt_pop_sel(struct Text *text);
84 void txt_delete_char(struct Text *text);
85 void txt_delete_word(struct Text *text);
86 void txt_delete_selected(struct Text *text);
87 void txt_sel_all(struct Text *text);
93 void txt_sel_clear(struct Text *text);
94 void txt_sel_line(struct Text *text);
95 void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc);
96 char *txt_sel_to_buf(struct Text *text, size_t *r_buf_strlen);
97 void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len)
98  ATTR_NONNULL(1, 2);
99 void txt_split_curline(struct Text *text);
100 void txt_backspace_char(struct Text *text);
101 void txt_backspace_word(struct Text *text);
102 bool txt_add_char(struct Text *text, unsigned int add);
103 bool txt_add_raw_char(struct Text *text, unsigned int add);
104 bool txt_replace_char(struct Text *text, unsigned int add);
105 bool txt_unindent(struct Text *text);
106 void txt_comment(struct Text *text);
107 void txt_indent(struct Text *text);
108 bool txt_uncomment(struct Text *text);
109 void txt_move_lines(struct Text *text, int direction);
110 void txt_duplicate_line(struct Text *text);
111 int txt_setcurr_tab_spaces(struct Text *text, int space);
112 bool txt_cursor_is_line_start(const struct Text *text);
113 bool txt_cursor_is_line_end(const struct Text *text);
114 
115 int txt_calc_tab_left(struct TextLine *tl, int ch);
116 int txt_calc_tab_right(struct TextLine *tl, int ch);
117 
121 int text_check_bracket(char ch);
122 bool text_check_delim(char ch);
123 bool text_check_digit(char ch);
124 bool text_check_identifier(char ch);
125 bool text_check_identifier_nodigit(char ch);
126 bool text_check_whitespace(char ch);
127 int text_find_identifier_start(const char *str, int i);
128 
129 /* EVIL: defined in `bpy_interface.c`. */
130 extern int text_check_identifier_unicode(unsigned int ch);
131 extern int text_check_identifier_nodigit_unicode(unsigned int ch);
132 
133 enum {
136 };
137 
138 /* Fast non-validating buffer conversion for undo. */
139 
143 char *txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len)
148 void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1, 2);
149 
150 #ifdef __cplusplus
151 }
152 #endif
bool text_check_identifier_nodigit(char ch)
Definition: text.c:2343
int text_check_identifier_unicode(unsigned int ch)
Definition: text.c:2364
void txt_move_down(struct Text *text, bool sel)
Definition: text.c:794
void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1
struct Text struct Text * BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase) ATTR_NONNULL(1
void void txt_split_curline(struct Text *text)
Definition: text.c:1649
int txt_setcurr_tab_spaces(struct Text *text, int space)
Definition: text.c:2213
bool txt_has_sel(const struct Text *text)
void txt_move_eof(struct Text *text, bool sel)
Definition: text.c:1068
void txt_delete_selected(struct Text *text)
Definition: text.c:1929
void txt_delete_char(struct Text *text)
Definition: text.c:1758
bool txt_cursor_is_line_end(const struct Text *text)
void txt_clean_text(struct Text *text)
Definition: text.c:633
void txt_sel_line(struct Text *text)
Definition: text.c:1263
void txt_move_toline(struct Text *text, unsigned int line, bool sel)
Definition: text.c:1091
bool txt_replace_char(struct Text *text, unsigned int add)
Definition: text.c:1935
int text_check_bracket(char ch)
Definition: text.c:2276
void txt_backspace_char(struct Text *text)
Definition: text.c:1806
void txt_sel_clear(struct Text *text)
Definition: text.c:1255
void txt_move_left(struct Text *text, bool sel)
Definition: text.c:865
bool txt_add_char(struct Text *text, unsigned int add)
Definition: text.c:1919
void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc)
Definition: text.c:1274
int txt_calc_tab_left(struct TextLine *tl, int ch)
Definition: text.c:824
void txt_delete_word(struct Text *text)
Definition: text.c:1799
char * txt_sel_to_buf(struct Text *text, size_t *r_buf_strlen)
Definition: text.c:1454
struct Text * BKE_text_add(struct Main *bmain, const char *name)
Definition: text.c:282
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition: text.c:1924
bool text_check_digit(char ch)
Definition: text.c:2309
bool txt_uncomment(struct Text *text)
Definition: text.c:2149
int txt_get_span(struct TextLine *from, struct TextLine *to)
Definition: text.c:676
void int BKE_text_file_modified_check(struct Text *text)
Definition: text.c:530
void txt_move_bof(struct Text *text, bool sel)
Definition: text.c:1045
char ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition: BKE_text.h:62
struct Text struct Text void BKE_text_clear(struct Text *text) ATTR_NONNULL(1)
Definition: text.c:516
void txt_move_right(struct Text *text, bool sel)
Definition: text.c:909
int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition: text.c:1591
@ TXT_MOVE_LINE_UP
Definition: BKE_text.h:134
@ TXT_MOVE_LINE_DOWN
Definition: BKE_text.h:135
void txt_move_lines(struct Text *text, int direction)
Definition: text.c:2182
void BKE_text_free_lines(struct Text *text)
Definition: text.c:266
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition: text.c:2369
int txt_calc_tab_right(struct TextLine *tl, int ch)
Definition: text.c:844
void txt_jump_left(struct Text *text, bool sel, bool use_init_step)
Definition: text.c:953
bool text_check_identifier(char ch)
Definition: text.c:2320
bool text_check_delim(char ch)
Definition: text.c:2293
void txt_move_eol(struct Text *text, bool sel)
Definition: text.c:1023
bool text_check_whitespace(char ch)
Definition: text.c:2375
void txt_backspace_word(struct Text *text)
Definition: text.c:1854
void txt_jump_right(struct Text *text, bool sel, bool use_init_step)
Definition: text.c:977
void txt_move_up(struct Text *text, bool sel)
Definition: text.c:764
void txt_comment(struct Text *text)
Definition: text.c:2137
void BKE_text_file_modified_ignore(struct Text *text)
Definition: text.c:564
void txt_move_bol(struct Text *text, bool sel)
Definition: text.c:1001
void txt_sel_all(struct Text *text)
Definition: text.c:1246
void txt_order_cursors(struct Text *text, bool reverse)
Definition: text.c:1177
bool txt_unindent(struct Text *text)
Definition: text.c:2171
void txt_indent(struct Text *text)
Definition: text.c:2160
void txt_duplicate_line(struct Text *text)
Definition: text.c:1741
struct Text * BKE_text_load_ex(struct Main *bmain, const char *filepath, const char *relbase, bool is_internal) ATTR_NONNULL(1
char * txt_to_buf(struct Text *text, size_t *r_buf_strlen) ATTR_NONNULL(1
void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len) ATTR_NONNULL(1
void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel)
Definition: text.c:1096
bool txt_cursor_is_line_start(const struct Text *text)
char * txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len) ATTR_NONNULL(1
void txt_pop_sel(struct Text *text)
Definition: text.c:1171
void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1
int text_find_identifier_start(const char *str, int i)
Definition: text.c:2383
bool BKE_text_reload(struct Text *text)
Definition: text.c:420
int txt_extended_ascii_as_utf8(char **str)
Definition: text.c:295
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_NONNULL(...)
StackEntry * from
#define str(s)
bool add(void *owner, const AttributeIDRef &attribute_id, eAttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer)
static struct PartialUpdateUser * wrap(PartialUpdateUserImpl *user)
Definition: BKE_main.h:121
char * filepath