Blender V5.3
text_intern.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <optional>
12
14
15#include "DNA_vec_types.h"
16
17namespace blender {
18
19/* Internal exports only. */
20
21struct ARegion;
22struct ScrArea;
23struct SpaceText;
24struct Text;
25struct TextLine;
26struct bContext;
27struct wmOperatorType;
28
29/* `text_draw.cc` */
30
31void draw_text_main(SpaceText *st, ARegion *region);
32
41std::optional<int2> space_text_cursor_region_xy_get(const SpaceText *st, const ARegion *region);
42
44void text_update_edited(Text *text);
45
50void space_text_scroll_to_cursor_with_area(SpaceText *st, ScrArea *area, bool center);
52
53/* Padding around line numbers in character widths. */
54#define TXT_NUMCOL_PAD 1.0f
55/* Total width of the optional line numbers column. */
56#define TXT_NUMCOL_WIDTH(st) \
57 ((st)->runtime->char_width_px * \
58 ((st)->runtime->line_number_display_digits + (2 * TXT_NUMCOL_PAD)))
59
60/* Padding on left of body text in character units. */
61#define TXT_BODY_LPAD 1.0f
62/* Left position of body text. */
63#define TXT_BODY_LEFT(st) \
64 ((st)->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * (st)->runtime->char_width_px)
65
66#define TXT_SCROLL_WIDTH U.widget_unit
67#define TXT_SCROLL_SPACE int(0.1f * U.widget_unit)
68
69/* Space between lines, in relation to letter height. */
70#define TXT_LINE_VPAD 0.3f
71/* Space between lines. */
72#define TXT_LINE_SPACING(st) int(TXT_LINE_VPAD * st->runtime->line_height_px)
73/* Total height of each line. */
74#define TXT_LINE_HEIGHT(st) int((1.0f + TXT_LINE_VPAD) * st->runtime->line_height_px)
75
76#define SUGG_LIST_SIZE 7
77#define SUGG_LIST_WIDTH 20
78
79#define TOOL_SUGG_LIST 0x01
80
81int space_text_wrap_width(const SpaceText *st, const ARegion *region);
85void space_text_wrap_offset(const SpaceText *st,
86 const ARegion *region,
87 TextLine *linein,
88 int cursin,
89 int *offl,
90 int *offc);
94void space_text_wrap_offset_in_line(const SpaceText *st,
95 const ARegion *region,
96 TextLine *linein,
97 int cursin,
98 int *offl,
99 int *offc);
100int space_text_get_char_pos(const SpaceText *st, const char *line, int cur);
101
102void space_text_drawcache_tag_update(SpaceText *st, bool full);
103void space_text_free_caches(SpaceText *st);
104
105bool space_text_do_suggest_select(SpaceText *st, const ARegion *region, const int mval[2]);
107
108int space_text_get_visible_lines(const SpaceText *st, const ARegion *region, const char *str);
109int space_text_get_span_wrap(const SpaceText *st,
110 const ARegion *region,
111 const TextLine *from,
112 const TextLine *to);
113int space_text_get_total_lines(SpaceText *st, const ARegion *region);
114
115/* `text_ops.cc` */
116
117enum {
119 LINE_END,
122 PREV_CHAR,
123 NEXT_CHAR,
124 PREV_WORD,
125 NEXT_WORD,
126 PREV_LINE,
127 NEXT_LINE,
128 PREV_PAGE,
130};
132
141
146
152
155
159
161
167
173
174/* The term: `find` means: find indicated text. */
180
181/* The term `text_find` means: open properties, activate search button. */
183
185
187
189
191
192/* `text_autocomplete.cc` */
193
195
196/* `space_text.cc` */
197
198extern "C" const char *text_context_dir[]; /* Doc access. */
199
200namespace ed::text {
202
205
208
211
216
219
221 int viewlines = 0;
222
224 float scroll_px_per_line = 0.0f;
225
230 int scroll_ofs_px[2]{0, 0};
231
233 void *drawcache = nullptr;
234};
235} // namespace ed::text
236} // namespace blender
#define C
Definition RandGen.cpp:29
#define str(s)
BMesh Iterators.
bool text_space_edit_poll(bContext *C)
Definition text_ops.cc:283
void TEXT_OT_delete(wmOperatorType *ot)
Definition text_ops.cc:2582
void TEXT_OT_new(wmOperatorType *ot)
Definition text_ops.cc:383
void space_text_drawcache_tag_update(SpaceText *st, const bool full)
Definition text_draw.cc:757
void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
Definition text_ops.cc:1183
void TEXT_OT_make_internal(wmOperatorType *ot)
Definition text_ops.cc:683
void text_update_line_edited(TextLine *line)
Definition text_ops.cc:328
void TEXT_OT_cursor_set(wmOperatorType *ot)
Definition text_ops.cc:3477
void TEXT_OT_autocomplete(wmOperatorType *ot)
void TEXT_OT_to_3d_object(wmOperatorType *ot)
Definition text_ops.cc:4328
void TEXT_OT_scroll_bar(wmOperatorType *ot)
Definition text_ops.cc:3027
void space_text_update_cursor_moved(bContext *C)
void TEXT_OT_resolve_conflict(wmOperatorType *ot)
Definition text_ops.cc:4291
void TEXT_OT_select_all(wmOperatorType *ot)
Definition text_ops.cc:1601
void TEXT_OT_convert_whitespace(wmOperatorType *ot)
Definition text_ops.cc:1558
void space_text_wrap_offset(const SpaceText *st, const ARegion *region, TextLine *linein, int cursin, int *offl, int *offc)
Definition text_draw.cc:210
int space_text_get_span_wrap(const SpaceText *st, const ARegion *region, const TextLine *from, const TextLine *to)
Definition text_draw.cc:872
int space_text_get_total_lines(SpaceText *st, const ARegion *region)
Definition text_draw.cc:895
void TEXT_OT_duplicate_line(wmOperatorType *ot)
Definition text_ops.cc:1060
void TEXT_OT_unindent(wmOperatorType *ot)
Definition text_ops.cc:1270
void TEXT_OT_update_shader(wmOperatorType *ot)
Definition text_ops.cc:4443
void TEXT_OT_save(wmOperatorType *ot)
Definition text_ops.cc:787
bool space_text_do_suggest_select(SpaceText *st, const ARegion *region, const int mval[2])
void TEXT_OT_line_break(wmOperatorType *ot)
Definition text_ops.cc:1327
void TEXT_OT_select_word(wmOperatorType *ot)
Definition text_ops.cc:1666
void TEXT_OT_unlink(wmOperatorType *ot)
Definition text_ops.cc:647
int space_text_get_char_pos(const SpaceText *st, const char *line, int cur)
Definition text_draw.cc:387
void TEXT_OT_jump(wmOperatorType *ot)
Definition text_ops.cc:2454
int space_text_wrap_width(const SpaceText *st, const ARegion *region)
Definition text_draw.cc:200
void TEXT_OT_scroll(wmOperatorType *ot)
Definition text_ops.cc:2917
void TEXT_OT_replace(wmOperatorType *ot)
Definition text_ops.cc:3926
void TEXT_OT_comment_toggle(wmOperatorType *ot)
Definition text_ops.cc:1385
void TEXT_OT_replace_set_selected(wmOperatorType *ot)
Definition text_ops.cc:4000
void TEXT_OT_jump_to_file_at_point(wmOperatorType *ot)
Definition text_ops.cc:4170
void TEXT_OT_cut(wmOperatorType *ot)
Definition text_ops.cc:1147
int space_text_get_visible_lines(const SpaceText *st, const ARegion *region, const char *str)
Definition text_draw.cc:833
void TEXT_OT_select_line(wmOperatorType *ot)
Definition text_ops.cc:1633
const char * text_context_dir[]
void TEXT_OT_open(wmOperatorType *ot)
Definition text_ops.cc:495
void space_text_free_caches(SpaceText *st)
Definition text_draw.cc:806
void text_update_edited(Text *text)
Definition text_ops.cc:338
void TEXT_OT_move_lines(wmOperatorType *ot)
Definition text_ops.cc:1704
void TEXT_OT_start_find(wmOperatorType *ot)
void TEXT_OT_selection_set(wmOperatorType *ot)
Definition text_ops.cc:3428
void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
Definition text_ops.cc:2624
void TEXT_OT_find_set_selected(wmOperatorType *ot)
Definition text_ops.cc:3969
void TEXT_OT_find(wmOperatorType *ot)
Definition text_ops.cc:3857
void TEXT_OT_move_select(wmOperatorType *ot)
Definition text_ops.cc:2401
void TEXT_OT_indent(wmOperatorType *ot)
Definition text_ops.cc:1229
void space_text_wrap_offset_in_line(const SpaceText *st, const ARegion *region, TextLine *linein, int cursin, int *offl, int *offc)
Definition text_draw.cc:315
std::optional< int2 > space_text_cursor_region_xy_get(const SpaceText *st, const ARegion *region)
void TEXT_OT_move(wmOperatorType *ot)
Definition text_ops.cc:2373
void draw_text_main(SpaceText *st, ARegion *region)
void TEXT_OT_paste(wmOperatorType *ot)
Definition text_ops.cc:1012
void space_text_scroll_to_cursor_with_area(SpaceText *st, ScrArea *area, const bool center)
void TEXT_OT_insert(wmOperatorType *ot)
Definition text_ops.cc:3746
void TEXT_OT_reload(wmOperatorType *ot)
Definition text_ops.cc:585
void text_pop_suggest_list()
void space_text_update_character_width(SpaceText *st)
void TEXT_OT_copy(wmOperatorType *ot)
Definition text_ops.cc:1106
void TEXT_OT_run_script(wmOperatorType *ot)
Definition text_ops.cc:947
void TEXT_OT_save_as(wmOperatorType *ot)
Definition text_ops.cc:867
void TEXT_OT_line_number(wmOperatorType *ot)
Definition text_ops.cc:3547