Blender V5.0
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:2340
int text_check_identifier_unicode(unsigned int ch)
Definition text.cc:2361
void txt_move_down(struct Text *text, bool sel)
Definition text.cc:797
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:1653
int txt_setcurr_tab_spaces(struct Text *text, int space)
Definition text.cc:2210
bool txt_has_sel(const struct Text *text)
void txt_move_eof(struct Text *text, bool sel)
Definition text.cc:1072
void txt_delete_selected(struct Text *text)
Definition text.cc:1928
void txt_delete_char(struct Text *text)
Definition text.cc:1766
bool txt_cursor_is_line_end(const struct Text *text)
void txt_clean_text(struct Text *text)
Definition text.cc:634
void txt_sel_line(struct Text *text)
Definition text.cc:1272
void txt_move_toline(struct Text *text, unsigned int line, bool sel)
Definition text.cc:1095
bool txt_replace_char(struct Text *text, unsigned int add)
Definition text.cc:1934
int text_check_bracket(char ch)
Definition text.cc:2273
int txt_calc_tab_right(const struct TextLine *tl, int ch)
void txt_backspace_char(struct Text *text)
Definition text.cc:1811
void txt_sel_clear(struct Text *text)
Definition text.cc:1264
void txt_move_left(struct Text *text, bool sel)
Definition text.cc:870
bool txt_add_char(struct Text *text, unsigned int add)
Definition text.cc:1918
void txt_sel_set(struct Text *text, int startl, int startc, int endl, int endc)
Definition text.cc:1283
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:1804
bool txt_add_raw_char(struct Text *text, unsigned int add)
Definition text.cc:1923
bool text_check_digit(char ch)
Definition text.cc:2306
void txt_move_bof(struct Text *text, bool sel)
Definition text.cc:1049
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:511
void txt_move_right(struct Text *text, bool sel)
Definition text.cc:913
@ TXT_MOVE_LINE_UP
Definition BKE_text.h:142
@ TXT_MOVE_LINE_DOWN
Definition BKE_text.h:143
int txt_get_span(const struct TextLine *from, const struct TextLine *to)
void txt_move_lines(struct Text *text, int direction)
Definition text.cc:2179
void BKE_text_free_lines(struct Text *text)
Definition text.cc:264
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition text.cc:2366
struct Text * BKE_text_add(struct Main *bmain, const char *name)
Definition text.cc:281
void txt_comment(struct Text *text, const char *prefix)
Definition text.cc:2138
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:957
bool text_check_identifier(char ch)
Definition text.cc:2317
void int BKE_text_file_modified_check(const struct Text *text)
bool text_check_delim(char ch)
Definition text.cc:2290
void txt_move_eol(struct Text *text, bool sel)
Definition text.cc:1027
bool text_check_whitespace(char ch)
Definition text.cc:2372
void txt_backspace_word(struct Text *text)
Definition text.cc:1853
void txt_jump_right(struct Text *text, bool sel, bool use_init_step)
Definition text.cc:981
void txt_move_up(struct Text *text, bool sel)
Definition text.cc:765
bool txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case)
Definition text.cc:1595
void BKE_text_file_modified_ignore(struct Text *text)
Definition text.cc:559
void txt_move_bol(struct Text *text, bool sel)
Definition text.cc:1005
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:1255
void txt_order_cursors(struct Text *text, bool reverse)
Definition text.cc:1183
bool txt_unindent(struct Text *text)
Definition text.cc:2168
void txt_indent(struct Text *text)
Definition text.cc:2157
void txt_duplicate_line(struct Text *text)
Definition text.cc:1749
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:1100
bool txt_cursor_is_line_start(const struct Text *text)
void txt_pop_sel(struct Text *text)
Definition text.cc:1177
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:2380
bool BKE_text_reload(struct Text *text)
Definition text.cc:415
bool txt_uncomment(struct Text *text, const char *prefix)
Definition text.cc:2148
int txt_extended_ascii_as_utf8(char **str)
Definition text.cc:294
#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:103
const char * name
char * filepath
i
Definition text_draw.cc:230