Blender V2.61 - r43446
Functions | Variables

text.c File Reference

#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <wchar.h>
#include <wctype.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_constraint_types.h"
#include "DNA_controller_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "DNA_userdef_types.h"
#include "DNA_object_types.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_text.h"

Go to the source code of this file.

Functions

static void txt_pop_first (Text *text)
static void txt_pop_last (Text *text)
static void txt_undo_add_op (Text *text, int op)
static void txt_undo_add_block (Text *text, int op, const char *buf)
static void txt_delete_line (Text *text, TextLine *line)
static void txt_delete_sel (Text *text)
static void txt_make_dirty (Text *text)
void txt_set_undostate (int u)
int txt_get_undostate (void)
static void init_undo_text (Text *text)
void free_text (Text *text)
Textadd_empty_text (const char *name)
int txt_extended_ascii_as_utf8 (char **str)
static void cleanup_textline (TextLine *tl)
int reopen_text (Text *text)
Textadd_text (const char *file, const char *relpath)
Textcopy_text (Text *ta)
void unlink_text (Main *bmain, Text *text)
void clear_text (Text *text)
void write_text (Text *text, const char *str)
static void make_new_line (TextLine *line, char *newline)
static TextLinetxt_new_line (const char *str)
static TextLinetxt_new_linen (const char *str, int n)
void txt_clean_text (Text *text)
int txt_get_span (TextLine *from, TextLine *to)
static short txt_char_type (unsigned int ch)
static void txt_curs_cur (Text *text, TextLine ***linep, int **charp)
static void txt_curs_sel (Text *text, TextLine ***linep, int **charp)
static void txt_curs_first (Text *text, TextLine **linep, int *charp)
int txt_utf8_offset_to_index (char *str, int offset)
int txt_utf8_index_to_offset (char *str, int index)
static int txt_utf8_len (const char *src)
void txt_move_up (Text *text, short sel)
void txt_move_down (Text *text, short sel)
void txt_move_left (Text *text, short sel)
void txt_move_right (Text *text, short sel)
void txt_jump_left (Text *text, short sel)
void txt_jump_right (Text *text, short sel)
void txt_move_bol (Text *text, short sel)
void txt_move_eol (Text *text, short sel)
void txt_move_bof (Text *text, short sel)
void txt_move_eof (Text *text, short sel)
void txt_move_toline (Text *text, unsigned int line, short sel)
void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel)
static void txt_curs_swap (Text *text)
void txt_pop_sel (Text *text)
void txt_order_cursors (Text *text)
int txt_has_sel (Text *text)
void txt_sel_all (Text *text)
void txt_sel_line (Text *text)
char * txt_to_buf (Text *text)
int txt_find_string (Text *text, const char *findstr, int wrap, int match_case)
char * txt_sel_to_buf (Text *text)
static void txt_shift_markers (Text *text, int lineno, int count)
void txt_insert_buf (Text *text, const char *in_buffer)
static int max_undo_test (Text *text, int x)
static void dump_buffer (Text *text)
void txt_print_undo (Text *text)
static void txt_undo_store_uint16 (char *undo_buf, int *undo_pos, unsigned short value)
static void txt_undo_store_uint32 (char *undo_buf, int *undo_pos, unsigned int value)
void txt_undo_add_toop (Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc)
static void txt_undo_add_charop (Text *text, int op_start, unsigned int c)
static unsigned short txt_undo_read_uint16 (const char *undo_buf, int *undo_pos)
static unsigned int txt_undo_read_uint32 (const char *undo_buf, int *undo_pos)
static unsigned int txt_undo_read_unicode (const char *undo_buf, int *undo_pos, short bytes)
static unsigned short txt_redo_read_uint16 (const char *undo_buf, int *undo_pos)
static unsigned int txt_redo_read_uint32 (const char *undo_buf, int *undo_pos)
static unsigned int txt_redo_read_unicode (const char *undo_buf, int *undo_pos, short bytes)
void txt_do_undo (Text *text)
void txt_do_redo (Text *text)
void txt_split_curline (Text *text)
static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb)
void txt_delete_char (Text *text)
void txt_delete_word (Text *text)
void txt_backspace_char (Text *text)
void txt_backspace_word (Text *text)
static void txt_convert_tab_to_spaces (Text *text)
static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs)
int txt_add_char (Text *text, unsigned int add)
int txt_add_raw_char (Text *text, unsigned int add)
void txt_delete_selected (Text *text)
int txt_replace_char (Text *text, unsigned int add)
void txt_indent (Text *text)
void txt_unindent (Text *text)
void txt_comment (Text *text)
void txt_uncomment (Text *text)
int setcurr_tab_spaces (Text *text, int space)
void txt_add_marker (Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags)
TextMarkertxt_find_marker_region (Text *text, TextLine *line, int start, int end, int group, int flags)
short txt_clear_marker_region (Text *text, TextLine *line, int start, int end, int group, int flags)
short txt_clear_markers (Text *text, int group, int flags)
TextMarkertxt_find_marker (Text *text, TextLine *line, int curs, int group, int flags)
TextMarkertxt_prev_marker (Text *text, TextMarker *marker)
TextMarkertxt_next_marker (Text *text, TextMarker *marker)
int text_check_bracket (char ch)
int text_check_delim (char ch)
int text_check_digit (char ch)
int text_check_identifier (char ch)
int text_check_whitespace (char ch)

Variables

static unsigned char undoing
static char tab_to_spaces [] = " "

Detailed Description

Definition in file text.c.


Function Documentation

Text* add_empty_text ( const char *  name) [read]
Text* add_text ( const char *  file,
const char *  relpath 
) [read]
static void cleanup_textline ( TextLine tl) [static]

Definition at line 263 of file text.c.

References i, TextLine::len, TextLine::line, and txt_extended_ascii_as_utf8().

Referenced by add_text(), and reopen_text().

void clear_text ( Text text)
Text* copy_text ( Text ta) [read]
static void dump_buffer ( Text text) [static]

Definition at line 1568 of file text.c.

References i, Text::undo_buf, and Text::undo_pos.

Referenced by txt_print_undo().

void free_text ( Text text)
static void init_undo_text ( Text text) [static]
static void make_new_line ( TextLine line,
char *  newline 
) [static]
static int max_undo_test ( Text text,
int  x 
) [static]
int reopen_text ( Text text)
int setcurr_tab_spaces ( Text text,
int  space 
)

Definition at line 2961 of file text.c.

References Text::curc, Text::curl, Text::flags, i, TextLine::line, NULL, rna_array::test, and TXT_TABSTOSPACES.

Referenced by text_line_break_exec().

int text_check_bracket ( char  ch)

Definition at line 3171 of file text.c.

Referenced by draw_brackets().

int text_check_delim ( char  ch)

Definition at line 3186 of file text.c.

Referenced by console_move_exec(), and txt_format_line().

int text_check_digit ( char  ch)

Definition at line 3198 of file text.c.

Referenced by txt_format_line().

int text_check_identifier ( char  ch)
int text_check_whitespace ( char  ch)

Definition at line 3216 of file text.c.

Referenced by console_move_exec(), and do_texttools().

int txt_add_char ( Text text,
unsigned int  add 
)
static int txt_add_char_intern ( Text text,
unsigned int  add,
int  replace_tabs 
) [static]
void txt_add_marker ( Text text,
TextLine line,
int  start,
int  end,
const unsigned char  color[4],
int  group,
int  flags 
)
int txt_add_raw_char ( Text text,
unsigned int  add 
)

Definition at line 2682 of file text.c.

References txt_add_char_intern().

Referenced by txt_insert_buf().

void txt_backspace_char ( Text text)
void txt_backspace_word ( Text text)

Definition at line 2603 of file text.c.

References txt_delete_sel(), and txt_jump_left().

Referenced by text_delete_exec().

static short txt_char_type ( unsigned int  ch) [static]

Definition at line 735 of file text.c.

Referenced by txt_jump_left(), and txt_jump_right().

void txt_clean_text ( Text text)
short txt_clear_marker_region ( Text text,
TextLine line,
int  start,
int  end,
int  group,
int  flags 
)
short txt_clear_markers ( Text text,
int  group,
int  flags 
)
static void txt_combine_lines ( Text text,
TextLine linea,
TextLine lineb 
) [static]
void txt_comment ( Text text)
static void txt_convert_tab_to_spaces ( Text text) [static]

Definition at line 2614 of file text.c.

References Text::curc, tab_to_spaces, txt_insert_buf(), and TXT_TABSIZE.

Referenced by txt_add_char_intern().

static void txt_curs_cur ( Text text,
TextLine ***  linep,
int **  charp 
) [static]
static void txt_curs_first ( Text text,
TextLine **  linep,
int *  charp 
) [static]

Definition at line 756 of file text.c.

References Text::curc, Text::curl, ListBase::first, Text::lines, Text::selc, Text::sell, and txt_get_span().

Referenced by txt_do_undo().

static void txt_curs_sel ( Text text,
TextLine ***  linep,
int **  charp 
) [static]
static void txt_curs_swap ( Text text) [static]
void txt_delete_char ( Text text)
static void txt_delete_line ( Text text,
TextLine line 
) [static]
static void txt_delete_sel ( Text text) [static]
void txt_delete_selected ( Text text)

Definition at line 2687 of file text.c.

References txt_delete_sel(), and txt_make_dirty().

Referenced by text_cut_exec().

void txt_delete_word ( Text text)

Definition at line 2538 of file text.c.

References txt_delete_sel(), and txt_jump_right().

Referenced by text_delete_exec().

void txt_do_redo ( Text text)
void txt_do_undo ( Text text)
int txt_extended_ascii_as_utf8 ( char **  str)
TextMarker* txt_find_marker ( Text text,
TextLine line,
int  curs,
int  group,
int  flags 
) [read]
TextMarker* txt_find_marker_region ( Text text,
TextLine line,
int  start,
int  end,
int  group,
int  flags 
) [read]
int txt_find_string ( Text text,
const char *  findstr,
int  wrap,
int  match_case 
)
int txt_get_span ( TextLine from,
TextLine to 
)
int txt_get_undostate ( void  )

Definition at line 147 of file text.c.

References undoing.

Referenced by clear_text(), and write_text().

int txt_has_sel ( Text text)
void txt_indent ( Text text)
void txt_insert_buf ( Text text,
const char *  in_buffer 
)
void txt_jump_left ( Text text,
short  sel 
)
void txt_jump_right ( Text text,
short  sel 
)
static void txt_make_dirty ( Text text) [static]
void txt_move_bof ( Text text,
short  sel 
)
void txt_move_bol ( Text text,
short  sel 
)
void txt_move_down ( Text text,
short  sel 
)
void txt_move_eof ( Text text,
short  sel 
)
void txt_move_eol ( Text text,
short  sel 
)
void txt_move_left ( Text text,
short  sel 
)
void txt_move_right ( Text text,
short  sel 
)
void txt_move_to ( Text text,
unsigned int  line,
unsigned int  ch,
short  sel 
)
void txt_move_toline ( Text text,
unsigned int  line,
short  sel 
)
void txt_move_up ( Text text,
short  sel 
)
static TextLine* txt_new_line ( const char *  str) [static]
static TextLine* txt_new_linen ( const char *  str,
int  n 
) [static]
TextMarker* txt_next_marker ( Text text,
TextMarker marker 
) [read]

Definition at line 3154 of file text.c.

References ListBase::first, TextMarker::group, Text::markers, TextMarker::next, and NULL.

Referenced by do_textmarkers().

void txt_order_cursors ( Text text)
static void txt_pop_first ( Text text) [static]
static void txt_pop_last ( Text text) [static]
void txt_pop_sel ( Text text)
TextMarker* txt_prev_marker ( Text text,
TextMarker marker 
) [read]

Definition at line 3140 of file text.c.

References TextMarker::group, ListBase::last, Text::markers, NULL, and TextMarker::prev.

void txt_print_undo ( Text text)
static unsigned short txt_redo_read_uint16 ( const char *  undo_buf,
int *  undo_pos 
) [static]

Definition at line 1905 of file text.c.

References simple_enum_gen::val.

Referenced by txt_do_redo().

static unsigned int txt_redo_read_uint32 ( const char *  undo_buf,
int *  undo_pos 
) [static]

Definition at line 1913 of file text.c.

References simple_enum_gen::val.

Referenced by txt_do_redo().

static unsigned int txt_redo_read_unicode ( const char *  undo_buf,
int *  undo_pos,
short  bytes 
) [static]

Definition at line 1923 of file text.c.

References BLI_str_utf8_as_unicode(), BLI_UTF8_MAX, and txt_undo_read_uint32().

Referenced by txt_do_redo().

int txt_replace_char ( Text text,
unsigned int  add 
)
void txt_sel_all ( Text text)
void txt_sel_line ( Text text)

Definition at line 1277 of file text.c.

References Text::curc, Text::curl, TextLine::len, Text::selc, and Text::sell.

Referenced by text_select_line_exec().

char* txt_sel_to_buf ( Text text)
void txt_set_undostate ( int  u)

Definition at line 142 of file text.c.

References undoing.

Referenced by clear_text(), and write_text().

static void txt_shift_markers ( Text text,
int  lineno,
int  count 
) [static]

Definition at line 1469 of file text.c.

References ListBase::first, TextMarker::lineno, Text::markers, and TextMarker::next.

Referenced by txt_insert_buf().

void txt_split_curline ( Text text)
char* txt_to_buf ( Text text)
void txt_uncomment ( Text text)
static void txt_undo_add_block ( Text text,
int  op,
const char *  buf 
) [static]
static void txt_undo_add_charop ( Text text,
int  op_start,
unsigned int  c 
) [static]
static void txt_undo_add_op ( Text text,
int  op 
) [static]
void txt_undo_add_toop ( Text text,
int  op,
unsigned int  froml,
unsigned short  fromc,
unsigned int  tol,
unsigned short  toc 
)
static unsigned short txt_undo_read_uint16 ( const char *  undo_buf,
int *  undo_pos 
) [static]

Definition at line 1858 of file text.c.

References simple_enum_gen::val.

Referenced by txt_do_undo().

static unsigned int txt_undo_read_uint32 ( const char *  undo_buf,
int *  undo_pos 
) [static]

Definition at line 1866 of file text.c.

References simple_enum_gen::val.

Referenced by txt_do_undo(), txt_redo_read_unicode(), and txt_undo_read_unicode().

static unsigned int txt_undo_read_unicode ( const char *  undo_buf,
int *  undo_pos,
short  bytes 
) [static]

Definition at line 1876 of file text.c.

References BLI_str_utf8_as_unicode(), BLI_UTF8_MAX, and txt_undo_read_uint32().

Referenced by txt_do_undo().

static void txt_undo_store_uint16 ( char *  undo_buf,
int *  undo_pos,
unsigned short  value 
) [static]

Definition at line 1764 of file text.c.

Referenced by txt_undo_add_toop().

static void txt_undo_store_uint32 ( char *  undo_buf,
int *  undo_pos,
unsigned int  value 
) [static]

Definition at line 1772 of file text.c.

Referenced by txt_undo_add_block(), txt_undo_add_charop(), and txt_undo_add_toop().

void txt_unindent ( Text text)
int txt_utf8_index_to_offset ( char *  str,
int  index 
)

Definition at line 785 of file text.c.

References BLI_str_utf8_size().

Referenced by txt_move_down(), txt_move_up(), and txt_wrap_move_bol().

static int txt_utf8_len ( const char *  src) [static]

Definition at line 797 of file text.c.

References BLI_str_utf8_size(), and len().

Referenced by txt_do_undo(), txt_move_down(), and txt_move_up().

int txt_utf8_offset_to_index ( char *  str,
int  offset 
)

Definition at line 775 of file text.c.

References BLI_str_utf8_size().

Referenced by draw_brackets(), txt_move_down(), txt_move_up(), wrap_offset(), and wrap_offset_in_line().

void unlink_text ( Main bmain,
Text text 
)
void write_text ( Text text,
const char *  str 
)

Variable Documentation

char tab_to_spaces[] = " " [static]

Definition at line 2612 of file text.c.

Referenced by txt_convert_tab_to_spaces(), txt_indent(), and txt_unindent().

unsigned char undoing [static]