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