Blender V4.5
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
10struct Main;
11struct Text;
12struct TextLine;
13
14#include "BLI_compiler_attrs.h"
15#include "BLI_sys_types.h"
16
20void BKE_text_free_lines(struct Text *text);
21struct Text *BKE_text_add(struct Main *bmain, const char *name);
27bool BKE_text_reload(struct Text *text);
36struct Text *BKE_text_load_ex(struct Main *bmain,
37 const char *filepath,
38 const char *relbase,
39 bool is_internal) ATTR_NONNULL(1, 2, 3);
45struct Text *BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase)
46 ATTR_NONNULL(1, 2, 3);
47void BKE_text_clear(struct Text *text) ATTR_NONNULL(1);
48void BKE_text_write(struct Text *text, const char *str, int str_len) ATTR_NONNULL(1, 2);
56int BKE_text_file_modified_check(const struct Text *text);
57void BKE_text_file_modified_ignore(struct Text *text);
58
59char *txt_to_buf(struct Text *text, size_t *r_buf_strlen)
61void txt_clean_text(struct Text *text);
62void txt_order_cursors(struct Text *text, bool reverse);
63bool txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
64bool txt_has_sel(const struct Text *text);
65int txt_get_span(const struct TextLine *from, const struct TextLine *to);
66void txt_move_up(struct Text *text, bool sel);
67void txt_move_down(struct Text *text, bool sel);
68void txt_move_left(struct Text *text, bool sel);
69void txt_move_right(struct Text *text, bool sel);
70void txt_jump_left(struct Text *text, bool sel, bool use_init_step);
71void txt_jump_right(struct Text *text, bool sel, bool use_init_step);
72void txt_move_bof(struct Text *text, bool sel);
73void txt_move_eof(struct Text *text, bool sel);
74void txt_move_bol(struct Text *text, bool sel);
75void txt_move_eol(struct Text *text, bool sel);
76void txt_move_toline(struct Text *text, unsigned int line, bool sel);
80void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, bool sel);
81void txt_pop_sel(struct Text *text);
82void txt_delete_char(struct Text *text);
83void txt_delete_word(struct Text *text);
84void txt_delete_selected(struct Text *text);
85void txt_sel_all(struct Text *text);
91void txt_sel_clear(struct Text *text);
92void txt_sel_line(struct Text *text);
93void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc);
94char *txt_sel_to_buf(const struct Text *text, size_t *r_buf_strlen);
98void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len)
99 ATTR_NONNULL(1, 2);
100void txt_split_curline(struct Text *text);
101void txt_backspace_char(struct Text *text);
102void txt_backspace_word(struct Text *text);
103bool txt_add_char(struct Text *text, unsigned int add);
104bool txt_add_raw_char(struct Text *text, unsigned int add);
105bool txt_replace_char(struct Text *text, unsigned int add);
106bool txt_unindent(struct Text *text);
107void txt_indent(struct Text *text);
108void txt_comment(struct Text *text, const char *prefix);
109bool txt_uncomment(struct Text *text, const char *prefix);
110void txt_move_lines(struct Text *text, int direction);
111void txt_duplicate_line(struct Text *text);
112int txt_setcurr_tab_spaces(struct Text *text, int space);
113bool txt_cursor_is_line_start(const struct Text *text);
114bool txt_cursor_is_line_end(const struct Text *text);
115
116int txt_calc_tab_left(const struct TextLine *tl, int ch);
117int txt_calc_tab_right(const struct TextLine *tl, int ch);
118
122int text_check_bracket(char ch);
123bool text_check_delim(char ch);
124bool text_check_digit(char ch);
125bool text_check_identifier(char ch);
127bool text_check_whitespace(char ch);
128int text_find_identifier_start(const char *str, int i);
129
130/* -------------------------------------------------------------------- */
135
136extern int text_check_identifier_unicode(unsigned int ch);
137extern int text_check_identifier_nodigit_unicode(unsigned int ch);
138
140
141enum {
144};
145
146/* Fast non-validating buffer conversion for undo. */
147
151char *txt_to_buf_for_undo(struct Text *text, size_t *r_buf_len)
156void txt_from_buf_for_undo(struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1, 2);
bool text_check_identifier_nodigit(char ch)
Definition text.cc:2339
int text_check_identifier_unicode(unsigned int ch)
Definition text.cc:2360
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:2209
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:1927
void txt_delete_char(struct Text *text)
Definition text.cc:1765
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:1933
int text_check_bracket(char ch)
Definition text.cc:2272
int txt_calc_tab_right(const struct TextLine *tl, int ch)
void txt_backspace_char(struct Text *text)
Definition text.cc:1810
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:1917
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
@ TXT_MOVE_LINE_UP
Definition BKE_text.h:142
@ TXT_MOVE_LINE_DOWN
Definition BKE_text.h:143
int txt_calc_tab_left(const struct TextLine *tl, int ch)
void txt_delete_word(struct Text *text)
Definition text.cc:1803
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition text.cc:1922
bool text_check_digit(char ch)
Definition text.cc:2305
void txt_move_bof(struct Text *text, bool sel)
Definition text.cc:1048
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)
void txt_move_lines(struct Text *text, int direction)
Definition text.cc:2178
void BKE_text_free_lines(struct Text *text)
Definition text.cc:263
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition text.cc:2365
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:2137
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:2316
void int BKE_text_file_modified_check(const struct Text *text)
bool text_check_delim(char ch)
Definition text.cc:2289
void txt_move_eol(struct Text *text, bool sel)
Definition text.cc:1026
bool text_check_whitespace(char ch)
Definition text.cc:2371
void txt_backspace_word(struct Text *text)
Definition text.cc:1852
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
bool txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition text.cc:1594
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:2167
void txt_indent(struct Text *text)
Definition text.cc:2156
void txt_duplicate_line(struct Text *text)
Definition text.cc:1748
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:2379
bool BKE_text_reload(struct Text *text)
Definition text.cc:414
bool txt_uncomment(struct Text *text, const char *prefix)
Definition text.cc:2147
int txt_extended_ascii_as_utf8(char **str)
Definition text.cc:293
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_RETURNS_NONNULL
#define ATTR_NONNULL(...)
#define str(s)
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
Definition msgfmt.cc:222
float wrap(float value, float max, float min)
Definition node_math.h:71
char * filepath
i
Definition text_draw.cc:230