Blender V5.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
9
10namespace blender {
11
12struct Main;
13struct Text;
14struct TextLine;
15
17#include "BLI_sys_types.hh"
18
22void BKE_text_free_lines(struct Text *text);
23struct Text *BKE_text_add(struct Main *bmain, const char *name);
29bool BKE_text_reload(struct Text *text);
38struct 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);
47struct Text *BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase)
48 ATTR_NONNULL(1, 2, 3);
49void BKE_text_clear(struct Text *text) ATTR_NONNULL(1);
50void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1, 2);
58int BKE_text_file_modified_check(const struct Text *text);
59void BKE_text_file_modified_ignore(struct Text *text);
60
61char *txt_to_buf(struct Text *text, size_t *r_buf_strlen)
63void txt_clean_text(struct Text *text);
64void txt_order_cursors(struct Text *text, bool reverse);
65bool txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
66bool txt_has_sel(const struct Text *text);
67int txt_get_span(const struct TextLine *from, const struct TextLine *to);
68void txt_move_up(struct Text *text, bool sel);
69void txt_move_down(struct Text *text, bool sel);
70void txt_move_left(struct Text *text, bool sel);
71void txt_move_right(struct Text *text, bool sel);
72void txt_jump_left(struct Text *text, bool sel, bool use_init_step);
73void txt_jump_right(struct Text *text, bool sel, bool use_init_step);
74void txt_move_bof(struct Text *text, bool sel);
75void txt_move_eof(struct Text *text, bool sel);
76void txt_move_bol(struct Text *text, bool sel);
77void txt_move_eol(struct Text *text, bool sel);
78void txt_move_toline(struct Text *text, unsigned int line, bool sel);
82void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel);
83void txt_pop_sel(struct Text *text);
84void txt_delete_char(struct Text *text);
85void txt_delete_word(struct Text *text);
86void txt_delete_selected(struct Text *text);
87void txt_sel_all(struct Text *text);
93void txt_sel_clear(struct Text *text);
94void txt_sel_line(struct Text *text);
95void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc);
96char *txt_sel_to_buf(const struct Text *text, size_t *r_buf_strlen);
100void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len)
102void txt_split_curline(struct Text *text);
103void txt_backspace_char(struct Text *text);
104void txt_backspace_word(struct Text *text);
105bool txt_add_char(struct Text *text, unsigned int add);
106bool txt_add_raw_char(struct Text *text, unsigned int add);
107bool txt_replace_char(struct Text *text, unsigned int add);
108bool txt_unindent(struct Text *text);
109void txt_indent(struct Text *text);
110void txt_comment(struct Text *text, const char *prefix);
111bool txt_uncomment(struct Text *text, const char *prefix);
112void txt_move_lines(struct Text *text, int direction);
113void txt_duplicate_line(struct Text *text);
114int txt_setcurr_tab_spaces(struct Text *text, int space);
115bool txt_cursor_is_line_start(const struct Text *text);
116bool txt_cursor_is_line_end(const struct Text *text);
117
118int txt_calc_tab_left(const struct TextLine *tl, int ch);
119int txt_calc_tab_right(const struct TextLine *tl, int ch);
125bool text_check_delim(char ch);
126bool text_check_digit(char ch);
127bool text_check_identifier(char ch);
129bool text_check_whitespace(char ch);
130int text_find_identifier_start(const char *str, int i);
131
132/* -------------------------------------------------------------------- */
138extern int text_check_identifier_unicode(unsigned int ch);
139extern int text_check_identifier_nodigit_unicode(unsigned int ch);
143enum {
146};
148/* Fast non-validating buffer conversion for undo. */
153char *txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len)
158void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1, 2);
159
160} // namespace blender
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_RETURNS_NONNULL
#define ATTR_NONNULL(...)
#define str(s)
float wrap(float a, float b, float c)
BMesh Iterators.
struct Text * BKE_text_add(struct Main *bmain, const char *name)
Definition text.cc:284
bool text_check_identifier(char ch)
Definition text.cc:2323
bool text_check_digit(char ch)
Definition text.cc:2312
int txt_get_span(const struct TextLine *from, const struct TextLine *to)
int txt_calc_tab_left(const struct TextLine *tl, int ch)
void txt_jump_left(struct Text *text, bool sel, bool use_init_step)
Definition text.cc:961
void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len) ATTR_NONNULL(1
Definition text.cc:1545
void txt_indent(struct Text *text)
Definition text.cc:2163
int txt_extended_ascii_as_utf8(char **str)
Definition text.cc:297
void txt_move_eof(struct Text *text, bool sel)
Definition text.cc:1076
bool BKE_text_reload(struct Text *text)
Definition text.cc:419
void txt_backspace_char(struct Text *text)
Definition text.cc:1816
bool text_check_identifier_nodigit(char ch)
Definition text.cc:2346
void txt_move_bof(struct Text *text, bool sel)
Definition text.cc:1053
bool txt_has_sel(const struct Text *text)
char * txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len) ATTR_NONNULL(1
Definition text.cc:1349
int text_find_identifier_start(const char *str, int i)
Definition text.cc:2386
void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc)
Definition text.cc:1287
void txt_sel_clear(struct Text *text)
Definition text.cc:1268
void txt_duplicate_line(struct Text *text)
Definition text.cc:1754
bool txt_add_char(struct Text *text, unsigned int add)
Definition text.cc:1924
void txt_comment(struct Text *text, const char *prefix)
Definition text.cc:2144
void txt_move_toline(struct Text *text, unsigned int line, bool sel)
Definition text.cc:1099
bool text_check_delim(char ch)
Definition text.cc:2296
bool txt_cursor_is_line_start(const struct Text *text)
bool txt_unindent(struct Text *text)
Definition text.cc:2174
bool txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition text.cc:1599
@ TXT_MOVE_LINE_UP
Definition BKE_text.h:144
@ TXT_MOVE_LINE_DOWN
Definition BKE_text.h:145
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition text.cc:2372
struct Text * BKE_text_load_ex(struct Main *bmain, const char *filepath, const char *relbase, bool is_internal) ATTR_NONNULL(1
Definition text.cc:456
void txt_delete_word(struct Text *text)
Definition text.cc:1809
int txt_calc_tab_right(const struct TextLine *tl, int ch)
int txt_setcurr_tab_spaces(struct Text *text, int space)
Definition text.cc:2216
bool txt_cursor_is_line_end(const struct Text *text)
void txt_pop_sel(struct Text *text)
Definition text.cc:1181
void txt_sel_all(struct Text *text)
Definition text.cc:1259
void txt_move_lines(struct Text *text, int direction)
Definition text.cc:2185
void txt_clean_text(struct Text *text)
Definition text.cc:638
void void txt_split_curline(struct Text *text)
Definition text.cc:1657
void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1
Definition text.cc:1366
void txt_delete_selected(struct Text *text)
Definition text.cc:1934
bool text_check_whitespace(char ch)
Definition text.cc:2378
int text_check_identifier_unicode(unsigned int ch)
Definition text.cc:2367
void txt_move_left(struct Text *text, bool sel)
Definition text.cc:874
void txt_move_down(struct Text *text, bool sel)
Definition text.cc:801
char * txt_sel_to_buf(const struct Text *text, size_t *r_buf_strlen)
bool txt_uncomment(struct Text *text, const char *prefix)
Definition text.cc:2154
void int BKE_text_file_modified_check(const struct Text *text)
void txt_move_right(struct Text *text, bool sel)
Definition text.cc:917
int text_check_bracket(char ch)
Definition text.cc:2279
void txt_sel_line(struct Text *text)
Definition text.cc:1276
void txt_move_bol(struct Text *text, bool sel)
Definition text.cc:1009
void txt_move_up(struct Text *text, bool sel)
Definition text.cc:769
char * txt_to_buf(struct Text *text, size_t *r_buf_strlen) ATTR_NONNULL(1
Definition text.cc:1434
struct Text struct Text * BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase) ATTR_NONNULL(1
Definition text.cc:510
void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1
Definition text.cc:522
void txt_jump_right(struct Text *text, bool sel, bool use_init_step)
Definition text.cc:985
void txt_delete_char(struct Text *text)
Definition text.cc:1771
void BKE_text_free_lines(struct Text *text)
Definition text.cc:268
void ATTR_NONNULL(1, 2)
void txt_move_eol(struct Text *text, bool sel)
Definition text.cc:1031
void BKE_text_file_modified_ignore(struct Text *text)
Definition text.cc:563
void txt_order_cursors(struct Text *text, bool reverse)
Definition text.cc:1187
void txt_backspace_word(struct Text *text)
Definition text.cc:1858
void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel)
Definition text.cc:1104
bool txt_replace_char(struct Text *text, unsigned int add)
Definition text.cc:1940
struct Text struct Text void BKE_text_clear(struct Text *text) ATTR_NONNULL(1)
Definition text.cc:515
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition text.cc:1929