Blender V2.61 - r43446
|
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "MEM_guardedalloc.h"
#include "BLF_api.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_text_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "BKE_context.h"
#include "BKE_suggestions.h"
#include "BKE_text.h"
#include "BIF_gl.h"
#include "ED_datafiles.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "text_intern.h"
Go to the source code of this file.
Classes | |
struct | DrawCache |
Defines | |
#define | mono blf_mono_font |
Typedefs | |
typedef struct DrawCache | DrawCache |
Functions | |
static void | text_font_begin (SpaceText *st) |
static void | text_font_end (SpaceText *UNUSED(st)) |
static int | text_font_draw (SpaceText *UNUSED(st), int x, int y, const char *str) |
static int | text_font_draw_character (SpaceText *st, int x, int y, char c) |
static int | text_font_draw_character_utf8 (SpaceText *st, int x, int y, const char *c) |
static void | flatten_string_append (FlattenString *fs, const char *c, int accum, int len) |
int | flatten_string (SpaceText *st, FlattenString *fs, const char *in) |
void | flatten_string_free (FlattenString *fs) |
static int | find_builtinfunc (char *string) |
static int | find_specialvar (char *string) |
static int | find_decorator (char *string) |
static int | find_bool (char *string) |
static int | text_check_format_len (TextLine *line, unsigned int len) |
static void | txt_format_line (SpaceText *st, TextLine *line, int do_next) |
static void | format_draw_color (char formatchar) |
int | wrap_width (SpaceText *st, ARegion *ar) |
void | wrap_offset (SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int *offl, int *offc) |
void | wrap_offset_in_line (SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int *offl, int *offc) |
int | text_get_char_pos (SpaceText *st, const char *line, int cur) |
static const char * | txt_utf8_get_nth (const char *str, int n) |
static int | text_draw_wrapped (SpaceText *st, const char *str, int x, int y, int w, const char *format, int skip) |
static int | text_draw (SpaceText *st, char *str, int cshift, int maxwidth, int draw, int x, int y, const char *format) |
static void | text_drawcache_init (SpaceText *st) |
static void | text_update_drawcache (SpaceText *st, ARegion *ar) |
void | text_drawcache_tag_update (SpaceText *st, int full) |
void | text_free_caches (SpaceText *st) |
static int | text_get_visible_lines_no (SpaceText *st, int lineno) |
int | text_get_visible_lines (SpaceText *st, ARegion *ar, const char *str) |
int | text_get_span_wrap (SpaceText *st, ARegion *ar, TextLine *from, TextLine *to) |
int | text_get_total_lines (SpaceText *st, ARegion *ar) |
static TextLine * | first_visible_line (SpaceText *st, ARegion *ar, int *wrap_top) |
static void | calc_text_rcts (SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) |
static void | draw_textscroll (SpaceText *st, rcti *scroll, rcti *back) |
static void | draw_markers (SpaceText *st, ARegion *ar) |
static void | draw_documentation (SpaceText *st, ARegion *ar) |
static void | draw_suggestion_list (SpaceText *st, ARegion *ar) |
static void | draw_cursor (SpaceText *st, ARegion *ar) |
static void | draw_brackets (SpaceText *st, ARegion *ar) |
void | draw_text_main (SpaceText *st, ARegion *ar) |
void | text_update_character_width (SpaceText *st) |
void | text_scroll_to_cursor (SpaceText *st, ScrArea *sa) |
void | text_update_cursor_moved (bContext *C) |
Definition in file text_draw.c.
#define mono blf_mono_font |
Definition at line 64 of file text_draw.c.
Referenced by BKE_stamp_buf(), checker_board_text(), console_draw_string(), draw_suggestion_list(), draw_text_main(), text_font_begin(), text_font_draw(), text_font_draw_character(), text_font_draw_character_utf8(), text_update_character_width(), and textview_draw().
Definition at line 1095 of file text_draw.c.
References CLAMP(), Text::curl, ListBase::first, Text::lines, MAX2, MIN2, SpaceText::pix_per_line, Text::sell, SpaceText::text, text_get_span_wrap(), text_get_total_lines(), SpaceText::top, SpaceText::txtbar, SpaceText::viewlines, ARegion::winx, ARegion::winy, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by draw_text_main().
Definition at line 1594 of file text_draw.c.
References BLI_str_prev_char_utf8(), BLI_str_utf8_size(), Text::curc, Text::curl, SpaceText::cwidth, find(), ListBase::first, TextLine::format, SpaceText::left, TextLine::len, len(), SpaceText::lheight, TextLine::line, Text::lines, TextLine::next, NULL, TextLine::prev, SpaceText::showlinenrs, SpaceText::showsyntax, stack, strlen(), SpaceText::text, text_check_bracket(), text_font_draw_character(), text_get_char_pos(), TEXTXLOC, TH_HILITE, SpaceText::top, txt_get_span(), TXT_OFFSET, txt_utf8_offset_to_index(), UI_ThemeColor(), ARegion::winy, and wrap_offset().
Referenced by draw_text_main().
Definition at line 1478 of file text_draw.c.
References Text::curc, Text::curl, SpaceText::cwidth, ListBase::first, i, SpaceText::left, SpaceText::lheight, TextLine::line, SpaceText::line_hlight, Text::lines, SpaceText::overwrite, Text::selc, Text::sell, SpaceText::showlinenrs, SpaceText::tabnumber, SpaceText::text, text_get_char_pos(), text_get_visible_lines(), TEXTXLOC, TH_HILITE, TH_SHADE2, SpaceText::top, txt_get_span(), TXT_OFFSET, UI_ThemeColor(), simple_enum_gen::w, ARegion::winx, ARegion::winy, SpaceText::wordwrap, wrap_offset(), and wrap_offset_in_line().
Referenced by draw_text_main().
Definition at line 1316 of file text_draw.c.
References Text::curc, Text::curl, SpaceText::cwidth, DOC_HEIGHT, DOC_WIDTH, i, SpaceText::left, SpaceText::lheight, NULL, p, TextLine::prev, SpaceText::showlinenrs, SUGG_LIST_WIDTH, SpaceText::text, text_draw(), texttool_docs_get(), texttool_suggest_first(), texttool_text_is_active(), TEXTXLOC, TH_BACK, TH_SHADE1, TH_TEXT, SpaceText::top, TXT_OFFSET, UI_ThemeColor(), and ARegion::winy.
Referenced by draw_text_main().
Definition at line 1232 of file text_draw.c.
References BLI_findindex(), BLI_findlink(), BLI_freelinkN(), TextMarker::color, SpaceText::cwidth, TextMarker::end, ListBase::first, first_visible_line(), i, SpaceText::left, TextLine::len, SpaceText::lheight, TextLine::line, TextMarker::lineno, Text::lines, Text::markers, TextMarker::next, next, NULL, SpaceText::showlinenrs, TextMarker::start, SpaceText::text, text_get_char_pos(), TEXTXLOC, SpaceText::top, txt_get_span(), TXT_OFFSET, SpaceText::viewlines, ARegion::winx, ARegion::winy, and wrap_offset().
Referenced by draw_text_main().
Definition at line 1404 of file text_draw.c.
References BLF_width(), BLI_strncpy(), Text::curc, Text::curl, SpaceText::cwidth, i, SpaceText::left, SpaceText::lheight, mono, SuggItem::next, NULL, TextLine::prev, SpaceText::showlinenrs, str, SUGG_LIST_SIZE, SUGG_LIST_WIDTH, SpaceText::text, text_draw(), text_pop_suggest_list(), texttool_suggest_first(), texttool_suggest_last(), texttool_suggest_selected(), texttool_suggest_top(), texttool_text_is_active(), TEXTXLOC, TH_BACK, TH_SHADE1, TH_SHADE2, TH_SYNTAX_B, TH_SYNTAX_L, TH_SYNTAX_N, TH_TEXT, SpaceText::top, TXT_OFFSET, UI_ThemeColor(), simple_enum_gen::w, and ARegion::winy.
Referenced by draw_text_main().
Definition at line 1721 of file text_draw.c.
References BLF_fixed_width(), BLI_snprintf(), calc_text_rcts(), Text::curl, SpaceText::cwidth, draw_brackets(), draw_cursor(), draw_documentation(), draw_markers(), draw_suggestion_list(), draw_textscroll(), ListBase::first, SpaceText::flags, TextLine::format, i, ListBase::last, SpaceText::left, SpaceText::lheight, SpaceText::linenrs_tot, Text::lines, SpaceText::margin_column, MAX2, mono, TextLine::next, Text::sell, SpaceText::showlinenrs, SpaceText::showsyntax, ST_SHOW_MARGIN, SpaceText::text, text_draw(), text_draw_wrapped(), text_font_begin(), text_font_draw(), text_font_end(), text_get_visible_lines_no(), text_update_drawcache(), TEXTXLOC, TH_GRID, TH_HILITE, TH_TEXT, SpaceText::top, txt_clean_text(), txt_format_line(), TXT_OFFSET, TXT_SCROLL_WIDTH, UI_ThemeColor(), SpaceText::viewlines, ARegion::winx, ARegion::winy, and SpaceText::wordwrap.
Referenced by text_main_area_draw().
Definition at line 1208 of file text_draw.c.
References SpaceText::flags, MIN2, ST_SCROLL_SELECT, TH_BACK, TH_HILITE, bTheme::tui, SpaceText::txtbar, UI_CNR_ALL, UI_GetTheme(), UI_GetThemeColor3ubv(), UI_SCROLL_PRESSED, UI_ThemeColor(), uiRoundBox(), uiSetRoundBox(), uiWidgetScrollDraw(), ThemeUI::wcol_scroll, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by draw_text_main().
static int find_bool | ( | char * | string | ) | [static] |
Definition at line 255 of file text_draw.c.
References i, and text_check_identifier().
Referenced by txt_format_line().
static int find_builtinfunc | ( | char * | string | ) | [static] |
Definition at line 189 of file text_draw.c.
References i, and text_check_identifier().
Referenced by txt_format_line().
static int find_decorator | ( | char * | string | ) | [static] |
Definition at line 243 of file text_draw.c.
References i, and text_check_identifier().
Referenced by txt_format_line().
static int find_specialvar | ( | char * | string | ) | [static] |
Definition at line 228 of file text_draw.c.
References i, and text_check_identifier().
Referenced by txt_format_line().
Definition at line 1062 of file text_draw.c.
References ListBase::first, i, Text::lines, TextLine::next, SpaceText::text, text_get_visible_lines_no(), text_update_drawcache(), SpaceText::top, and SpaceText::wordwrap.
Referenced by draw_markers().
int flatten_string | ( | SpaceText * | st, |
FlattenString * | fs, | ||
const char * | in | ||
) |
Definition at line 142 of file text_draw.c.
References FlattenString::accum, BLI_str_utf8_size(), FlattenString::buf, FlattenString::fixedaccum, FlattenString::fixedbuf, flatten_string_append(), i, len(), FlattenString::len, and SpaceText::tabnumber.
Referenced by text_convert_whitespace_exec(), text_draw(), text_draw_wrapped(), and txt_format_line().
static void flatten_string_append | ( | FlattenString * | fs, |
const char * | c, | ||
int | accum, | ||
int | len | ||
) | [static] |
Definition at line 110 of file text_draw.c.
References FlattenString::accum, FlattenString::buf, FlattenString::fixedbuf, i, len(), FlattenString::len, MEM_callocN(), MEM_freeN(), and FlattenString::pos.
Referenced by flatten_string().
void flatten_string_free | ( | FlattenString * | fs | ) |
Definition at line 174 of file text_draw.c.
References FlattenString::accum, FlattenString::buf, FlattenString::fixedaccum, FlattenString::fixedbuf, and MEM_freeN().
Referenced by text_convert_whitespace_exec(), text_draw(), text_draw_wrapped(), and txt_format_line().
static void format_draw_color | ( | char | formatchar | ) | [static] |
Definition at line 459 of file text_draw.c.
References TH_BACK, TH_SYNTAX_B, TH_SYNTAX_C, TH_SYNTAX_L, TH_SYNTAX_N, TH_SYNTAX_V, TH_TEXT, UI_ThemeColor(), and UI_ThemeColorBlend().
Referenced by text_draw(), and text_draw_wrapped().
static int text_check_format_len | ( | TextLine * | line, |
unsigned int | len | ||
) | [static] |
Definition at line 275 of file text_draw.c.
References TextLine::format, MEM_freeN(), MEM_mallocN(), and strlen().
Referenced by txt_format_line().
static int text_draw | ( | SpaceText * | st, |
char * | str, | ||
int | cshift, | ||
int | maxwidth, | ||
int | draw, | ||
int | x, | ||
int | y, | ||
const char * | format | ||
) | [static] |
Definition at line 757 of file text_draw.c.
References FlattenString::accum, BLI_str_utf8_size(), FlattenString::buf, SpaceText::cwidth, flatten_string(), flatten_string_free(), format_draw_color(), MIN2, SpaceText::showlinenrs, SpaceText::showsyntax, text_font_draw(), text_font_draw_character_utf8(), TEXTXLOC, TXT_OFFSET, txt_utf8_get_nth(), and simple_enum_gen::w.
Referenced by draw_documentation(), draw_suggestion_list(), draw_text_main(), and text_scroll_to_cursor().
static int text_draw_wrapped | ( | SpaceText * | st, |
const char * | str, | ||
int | x, | ||
int | y, | ||
int | w, | ||
const char * | format, | ||
int | skip | ||
) | [static] |
Definition at line 700 of file text_draw.c.
References BLI_str_utf8_size(), FlattenString::buf, SpaceText::cwidth, flatten_string(), flatten_string_free(), format_draw_color(), i, SpaceText::lheight, max, SpaceText::showsyntax, str, text_font_draw_character_utf8(), and txt_utf8_get_nth().
Referenced by draw_text_main().
static void text_drawcache_init | ( | SpaceText * | st | ) | [static] |
Definition at line 820 of file text_draw.c.
References BLI_countlist(), SpaceText::drawcache, Text::lines, MEM_callocN(), DrawCache::nlines, SpaceText::text, DrawCache::text_id, and DrawCache::winx.
Referenced by text_update_drawcache().
void text_drawcache_tag_update | ( | SpaceText * | st, |
int | full | ||
) |
Definition at line 935 of file text_draw.c.
References BLI_findindex(), SpaceText::drawcache, DrawCache::nlines, NULL, SpaceText::text, DrawCache::update_flag, DrawCache::valid_head, and DrawCache::valid_tail.
Referenced by ED_text_undo_step(), text_comment_exec(), text_convert_whitespace_exec(), text_cut_exec(), text_delete_exec(), text_find_and_replace(), text_indent_exec(), text_insert_exec(), text_line_break_exec(), text_listener(), text_new_exec(), text_open_exec(), text_paste_exec(), text_reload_exec(), text_uncomment_exec(), text_unindent_exec(), and text_unlink_exec().
static void text_font_begin | ( | SpaceText * | st | ) | [static] |
Definition at line 66 of file text_draw.c.
References BLF_size(), SpaceText::lheight, and mono.
Referenced by draw_text_main(), and text_update_character_width().
static int text_font_draw | ( | SpaceText * | UNUSEDst, |
int | x, | ||
int | y, | ||
const char * | str | ||
) | [static] |
Definition at line 75 of file text_draw.c.
References BLF_draw(), BLF_DRAW_STR_DUMMY_MAX, BLF_position(), BLF_width(), and mono.
Referenced by draw_text_main(), and text_draw().
static int text_font_draw_character | ( | SpaceText * | st, |
int | x, | ||
int | y, | ||
char | c | ||
) | [static] |
Definition at line 83 of file text_draw.c.
References BLF_draw(), BLF_position(), SpaceText::cwidth, mono, and str.
Referenced by draw_brackets().
static int text_font_draw_character_utf8 | ( | SpaceText * | st, |
int | x, | ||
int | y, | ||
const char * | c | ||
) | [static] |
Definition at line 95 of file text_draw.c.
References BLF_draw(), BLF_position(), BLI_str_utf8_size(), BLI_UTF8_MAX, SpaceText::cwidth, len(), mono, and str.
Referenced by text_draw(), and text_draw_wrapped().
static void text_font_end | ( | SpaceText * | UNUSEDst | ) | [static] |
Definition at line 71 of file text_draw.c.
Referenced by draw_text_main(), and text_update_character_width().
void text_free_caches | ( | SpaceText * | st | ) |
Definition at line 977 of file text_draw.c.
References SpaceText::drawcache, DrawCache::line_height, and MEM_freeN().
Referenced by text_free().
int text_get_char_pos | ( | SpaceText * | st, |
const char * | line, | ||
int | cur | ||
) |
Definition at line 678 of file text_draw.c.
References BLI_str_utf8_size(), i, and SpaceText::tabnumber.
Referenced by cursor_skip_find_line(), draw_brackets(), draw_cursor(), draw_markers(), txt_wrap_move_down(), and txt_wrap_move_up().
Definition at line 1034 of file text_draw.c.
References TextLine::line, TextLine::next, text_get_visible_lines(), txt_get_span(), and SpaceText::wordwrap.
Referenced by calc_text_rcts().
Definition at line 1051 of file text_draw.c.
References SpaceText::drawcache, text_update_drawcache(), and DrawCache::total_lines.
Referenced by calc_text_rcts(), text_scroll_modal(), and txt_screen_skip().
Definition at line 999 of file text_draw.c.
References BLI_str_utf8_size(), i, max, SpaceText::tabnumber, and wrap_width().
Referenced by cursor_skip_find_line(), draw_cursor(), get_first_visible_line(), text_get_span_wrap(), text_update_drawcache(), txt_wrap_move_down(), txt_wrap_move_up(), and wrap_offset().
static int text_get_visible_lines_no | ( | SpaceText * | st, |
int | lineno | ||
) | [static] |
Definition at line 992 of file text_draw.c.
References SpaceText::drawcache, and DrawCache::line_height.
Referenced by draw_text_main(), and first_visible_line().
Definition at line 1860 of file text_draw.c.
References Text::curc, Text::curl, SpaceText::cwidth, ELEM3, ListBase::first, i, SpaceText::left, TextLine::line, Text::lines, ARegion::next, NULL, ScrArea::regionbase, ARegion::regiontype, RGN_TYPE_WINDOW, Text::selc, Text::sell, SpaceText::text, text_draw(), text_update_character_width(), SpaceText::top, txt_get_span(), TXT_SCROLL_WIDTH, SpaceText::viewlines, ARegion::winx, SpaceText::wordwrap, and wrap_offset().
Referenced by text_listener(), and text_update_cursor_moved().
void text_update_character_width | ( | SpaceText * | st | ) |
Definition at line 1850 of file text_draw.c.
References BLF_fixed_width(), SpaceText::cwidth, MAX2, mono, text_font_begin(), and text_font_end().
Referenced by text_cursor_set_to_pos(), text_do_suggest_select(), text_line_number_invoke(), text_scroll_apply(), text_scroll_invoke(), text_scroll_to_cursor(), text_update_drawcache(), txt_wrap_move_bol(), txt_wrap_move_down(), txt_wrap_move_eol(), and txt_wrap_move_up().
void text_update_cursor_moved | ( | bContext * | C | ) |
Definition at line 1904 of file text_draw.c.
References CTX_wm_area(), CTX_wm_space_text(), and text_scroll_to_cursor().
Referenced by ED_text_undo_step(), text_clear_all_markers_exec(), text_comment_exec(), text_convert_whitespace_exec(), text_cursor_set_apply(), text_cursor_set_exec(), text_cursor_set_exit(), text_cut_exec(), text_delete_exec(), text_find_and_replace(), text_indent_exec(), text_insert_exec(), text_jump_exec(), text_line_break_exec(), text_line_number_invoke(), text_make_internal_exec(), text_move_cursor(), text_next_marker_exec(), text_paste_exec(), text_previous_marker_exec(), text_reload_exec(), text_run_script(), text_save_as_exec(), text_save_exec(), text_select_all_exec(), text_select_line_exec(), text_select_word_exec(), text_uncomment_exec(), text_unindent_exec(), and text_unlink_exec().
Definition at line 831 of file text_draw.c.
References BLI_countlist(), SpaceText::cwidth, DrawCache::cwidth, SpaceText::drawcache, ListBase::first, Text::id, SpaceText::lheight, DrawCache::lheight, TextLine::line, DrawCache::line_height, SpaceText::linenrs_tot, Text::lines, MAX_ID_NAME, MEM_callocN(), MEM_freeN(), MEM_reallocN(), ID::name, TextLine::next, DrawCache::nlines, NULL, SpaceText::showlinenrs, DrawCache::showlinenrs, size(), SpaceText::tabnumber, DrawCache::tabnumber, SpaceText::text, text_drawcache_init(), text_get_visible_lines(), DrawCache::text_id, text_update_character_width(), DrawCache::total_lines, DrawCache::update_flag, DrawCache::valid_head, DrawCache::valid_tail, ARegion::winx, DrawCache::winx, SpaceText::wordwrap, and DrawCache::wordwrap.
Referenced by draw_text_main(), first_visible_line(), and text_get_total_lines().
Definition at line 306 of file text_draw.c.
References BLI_str_utf8_size(), FlattenString::buf, find(), find_bool(), find_builtinfunc(), find_decorator(), find_specialvar(), flatten_string(), flatten_string_free(), TextLine::format, i, len(), TextLine::line, TextLine::next, NULL, TextLine::prev, str, strlen(), text_check_delim(), text_check_digit(), text_check_format_len(), TXT_DBLQUOTSTR, TXT_SNGQUOTSTR, and TXT_TRISTR.
Referenced by draw_text_main().
static const char* txt_utf8_get_nth | ( | const char * | str, |
int | n | ||
) | [static] |
Definition at line 691 of file text_draw.c.
References BLI_str_utf8_size().
Referenced by text_draw(), and text_draw_wrapped().
void wrap_offset | ( | SpaceText * | st, |
ARegion * | ar, | ||
TextLine * | linein, | ||
int | cursin, | ||
int * | offl, | ||
int * | offc | ||
) |
Definition at line 528 of file text_draw.c.
References BLI_str_utf8_size(), ListBase::first, i, TextLine::line, Text::lines, max, TextLine::next, SpaceText::tabnumber, SpaceText::text, text_get_visible_lines(), SpaceText::top, txt_utf8_offset_to_index(), SpaceText::wordwrap, and wrap_width().
Referenced by draw_brackets(), draw_cursor(), draw_markers(), and text_scroll_to_cursor().
void wrap_offset_in_line | ( | SpaceText * | st, |
ARegion * | ar, | ||
TextLine * | linein, | ||
int | cursin, | ||
int * | offl, | ||
int * | offc | ||
) |
Definition at line 619 of file text_draw.c.
References BLI_str_utf8_size(), i, TextLine::line, max, SpaceText::tabnumber, SpaceText::text, txt_utf8_offset_to_index(), SpaceText::wordwrap, and wrap_width().
Referenced by cursor_skip_find_line(), draw_cursor(), txt_wrap_move_down(), and txt_wrap_move_up().
Definition at line 517 of file text_draw.c.
References SpaceText::cwidth, max, SpaceText::showlinenrs, TEXTXLOC, TXT_OFFSET, TXT_SCROLL_WIDTH, and ARegion::winx.
Referenced by text_cursor_set_to_pos_wrapped(), text_get_cursor_rel(), text_get_visible_lines(), txt_wrap_move_bol(), txt_wrap_move_eol(), wrap_offset(), and wrap_offset_in_line().