Blender  V2.93
text_intern.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 /* internal exports only */
27 
28 struct ARegion;
29 struct ScrArea;
30 struct SpaceText;
31 struct Text;
32 struct TextLine;
33 struct bContext;
34 struct wmOperatorType;
35 
36 /* text_draw.c */
37 void draw_text_main(struct SpaceText *st, struct ARegion *region);
38 
39 void text_update_line_edited(struct TextLine *line);
40 void text_update_edited(struct Text *text);
42 void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *area, const bool center);
44 
45 /* Padding around line numbers in character widths. */
46 #define TXT_NUMCOL_PAD 1.0f
47 /* Total width of the optional line numbers column. */
48 #define TXT_NUMCOL_WIDTH(st) \
49  ((st)->runtime.cwidth_px * ((st)->runtime.line_number_display_digits + (2 * TXT_NUMCOL_PAD)))
50 
51 /* Padding on left of body text in character units. */
52 #define TXT_BODY_LPAD 1.0f
53 /* Left position of body text. */
54 #define TXT_BODY_LEFT(st) \
55  ((st)->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * (st)->runtime.cwidth_px)
56 
57 #define TXT_SCROLL_WIDTH U.widget_unit
58 #define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit))
59 
60 /* Space between lines, in relation to letter height. */
61 #define TXT_LINE_VPAD 0.3f
62 /* Space between lines. */
63 #define TXT_LINE_SPACING(st) ((int)(TXT_LINE_VPAD * st->runtime.lheight_px))
64 /* Total height of each line. */
65 #define TXT_LINE_HEIGHT(st) ((int)((1.0f + TXT_LINE_VPAD) * st->runtime.lheight_px))
66 
67 #define SUGG_LIST_SIZE 7
68 #define SUGG_LIST_WIDTH 20
69 #define DOC_WIDTH 40
70 #define DOC_HEIGHT 10
71 
72 #define TOOL_SUGG_LIST 0x01
73 #define TOOL_DOCUMENT 0x02
74 
75 int wrap_width(const struct SpaceText *st, struct ARegion *region);
76 void wrap_offset(const struct SpaceText *st,
77  struct ARegion *region,
78  struct TextLine *linein,
79  int cursin,
80  int *offl,
81  int *offc);
82 void wrap_offset_in_line(const struct SpaceText *st,
83  struct ARegion *region,
84  struct TextLine *linein,
85  int cursin,
86  int *offl,
87  int *offc);
88 int text_get_char_pos(const struct SpaceText *st, const char *line, int cur);
89 
90 void text_drawcache_tag_update(struct SpaceText *st, int full);
91 void text_free_caches(struct SpaceText *st);
92 
93 bool text_do_suggest_select(struct SpaceText *st, struct ARegion *region, const int mval[2]);
94 void text_pop_suggest_list(void);
95 
96 int text_get_visible_lines(const struct SpaceText *st, struct ARegion *region, const char *str);
97 int text_get_span_wrap(const struct SpaceText *st,
98  struct ARegion *region,
99  struct TextLine *from,
100  struct TextLine *to);
101 int text_get_total_lines(struct SpaceText *st, struct ARegion *region);
102 
103 /* text_ops.c */
104 enum {
116  NEXT_PAGE
117 };
119 
120 void TEXT_OT_new(struct wmOperatorType *ot);
121 void TEXT_OT_open(struct wmOperatorType *ot);
122 void TEXT_OT_reload(struct wmOperatorType *ot);
123 void TEXT_OT_unlink(struct wmOperatorType *ot);
124 void TEXT_OT_save(struct wmOperatorType *ot);
125 void TEXT_OT_save_as(struct wmOperatorType *ot);
127 void TEXT_OT_run_script(struct wmOperatorType *ot);
129 
130 void TEXT_OT_paste(struct wmOperatorType *ot);
131 void TEXT_OT_copy(struct wmOperatorType *ot);
132 void TEXT_OT_cut(struct wmOperatorType *ot);
134 
137 void TEXT_OT_unindent(struct wmOperatorType *ot);
138 void TEXT_OT_indent(struct wmOperatorType *ot);
140 
141 void TEXT_OT_line_break(struct wmOperatorType *ot);
142 void TEXT_OT_insert(struct wmOperatorType *ot);
143 
145 void TEXT_OT_select_all(struct wmOperatorType *ot);
147 
148 void TEXT_OT_move_lines(struct wmOperatorType *ot);
149 
150 void TEXT_OT_jump(struct wmOperatorType *ot);
151 void TEXT_OT_move(struct wmOperatorType *ot);
153 void TEXT_OT_delete(struct wmOperatorType *ot);
155 
156 void TEXT_OT_scroll(struct wmOperatorType *ot);
157 void TEXT_OT_scroll_bar(struct wmOperatorType *ot);
159 void TEXT_OT_cursor_set(struct wmOperatorType *ot);
161 
162 /* find = find indicated text */
163 void TEXT_OT_find(struct wmOperatorType *ot);
165 void TEXT_OT_replace(struct wmOperatorType *ot);
167 
168 /* text_find = open properties, activate search button */
169 void TEXT_OT_start_find(struct wmOperatorType *ot);
170 
172 
174 
175 bool text_space_edit_poll(struct bContext *C);
176 
177 /* text_autocomplete.c */
179 
180 /* space_text.c */
181 extern const char *text_context_dir[]; /* doc access */
NSNotificationCenter * center
#define C
Definition: RandGen.cpp:39
StackEntry * from
#define str(s)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void text_pop_suggest_list(void)
void TEXT_OT_delete(struct wmOperatorType *ot)
Definition: text_ops.c:2447
const char * text_context_dir[]
Definition: space_text.c:235
void TEXT_OT_indent_or_autocomplete(struct wmOperatorType *ot)
Definition: text_ops.c:1103
int text_get_span_wrap(const struct SpaceText *st, struct ARegion *region, struct TextLine *from, struct TextLine *to)
void TEXT_OT_selection_set(struct wmOperatorType *ot)
Definition: text_ops.c:3294
void TEXT_OT_save(struct wmOperatorType *ot)
Definition: text_ops.c:658
void text_free_caches(struct SpaceText *st)
void text_update_line_edited(struct TextLine *line)
Definition: text_ops.c:232
void TEXT_OT_replace(struct wmOperatorType *ot)
Definition: text_ops.c:3687
@ DEL_PREV_WORD
Definition: text_intern.h:118
@ DEL_PREV_CHAR
Definition: text_intern.h:118
@ DEL_NEXT_WORD
Definition: text_intern.h:118
@ DEL_NEXT_CHAR
Definition: text_intern.h:118
void TEXT_OT_select_line(struct wmOperatorType *ot)
Definition: text_ops.c:1530
void TEXT_OT_paste(struct wmOperatorType *ot)
Definition: text_ops.c:936
void TEXT_OT_find_set_selected(struct wmOperatorType *ot)
Definition: text_ops.c:3730
void TEXT_OT_new(struct wmOperatorType *ot)
Definition: text_ops.c:292
int text_get_total_lines(struct SpaceText *st, struct ARegion *region)
void TEXT_OT_line_break(struct wmOperatorType *ot)
Definition: text_ops.c:1245
void TEXT_OT_cut(struct wmOperatorType *ot)
Definition: text_ops.c:1068
@ NEXT_LINE
Definition: text_intern.h:114
@ NEXT_CHAR
Definition: text_intern.h:110
@ FILE_TOP
Definition: text_intern.h:107
@ LINE_BEGIN
Definition: text_intern.h:105
@ PREV_WORD
Definition: text_intern.h:111
@ PREV_LINE
Definition: text_intern.h:113
@ FILE_BOTTOM
Definition: text_intern.h:108
@ PREV_CHAR
Definition: text_intern.h:109
@ LINE_END
Definition: text_intern.h:106
@ PREV_PAGE
Definition: text_intern.h:115
@ NEXT_PAGE
Definition: text_intern.h:116
@ NEXT_WORD
Definition: text_intern.h:112
void TEXT_OT_overwrite_toggle(struct wmOperatorType *ot)
Definition: text_ops.c:2489
void TEXT_OT_move_select(struct wmOperatorType *ot)
Definition: text_ops.c:2282
void text_update_cursor_moved(struct bContext *C)
void wrap_offset_in_line(const struct SpaceText *st, struct ARegion *region, struct TextLine *linein, int cursin, int *offl, int *offc)
void TEXT_OT_select_word(struct wmOperatorType *ot)
Definition: text_ops.c:1563
void TEXT_OT_scroll_bar(struct wmOperatorType *ot)
Definition: text_ops.c:2887
void TEXT_OT_line_number(struct wmOperatorType *ot)
Definition: text_ops.c:3409
void TEXT_OT_unlink(struct wmOperatorType *ot)
Definition: text_ops.c:522
void TEXT_OT_move_lines(struct wmOperatorType *ot)
Definition: text_ops.c:1601
bool text_do_suggest_select(struct SpaceText *st, struct ARegion *region, const int mval[2])
void text_update_edited(struct Text *text)
Definition: text_ops.c:245
void TEXT_OT_copy(struct wmOperatorType *ot)
Definition: text_ops.c:1028
void TEXT_OT_make_internal(struct wmOperatorType *ot)
Definition: text_ops.c:558
void TEXT_OT_run_script(struct wmOperatorType *ot)
Definition: text_ops.c:810
void wrap_offset(const struct SpaceText *st, struct ARegion *region, struct TextLine *linein, int cursin, int *offl, int *offc)
void TEXT_OT_jump(struct wmOperatorType *ot)
Definition: text_ops.c:2335
void TEXT_OT_insert(struct wmOperatorType *ot)
Definition: text_ops.c:3509
void TEXT_OT_unindent(struct wmOperatorType *ot)
Definition: text_ops.c:1188
void TEXT_OT_autocomplete(struct wmOperatorType *ot)
void TEXT_OT_resolve_conflict(struct wmOperatorType *ot)
Definition: text_ops.c:3883
void TEXT_OT_convert_whitespace(struct wmOperatorType *ot)
Definition: text_ops.c:1459
void TEXT_OT_indent(struct wmOperatorType *ot)
Definition: text_ops.c:1148
int wrap_width(const struct SpaceText *st, struct ARegion *region)
void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *area, const bool center)
void TEXT_OT_save_as(struct wmOperatorType *ot)
Definition: text_ops.c:729
bool text_space_edit_poll(struct bContext *C)
Definition: text_ops.c:187
void TEXT_OT_refresh_pyconstraints(struct wmOperatorType *ot)
Definition: text_ops.c:878
void TEXT_OT_cursor_set(struct wmOperatorType *ot)
Definition: text_ops.c:3343
void TEXT_OT_replace_set_selected(struct wmOperatorType *ot)
Definition: text_ops.c:3761
void TEXT_OT_start_find(struct wmOperatorType *ot)
Definition: text_header.c:100
void draw_text_main(struct SpaceText *st, struct ARegion *region)
void TEXT_OT_select_all(struct wmOperatorType *ot)
Definition: text_ops.c:1500
void TEXT_OT_open(struct wmOperatorType *ot)
Definition: text_ops.c:392
void TEXT_OT_find(struct wmOperatorType *ot)
Definition: text_ops.c:3618
void TEXT_OT_scroll(struct wmOperatorType *ot)
Definition: text_ops.c:2780
void TEXT_OT_comment_toggle(struct wmOperatorType *ot)
Definition: text_ops.c:1301
int text_get_visible_lines(const struct SpaceText *st, struct ARegion *region, const char *str)
void TEXT_OT_move(struct wmOperatorType *ot)
Definition: text_ops.c:2254
void text_drawcache_tag_update(struct SpaceText *st, int full)
void TEXT_OT_reload(struct wmOperatorType *ot)
Definition: text_ops.c:471
int text_get_char_pos(const struct SpaceText *st, const char *line, int cur)
void TEXT_OT_duplicate_line(struct wmOperatorType *ot)
Definition: text_ops.c:982
void text_update_character_width(struct SpaceText *st)
void TEXT_OT_to_3d_object(struct wmOperatorType *ot)
Definition: text_ops.c:3920
wmOperatorType * ot
Definition: wm_files.c:3156