Blender V2.61 - r43446

BKE_text.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BKE_TEXT_H
00028 #define BKE_TEXT_H
00029 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 struct Main;
00041 struct Text;
00042 struct TextLine;
00043 struct SpaceText;
00044 
00045 void            free_text       (struct Text *text);
00046 void            txt_set_undostate   (int u);
00047 int             txt_get_undostate   (void);
00048 struct Text*    add_empty_text  (const char *name);
00049 int             txt_extended_ascii_as_utf8(char **str);
00050 int             reopen_text     (struct Text *text);
00051 struct Text*    add_text        (const char *file, const char *relpath); 
00052 struct Text*    copy_text       (struct Text *ta);
00053 void            unlink_text     (struct Main *bmain, struct Text *text);
00054 void            clear_text(struct Text *text);
00055 void            write_text(struct Text *text, const char *str);
00056 
00057 char*   txt_to_buf          (struct Text *text);
00058 void    txt_clean_text      (struct Text *text);
00059 void    txt_order_cursors   (struct Text *text);
00060 int     txt_find_string     (struct Text *text, const char *findstr, int wrap, int match_case);
00061 int     txt_has_sel         (struct Text *text);
00062 int     txt_get_span        (struct TextLine *from, struct TextLine *to);
00063 int     txt_utf8_offset_to_index(char *str, int offset);
00064 int     txt_utf8_index_to_offset(char *str, int index);
00065 void    txt_move_up         (struct Text *text, short sel);
00066 void    txt_move_down       (struct Text *text, short sel);
00067 void    txt_move_left       (struct Text *text, short sel);
00068 void    txt_move_right      (struct Text *text, short sel);
00069 void    txt_jump_left       (struct Text *text, short sel);
00070 void    txt_jump_right      (struct Text *text, short sel);
00071 void    txt_move_bof        (struct Text *text, short sel);
00072 void    txt_move_eof        (struct Text *text, short sel);
00073 void    txt_move_bol        (struct Text *text, short sel);
00074 void    txt_move_eol        (struct Text *text, short sel);
00075 void    txt_move_toline     (struct Text *text, unsigned int line, short sel);
00076 void    txt_move_to         (struct Text *text, unsigned int line, unsigned int ch, short sel);
00077 void    txt_pop_sel         (struct Text *text);
00078 void    txt_delete_char     (struct Text *text);
00079 void    txt_delete_word     (struct Text *text);
00080 void    txt_delete_selected (struct Text *text);
00081 void    txt_sel_all         (struct Text *text);
00082 void    txt_sel_line        (struct Text *text);
00083 char*   txt_sel_to_buf      (struct Text *text);
00084 void    txt_insert_buf      (struct Text *text, const char *in_buffer);
00085 void    txt_print_undo      (struct Text *text);
00086 void    txt_undo_add_toop   (struct Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc);
00087 void    txt_do_undo         (struct Text *text);
00088 void    txt_do_redo         (struct Text *text);
00089 void    txt_split_curline   (struct Text *text);
00090 void    txt_backspace_char  (struct Text *text);
00091 void    txt_backspace_word  (struct Text *text);
00092 int     txt_add_char        (struct Text *text, unsigned int add);
00093 int     txt_add_raw_char    (struct Text *text, unsigned int add);
00094 int     txt_replace_char    (struct Text *text, unsigned int add);
00095 void    txt_export_to_object(struct Text *text);
00096 void    txt_export_to_objects(struct Text *text);
00097 void    txt_unindent        (struct Text *text);
00098 void    txt_comment         (struct Text *text);
00099 void    txt_indent          (struct Text *text);
00100 void    txt_uncomment       (struct Text *text);
00101 int setcurr_tab_spaces  (struct Text *text, int space);
00102 
00103 void    txt_add_marker                      (struct Text *text, struct TextLine *line, int start, int end, const unsigned char color[4], int group, int flags);
00104 short   txt_clear_marker_region             (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
00105 short   txt_clear_markers                   (struct Text *text, int group, int flags);
00106 struct TextMarker   *txt_find_marker        (struct Text *text, struct TextLine *line, int curs, int group, int flags);
00107 struct TextMarker   *txt_find_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
00108 struct TextMarker   *txt_prev_marker        (struct Text *text, struct TextMarker *marker);
00109 struct TextMarker   *txt_next_marker        (struct Text *text, struct TextMarker *marker);
00110 struct TextMarker   *txt_prev_marker_color  (struct Text *text, struct TextMarker *marker);
00111 struct TextMarker   *txt_next_marker_color  (struct Text *text, struct TextMarker *marker);
00112 
00113 /* utility functions, could be moved somewhere more generic but are python/text related  */
00114 int text_check_bracket(char ch);
00115 int text_check_delim(char ch);
00116 int text_check_digit(char ch);
00117 int text_check_identifier(char ch);
00118 int text_check_whitespace(char ch);
00119 
00120 
00121 /* Undo opcodes */
00122 
00123 /* Simple main cursor movement */
00124 #define UNDO_CLEFT      001
00125 #define UNDO_CRIGHT     002
00126 #define UNDO_CUP        003
00127 #define UNDO_CDOWN      004
00128 
00129 /* Simple selection cursor movement */
00130 #define UNDO_SLEFT      005
00131 #define UNDO_SRIGHT     006
00132 #define UNDO_SUP        007
00133 #define UNDO_SDOWN      010
00134 
00135 /* Complex movement (opcode is followed
00136  * by 4 character line ID + a 2 character
00137  * position ID and opcode (repeat)) */
00138 #define UNDO_CTO        011
00139 #define UNDO_STO        012
00140 
00141 /* Complex editing */
00142 /* 1 - opcode is followed by 1 byte for ascii character and opcode (repeat)) */
00143 /* 2 - opcode is followed by 2 bytes for utf-8 character and opcode (repeat)) */
00144 /* 3 - opcode is followed by 3 bytes for utf-8 character and opcode (repeat)) */
00145 /* 4 - opcode is followed by 4 bytes for unicode character and opcode (repeat)) */
00146 #define UNDO_INSERT_1   013
00147 #define UNDO_INSERT_2   014
00148 #define UNDO_INSERT_3   015
00149 #define UNDO_INSERT_4   016
00150 
00151 #define UNDO_BS_1       017
00152 #define UNDO_BS_2       020
00153 #define UNDO_BS_3       021
00154 #define UNDO_BS_4       022
00155 
00156 #define UNDO_DEL_1      023
00157 #define UNDO_DEL_2      024
00158 #define UNDO_DEL_3      025
00159 #define UNDO_DEL_4      026
00160 
00161 /* Text block (opcode is followed
00162  * by 4 character length ID + the text
00163  * block itself + the 4 character length
00164  * ID (repeat) and opcode (repeat)) */
00165 #define UNDO_DBLOCK     027 /* Delete block */
00166 #define UNDO_IBLOCK     030 /* Insert block */
00167 
00168 /* Misc */
00169 #define UNDO_SWAP       031 /* Swap cursors */
00170 
00171 #define UNDO_INDENT     032
00172 #define UNDO_UNINDENT   033
00173 #define UNDO_COMMENT    034
00174 #define UNDO_UNCOMMENT  035
00175 
00176 /* Marker flags */
00177 #define TMARK_TEMP      0x01    /* Remove on non-editing events, don't save */
00178 #define TMARK_EDITALL   0x02    /* Edit all markers of the same group as one */
00179 
00180 #ifdef __cplusplus
00181 }
00182 #endif
00183 
00184 #endif