Blender V4.3
BKE_text.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14struct Main;
15struct Text;
16struct TextLine;
17
18#include "BLI_compiler_attrs.h"
19
23void BKE_text_free_lines(struct Text *text);
24struct Text *BKE_text_add(struct Main *bmain, const char *name);
30bool BKE_text_reload(struct Text *text);
39struct Text *BKE_text_load_ex(struct Main *bmain,
40 const char *filepath,
41 const char *relbase,
42 bool is_internal) ATTR_NONNULL(1, 2, 3);
48struct Text *BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase)
49 ATTR_NONNULL(1, 2, 3);
50void BKE_text_clear(struct Text *text) ATTR_NONNULL(1);
51void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1, 2);
59int BKE_text_file_modified_check(const struct Text *text);
60void BKE_text_file_modified_ignore(struct Text *text);
61
62char *txt_to_buf(struct Text *text, size_t *r_buf_strlen)
64void txt_clean_text(struct Text *text);
65void txt_order_cursors(struct Text *text, bool reverse);
66int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
67bool txt_has_sel(const struct Text *text);
68int txt_get_span(const struct TextLine *from, const struct TextLine *to);
69void txt_move_up(struct Text *text, bool sel);
70void txt_move_down(struct Text *text, bool sel);
71void txt_move_left(struct Text *text, bool sel);
72void txt_move_right(struct Text *text, bool sel);
73void txt_jump_left(struct Text *text, bool sel, bool use_init_step);
74void txt_jump_right(struct Text *text, bool sel, bool use_init_step);
75void txt_move_bof(struct Text *text, bool sel);
76void txt_move_eof(struct Text *text, bool sel);
77void txt_move_bol(struct Text *text, bool sel);
78void txt_move_eol(struct Text *text, bool sel);
79void txt_move_toline(struct Text *text, unsigned int line, bool sel);
83void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel);
84void txt_pop_sel(struct Text *text);
85void txt_delete_char(struct Text *text);
86void txt_delete_word(struct Text *text);
87void txt_delete_selected(struct Text *text);
88void txt_sel_all(struct Text *text);
94void txt_sel_clear(struct Text *text);
95void txt_sel_line(struct Text *text);
96void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc);
97char *txt_sel_to_buf(const struct Text *text, size_t *r_buf_strlen);
101void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len)
102 ATTR_NONNULL(1, 2);
103void txt_split_curline(struct Text *text);
104void txt_backspace_char(struct Text *text);
105void txt_backspace_word(struct Text *text);
106bool txt_add_char(struct Text *text, unsigned int add);
107bool txt_add_raw_char(struct Text *text, unsigned int add);
108bool txt_replace_char(struct Text *text, unsigned int add);
109bool txt_unindent(struct Text *text);
110void txt_indent(struct Text *text);
111void txt_comment(struct Text *text, const char *prefix);
112bool txt_uncomment(struct Text *text, const char *prefix);
113void txt_move_lines(struct Text *text, int direction);
114void txt_duplicate_line(struct Text *text);
115int txt_setcurr_tab_spaces(struct Text *text, int space);
116bool txt_cursor_is_line_start(const struct Text *text);
117bool txt_cursor_is_line_end(const struct Text *text);
118
119int txt_calc_tab_left(const struct TextLine *tl, int ch);
120int txt_calc_tab_right(const struct TextLine *tl, int ch);
121
125int text_check_bracket(char ch);
126bool text_check_delim(char ch);
127bool text_check_digit(char ch);
128bool text_check_identifier(char ch);
130bool text_check_whitespace(char ch);
131int text_find_identifier_start(const char *str, int i);
132
133/* -------------------------------------------------------------------- */
139extern int text_check_identifier_unicode(unsigned int ch);
140extern int text_check_identifier_nodigit_unicode(unsigned int ch);
141
144enum {
147};
148
149/* Fast non-validating buffer conversion for undo. */
150
154char *txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len)
159void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1, 2);
160
161#ifdef __cplusplus
162}
163#endif
bool text_check_identifier_nodigit(char ch)
Definition text.cc:2337
int text_check_identifier_unicode(unsigned int ch)
Definition text.cc:2358
void txt_move_down(struct Text *text, bool sel)
Definition text.cc:796
void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1
void void txt_split_curline(struct Text *text)
Definition text.cc:1652
int txt_setcurr_tab_spaces(struct Text *text, int space)
Definition text.cc:2207
bool txt_has_sel(const struct Text *text)
void txt_move_eof(struct Text *text, bool sel)
Definition text.cc:1071
void txt_delete_selected(struct Text *text)
Definition text.cc:1926
void txt_delete_char(struct Text *text)
Definition text.cc:1764
bool txt_cursor_is_line_end(const struct Text *text)
void txt_clean_text(struct Text *text)
Definition text.cc:633
void txt_sel_line(struct Text *text)
Definition text.cc:1271
void txt_move_toline(struct Text *text, unsigned int line, bool sel)
Definition text.cc:1094
bool txt_replace_char(struct Text *text, unsigned int add)
Definition text.cc:1932
int text_check_bracket(char ch)
Definition text.cc:2270
int txt_calc_tab_right(const struct TextLine *tl, int ch)
void txt_backspace_char(struct Text *text)
Definition text.cc:1809
void txt_sel_clear(struct Text *text)
Definition text.cc:1263
void txt_move_left(struct Text *text, bool sel)
Definition text.cc:869
bool txt_add_char(struct Text *text, unsigned int add)
Definition text.cc:1916
void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc)
Definition text.cc:1282
char * txt_to_buf(struct Text *text, size_t *r_buf_strlen) ATTR_NONNULL(1
int txt_calc_tab_left(const struct TextLine *tl, int ch)
void txt_delete_word(struct Text *text)
Definition text.cc:1802
@ TXT_MOVE_LINE_UP
Definition BKE_text.h:145
@ TXT_MOVE_LINE_DOWN
Definition BKE_text.h:146
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition text.cc:1921
bool text_check_digit(char ch)
Definition text.cc:2303
void txt_move_bof(struct Text *text, bool sel)
Definition text.cc:1048
char ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition BKE_text.h:63
char * txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len) ATTR_NONNULL(1
struct Text struct Text void BKE_text_clear(struct Text *text) ATTR_NONNULL(1)
Definition text.cc:510
void txt_move_right(struct Text *text, bool sel)
Definition text.cc:912
int txt_get_span(const struct TextLine *from, const struct TextLine *to)
int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition text.cc:1594
void txt_move_lines(struct Text *text, int direction)
Definition text.cc:2176
void BKE_text_free_lines(struct Text *text)
Definition text.cc:263
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition text.cc:2363
struct Text * BKE_text_add(struct Main *bmain, const char *name)
Definition text.cc:280
void txt_comment(struct Text *text, const char *prefix)
Definition text.cc:2135
struct Text struct Text * BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase) ATTR_NONNULL(1
void txt_jump_left(struct Text *text, bool sel, bool use_init_step)
Definition text.cc:956
bool text_check_identifier(char ch)
Definition text.cc:2314
void int BKE_text_file_modified_check(const struct Text *text)
bool text_check_delim(char ch)
Definition text.cc:2287
void txt_move_eol(struct Text *text, bool sel)
Definition text.cc:1026
bool text_check_whitespace(char ch)
Definition text.cc:2369
void txt_backspace_word(struct Text *text)
Definition text.cc:1851
void txt_jump_right(struct Text *text, bool sel, bool use_init_step)
Definition text.cc:980
void txt_move_up(struct Text *text, bool sel)
Definition text.cc:764
void BKE_text_file_modified_ignore(struct Text *text)
Definition text.cc:558
void txt_move_bol(struct Text *text, bool sel)
Definition text.cc:1004
struct Text * BKE_text_load_ex(struct Main *bmain, const char *filepath, const char *relbase, bool is_internal) ATTR_NONNULL(1
void txt_sel_all(struct Text *text)
Definition text.cc:1254
void txt_order_cursors(struct Text *text, bool reverse)
Definition text.cc:1182
bool txt_unindent(struct Text *text)
Definition text.cc:2165
void txt_indent(struct Text *text)
Definition text.cc:2154
void txt_duplicate_line(struct Text *text)
Definition text.cc:1747
char * txt_sel_to_buf(const struct Text *text, size_t *r_buf_strlen)
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.cc:1099
bool txt_cursor_is_line_start(const struct Text *text)
void txt_pop_sel(struct Text *text)
Definition text.cc:1176
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.cc:2377
bool BKE_text_reload(struct Text *text)
Definition text.cc:414
bool txt_uncomment(struct Text *text, const char *prefix)
Definition text.cc:2145
int txt_extended_ascii_as_utf8(char **str)
Definition text.cc:293
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_NONNULL(...)
#define str(s)
float wrap(float value, float max, float min)
Definition node_math.h:71
char * filepath