Blender V5.3
text.cc File Reference
#include <cstdlib>
#include <cstring>
#include <cwctype>
#include <optional>
#include <sys/stat.h>
#include <sys/types.h>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.hh"
#include "BLI_listbase.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.hh"
#include "BLI_string_cursor_utf8.hh"
#include "BLI_string_utf8.hh"
#include "BLI_utildefines.hh"
#include "BLT_translation.hh"
#include "DNA_text_types.h"
#include "DNA_userdef_types.h"
#include "BKE_bpath.hh"
#include "BKE_idtype.hh"
#include "BKE_lib_id.hh"
#include "BKE_library.hh"
#include "BKE_main.hh"
#include "BKE_text.h"
#include "BLO_read_write.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Functions

Prototypes
static void blender::txt_pop_first (Text *text)
static void blender::txt_pop_last (Text *text)
static void blender::txt_delete_line (Text *text, TextLine *line)
static void blender::txt_delete_sel (Text *text)
static void blender::txt_make_dirty (Text *text)
static TextLine * blender::txt_line_malloc () ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Text Data-Block
static void blender::text_init_data (ID *id)
static void blender::text_copy_data (Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
static void blender::text_free_data (ID *id)
static void blender::text_foreach_path (ID *id, BPathForeachPathData *bpath_data)
static void blender::text_blend_write (BlendWriter *writer, ID *id, const void *id_address)
static void blender::text_blend_read_data (BlendDataReader *reader, ID *id)
Text Add, Free, Validation
void blender::BKE_text_free_lines (struct Text *text)
struct Text * blender::BKE_text_add (struct Main *bmain, const char *name)
int blender::txt_extended_ascii_as_utf8 (char **str)
static void blender::cleanup_textline (TextLine *tl)
static void blender::text_from_buf (Text *text, const uchar *buffer, const int len)
bool blender::BKE_text_reload (struct Text *text)
struct Text * blender::BKE_text_load_ex (struct Main *bmain, const char *filepath, const char *relbase, bool is_internal) ATTR_NONNULL(1
struct Text struct Text * blender::BKE_text_load (struct Main *bmain, const char *filepath, const char *relbase) ATTR_NONNULL(1
struct Text struct Text void blender::BKE_text_clear (struct Text *text) ATTR_NONNULL(1)
void blender::BKE_text_write (struct Text *text, const char *str, int str_len) ATTR_NONNULL(1
int blender::BKE_text_file_modified_check (const Text *text)
void blender::BKE_text_file_modified_ignore (struct Text *text)
Editing Utility Functions
static void blender::make_new_line (TextLine *line, char *newline)
static TextLine * blender::txt_new_linen (const char *str, int str_len)
static TextLine * blender::txt_new_line (const char *str)
void blender::txt_clean_text (struct Text *text)
int blender::txt_get_span (const TextLine *from, const TextLine *to)
Cursor Utility Functions
static void blender::txt_curs_cur (Text *text, TextLine ***linep, int **charp)
static void blender::txt_curs_sel (Text *text, TextLine ***linep, int **charp)
bool blender::txt_cursor_is_line_start (const Text *text)
bool blender::txt_cursor_is_line_end (const Text *text)
Cursor Movement Functions
Note
If the user moves the cursor the space containing that cursor should be popped See txt_pop_first, txt_pop_last Other space-types retain their own top location.
void blender::txt_move_up (struct Text *text, bool sel)
void blender::txt_move_down (struct Text *text, bool sel)
int blender::txt_calc_tab_left (const TextLine *tl, int ch)
int blender::txt_calc_tab_right (const TextLine *tl, int ch)
void blender::txt_move_left (struct Text *text, bool sel)
void blender::txt_move_right (struct Text *text, bool sel)
void blender::txt_jump_left (struct Text *text, bool sel, bool use_init_step)
void blender::txt_jump_right (struct Text *text, bool sel, bool use_init_step)
void blender::txt_move_bol (struct Text *text, bool sel)
void blender::txt_move_eol (struct Text *text, bool sel)
void blender::txt_move_bof (struct Text *text, bool sel)
void blender::txt_move_eof (struct Text *text, bool sel)
void blender::txt_move_toline (struct Text *text, unsigned int line, bool sel)
void blender::txt_move_to (struct Text *text, unsigned int line, unsigned int ch, bool sel)
Text Selection Functions
static void blender::txt_curs_swap (Text *text)
void blender::txt_pop_sel (struct Text *text)
void blender::txt_order_cursors (struct Text *text, bool reverse)
bool blender::txt_has_sel (const Text *text)
void blender::txt_sel_all (struct Text *text)
void blender::txt_sel_clear (struct Text *text)
void blender::txt_sel_line (struct Text *text)
void blender::txt_sel_set (struct Text *text, int startl, int startc, int endl, int endc)
Buffer Conversion for Undo/Redo

Buffer conversion functions that rely on the buffer already being validated.

The only requirement for these functions is that they're reverse-able, the undo logic doesn't inspect their content.

Currently buffers:

  • Always ends with a new-line.
  • Are not null terminated.
char * blender::txt_to_buf_for_undo (struct Text *text, size_t *r_buf_len) ATTR_NONNULL(1
void blender::txt_from_buf_for_undo (struct Text *text, const char *buf, size_t buf_len) ATTR_NONNULL(1
Cut and Paste Functions
char * blender::txt_to_buf (struct Text *text, size_t *r_buf_strlen) ATTR_NONNULL(1
char * blender::txt_sel_to_buf (const Text *text, size_t *r_buf_strlen)
void blender::txt_insert_buf (struct Text *text, const char *in_buffer, int in_buffer_len) ATTR_NONNULL(1
Find String in Text
bool blender::txt_find_string (struct Text *text, const char *findstr, int wrap, int match_case)
Character Queries
int blender::text_check_bracket (char ch)
bool blender::text_check_delim (char ch)
bool blender::text_check_digit (char ch)
bool blender::text_check_identifier (char ch)
bool blender::text_check_identifier_nodigit (char ch)
bool blender::text_check_whitespace (char ch)
int blender::text_find_identifier_start (const char *str, int i)
Character Classification

Define text.cc functions here (declared in BKE_text.h), This could be removed if Blender gets its own unicode library.

int blender::text_check_identifier_unicode (unsigned int ch)
int blender::text_check_identifier_nodigit_unicode (unsigned int ch)

Line Editing Functions

static char blender::tab_to_spaces [] = " "
void void blender::txt_split_curline (struct Text *text)
static void blender::txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb)
void blender::txt_duplicate_line (struct Text *text)
void blender::txt_delete_char (struct Text *text)
void blender::txt_delete_word (struct Text *text)
void blender::txt_backspace_char (struct Text *text)
void blender::txt_backspace_word (struct Text *text)
static void blender::txt_convert_tab_to_spaces (Text *text)
static bool blender::txt_add_char_intern (Text *text, uint add, bool replace_tabs)
bool blender::txt_add_char (struct Text *text, unsigned int add)
bool blender::txt_add_raw_char (struct Text *text, unsigned int add)
void blender::txt_delete_selected (struct Text *text)
bool blender::txt_replace_char (struct Text *text, unsigned int add)
static void blender::txt_select_prefix (Text *text, const char *add, bool skip_blank_lines)
static bool blender::txt_select_unprefix (Text *text, const char *remove, const bool require_all)
void blender::txt_comment (struct Text *text, const char *prefix)
bool blender::txt_uncomment (struct Text *text, const char *prefix)
void blender::txt_indent (struct Text *text)
bool blender::txt_unindent (struct Text *text)
void blender::txt_move_lines (struct Text *text, int direction)
int blender::txt_setcurr_tab_spaces (struct Text *text, int space)