88 else if (code == 39) {
91 else if (code ==
'^') {
94 else if (code ==
'~') {
97 else if (code ==
'"') {
100 else if (code ==
'o') {
103 else if (code ==
'e') {
106 else if (code ==
'-') {
110 else if (char1 ==
'c') {
114 else if (code ==
'|') {
117 else if (code ==
'o') {
121 else if (char1 ==
'e') {
125 else if (code == 39) {
128 else if (code ==
'^') {
131 else if (code ==
'"') {
135 else if (char1 ==
'i') {
139 else if (code == 39) {
142 else if (code ==
'^') {
145 else if (code ==
'"') {
149 else if (char1 ==
'n') {
154 else if (char1 ==
'o') {
158 else if (code == 39) {
161 else if (code ==
'^') {
164 else if (code ==
'~') {
167 else if (code ==
'"') {
170 else if (code ==
'/') {
173 else if (code ==
'-') {
176 else if (code ==
'e') {
179 else if (code ==
'c') {
182 else if (code ==
'r') {
186 else if (char1 ==
'r') {
191 else if (char1 ==
's') {
196 else if (char1 ==
't') {
201 else if (char1 ==
'u') {
205 else if (code == 39) {
208 else if (code ==
'^') {
211 else if (code ==
'"') {
215 else if (char1 ==
'y') {
219 else if (code ==
'"') {
223 else if (char1 ==
'A') {
227 else if (code == 39) {
230 else if (code ==
'^') {
233 else if (code ==
'~') {
236 else if (code ==
'"') {
239 else if (code ==
'o') {
242 else if (code ==
'e') {
246 else if (char1 ==
'C') {
251 else if (char1 ==
'E') {
255 else if (code == 39) {
258 else if (code ==
'^') {
261 else if (code ==
'"') {
265 else if (char1 ==
'I') {
269 else if (code == 39) {
272 else if (code ==
'^') {
275 else if (code ==
'"') {
279 else if (char1 ==
'N') {
284 else if (char1 ==
'O') {
288 else if (code == 39) {
291 else if (code ==
'^') {
294 else if (code ==
'~') {
297 else if (code ==
'"') {
300 else if (code ==
'/') {
303 else if (code ==
'e') {
307 else if (char1 ==
'U') {
311 else if (code == 39) {
314 else if (code ==
'^') {
317 else if (code ==
'"') {
321 else if (char1 ==
'Y') {
326 else if (char1 ==
'1') {
334 else if (char1 ==
'3') {
339 else if (char1 ==
':') {
344 else if (char1 ==
'-') {
355 else if (char1 ==
'|') {
363 else if (char1 ==
'=') {
368 else if (char1 ==
'+') {
447 int selend, selstart, direction;
457 if (ef->
pos >= selstart) {
458 ef->
pos = selstart + offset;
460 if ((direction == -1) && ins) {
464 getfrom = selend + offset;
469 (offset *
sizeof(*ef->
textbuf));
473 ((ef->
len - selstart) + offset) *
sizeof(
CharInfo));
474 ef->
len -= ((selend - selstart) + 1);
490 const size_t str_len,
496 int selend, selstart;
499 selstart = selend = 0;
503 if ((ef->
len + str_len) - (selend - selstart) <=
MAXTEXT) {
540 char32_t *mem =
MEM_mallocN((
sizeof(*mem) * (str_len + 1)), __func__);
613 ot->
idname =
"FONT_OT_text_paste_from_file";
642 const float offset[3])
652 int nchars = 0, nbytes = 0;
655 const float rot[3] = {0.0f, 0.0f, 0.0f};
658 base = view_layer->
basact;
671 for (tmp = firstline,
a = 0; nbytes <
MAXTEXT &&
a < totline; tmp = tmp->
next,
a++) {
672 size_t nchars_line, nbytes_line;
674 nchars += nchars_line + 1;
675 nbytes += nbytes_line + 1;
694 for (tmp = firstline,
a = 0; cu->
len <
MAXTEXT &&
a < totline; tmp = tmp->
next,
a++) {
700 cu->
len += nbytes_line;
706 cu->
len += nbytes_line;
731 if (
line->line[0] ==
'\0') {
738 offset[1] = -linenum;
781 int i, selstart, selend;
787 for (i = selstart; i <= selend; i++) {
840 int style,
clear, selstart, selend;
857 ot->
name =
"Toggle Style";
859 ot->
idname =
"FONT_OT_style_toggle";
920 int selstart, selend;
974 int selstart, selend;
1038 } clipboard_system = {
NULL}, clipboard_vfont = {
NULL};
1042 if (clipboard_system.buf ==
NULL) {
1051 if (clipboard_vfont.buf ==
NULL) {
1059 if (clipboard_vfont.buf &&
STREQ(clipboard_vfont.buf, clipboard_system.buf)) {
1063 if ((clipboard_system.len <=
MAXTEXT) &&
1082 if (clipboard_vfont.buf) {
1113 {
LINE_BEGIN,
"LINE_BEGIN", 0,
"Line Begin",
""},
1114 {
LINE_END,
"LINE_END", 0,
"Line End",
""},
1115 {
PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
1116 {
NEXT_CHAR,
"NEXT_CHARACTER", 0,
"Next Character",
""},
1117 {
PREV_WORD,
"PREVIOUS_WORD", 0,
"Previous Word",
""},
1118 {
NEXT_WORD,
"NEXT_WORD", 0,
"Next Word",
""},
1119 {
PREV_LINE,
"PREVIOUS_LINE", 0,
"Previous Line",
""},
1120 {
NEXT_LINE,
"NEXT_LINE", 0,
"Next Line",
""},
1121 {
PREV_PAGE,
"PREVIOUS_PAGE", 0,
"Previous Page",
""},
1122 {
NEXT_PAGE,
"NEXT_PAGE", 0,
"Next Page",
""},
1140 while (ef->
pos > 0) {
1153 while (ef->
pos < ef->
len) {
1214 if (cursmove == -1) {
1224 else if (ef->
pos < 0) {
1261 ot->
name =
"Move Cursor";
1292 ot->
name =
"Move Select";
1294 ot->
idname =
"FONT_OT_move_select";
1309 "Where to move cursor to, to make a selection");
1324 int selstart, selend;
1325 bool changed =
false;
1332 selstart = selend = ef->
pos - 1;
1334 selstart =
max_ii(0, selstart);
1336 for (
int i = selstart; i <= selend; i++) {
1338 CLAMP(kern, -20, 20);
1357 ot->
name =
"Change Spacing";
1359 ot->
idname =
"FONT_OT_change_spacing";
1375 "Amount to decrease or increase character spacing with",
1399 CLAMP(character, 0, 255);
1415 ot->
name =
"Change Character";
1417 ot->
idname =
"FONT_OT_change_character";
1433 "Number to increase or decrease character code with",
1482 {
DEL_PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
1486 {
DEL_NEXT_SEL,
"NEXT_OR_SELECTION", 0,
"Next or Selection",
""},
1487 {
DEL_PREV_SEL,
"PREVIOUS_OR_SELECTION", 0,
"Previous or Selection",
""},
1497 int range[2] = {0, 0};
1498 bool has_select =
false;
1533 range[0] = ef->
pos - 1;
1539 if (ef->
pos >= ef->
len) {
1544 range[1] = ef->
pos + 1;
1568 if (range[0] != range[1]) {
1570 int len_remove = range[1] - range[0];
1571 int len_tail = ef->
len - range[1];
1573 for (
int i = 0; i < 2; i++) {
1575 if (*sel <= range[0]) {
1578 else if (*sel >= range[1]) {
1581 else if (*sel < range[1]) {
1593 ef->
len -= len_remove;
1624 "Which part of the text to delete");
1636 char *inserted_utf8;
1637 char32_t *inserted_text;
1647 inserted_text =
MEM_callocN(
sizeof(char32_t) * (
len + 1),
"FONT_insert_text");
1650 for (
a = 0;
a <
len;
a++) {
1668 static int accentcode = 0;
1670 int alt =
event->alt, shift =
event->shift, ctrl =
event->ctrl;
1671 int event_type =
event->type, event_val =
event->val;
1672 char32_t inserted_text[2] = {0};
1679 if (ef->
len != 0 && ef->
pos > 0) {
1687 if ((alt || ctrl || shift) == 0) {
1695 if (alt && ef->
len != 0 && ef->
pos > 0) {
1701 if (event_val && (ascii || event->
utf8_buf[0])) {
1703 if ((ascii > 31 && ascii < 254 && ascii != 127) || (
ELEM(ascii, 13, 10)) || (ascii == 8) ||
1715 ascii = inserted_text[0];
1731 inserted_text[0] = ascii;
1740 if (inserted_text[0]) {
1742 char inserted_utf8[8] = {0};
1749 if (event_val == 0) {
1759 ot->
name =
"Insert Text";
1761 ot->
idname =
"FONT_OT_text_insert";
1778 "Next typed character will strike through previous, for special character input");
1795 cu->
tb[i] = cu->
tb[i - 1];
1810 ot->
name =
"Add Text Box";
1812 ot->
idname =
"FONT_OT_textbox_add";
1836 for (i = index; i < cu->
totbox; i++) {
1837 cu->
tb[i] = cu->
tb[i + 1];
1840 if (cu->
actbox >= index) {
1854 ot->
name =
"Remove Text Box";
1856 ot->
idname =
"FONT_OT_textbox_remove";
1865 RNA_def_int(
ot->
srna,
"index", 0, 0, INT_MAX,
"Index",
"The current text box", 0, INT_MAX);
1890 ef->
len = len_char32;
1964 int selstart, selend;
1967 len = (selend - selstart) + 1;
1970 if (*
str >=
'a' && *
str <=
'z') {
1978 len = (selend - selstart) + 1;
1981 if (*
str >=
'A' && *
str <=
'Z') {
2034 if (*
str >=
'a' && *
str <=
'z') {
2048 ot->
name =
"Toggle Case";
2050 ot->
idname =
"FONT_OT_case_toggle";
2179 VFont *builtin_font;
2215 bContext *
C,
const int mval[2],
bool extend,
bool deselect,
bool toggle)
2222 const float active_bias_px = 4.0f;
2223 const float mval_fl[2] = {
UNPACK2(mval)};
2225 int i_iter, actbox_select = -1;
2227 float dist_sq_best = dist * dist;
2238 for (i_iter = 0; i_iter < cu->
totbox; i_iter++) {
2239 int i = (i_iter + i_actbox) % cu->
totbox;
2243 float obedit_co[4][3];
2244 float screen_co[4][2];
2250 copy_v3_fl3(obedit_co[0], rect.xmin, rect.ymin, 0.0f);
2251 copy_v3_fl3(obedit_co[1], rect.xmin, rect.ymax, 0.0f);
2252 copy_v3_fl3(obedit_co[2], rect.xmax, rect.ymax, 0.0f);
2253 copy_v3_fl3(obedit_co[3], rect.xmax, rect.ymin, 0.0f);
2255 for (j = 0; j < 4; j++) {
2258 project_ok |= (1 << j);
2262 dist_sq_min = dist_sq_best;
2263 for (j = 0, j_prev = 3; j < 4; j_prev = j++) {
2264 if ((project_ok & (1 << j)) && (project_ok & (1 << j_prev))) {
2266 mval_fl, screen_co[j_prev], screen_co[j]);
2267 if (dist_sq_min > dist_test_sq) {
2268 dist_sq_min = dist_test_sq;
2275 dist_sq_min += active_bias_px;
2278 if (dist_sq_min < dist_sq_best) {
2279 dist_sq_best = dist_sq_min;
2280 actbox_select = i + 1;
2284 if (actbox_select != -1) {
2285 if (cu->
actbox != actbox_select) {
2286 cu->
actbox = actbox_select;
struct Scene * CTX_data_scene(const bContext *C)
struct Object * CTX_data_edit_object(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
void BKE_curve_rect_from_textbox(const struct Curve *cu, const struct TextBox *tb, struct rctf *r_rect)
void BKE_curve_editfont_free(struct Curve *cu)
bool BKE_vfont_is_builtin(struct VFont *vfont)
void BKE_vfont_select_clamp(struct Object *ob)
bool BKE_vfont_to_curve(struct Object *ob, int mode)
int BKE_vfont_select_get(struct Object *ob, int *r_start, int *r_end)
struct VFont * BKE_vfont_load(struct Main *bmain, const char *filepath)
struct VFont * BKE_vfont_builtin_get(void)
void BKE_vfont_clipboard_set(const char32_t *text_buf, const struct CharInfo *info_buf, const size_t len)
void BKE_vfont_clipboard_free(void)
void BKE_vfont_clipboard_get(char32_t **r_text_buf, struct CharInfo **r_info_buf, size_t *r_len_utf8, size_t *r_len_utf32)
void id_us_min(struct ID *id)
void id_us_plus(struct ID *id)
General operations, lookup, etc. for blender objects.
void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
struct Object * BKE_object_add(struct Main *bmain, struct ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
void BKE_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
void mul_mat3_m4_v3(const float M[4][4], float r[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
MINLINE void add_v3_v3(float r[3], const float a[3])
size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_str_cursor_step_utf32(const char32_t *str, size_t maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONNULL()
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL()
unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_NONNULL()
size_t BLI_str_utf32_as_utf8_len(const char32_t *src) ATTR_NONNULL()
size_t BLI_str_utf32_as_utf8(char *__restrict dst, const char32_t *__restrict src, const size_t maxncpy) ATTR_NONNULL()
size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) ATTR_NONNULL()
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
Object is a sort of wrapper for general info.
#define FO_CURS_IS_MOTION(mode)
void ED_object_base_init_transform_on_add(struct Object *object, const float loc[3], const float rot[3])
void ED_outliner_select_sync_from_object_tag(struct bContext *C)
bool ED_operator_editfont(struct bContext *C)
bool ED_operator_object_active_editable_font(struct bContext *C)
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
float ED_view3d_select_dist_px(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
#define WM_FILESEL_RELPATH
#define WM_FILESEL_FILEPATH
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const Depsgraph * depsgraph
static int set_case(bContext *C, int ccase)
void FONT_OT_textbox_add(wmOperatorType *ot)
void FONT_OT_style_toggle(wmOperatorType *ot)
void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
static void text_update_edited(bContext *C, Object *obedit, int mode)
void FONT_OT_text_copy(wmOperatorType *ot)
static bool font_paste_wchar(Object *obedit, const char32_t *str, const size_t str_len, struct CharInfo *str_info)
void FONT_OT_line_break(wmOperatorType *ot)
static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void font_open_cancel(bContext *UNUSED(C), wmOperator *op)
static void copy_selection(Object *obedit)
void FONT_OT_unlink(wmOperatorType *ot)
static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int kill_selection(Object *obedit, int ins)
void ED_curve_editfont_make(Object *obedit)
void FONT_OT_select_all(wmOperatorType *ot)
static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
static int change_spacing_exec(bContext *C, wmOperator *op)
void FONT_OT_move(wmOperatorType *ot)
static int change_character_exec(bContext *C, wmOperator *op)
static int toggle_style_exec(bContext *C, wmOperator *op)
static int paste_from_file_exec(bContext *C, wmOperator *op)
static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int paste_text_exec(bContext *C, wmOperator *op)
void FONT_OT_text_cut(wmOperatorType *ot)
static int set_style_exec(bContext *C, wmOperator *op)
static int move_select_exec(bContext *C, wmOperator *op)
void FONT_OT_change_spacing(wmOperatorType *ot)
static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
static void txt_add_object(bContext *C, const TextLine *firstline, int totline, const float offset[3])
void ED_curve_editfont_load(Object *obedit)
void FONT_OT_change_character(wmOperatorType *ot)
static const EnumPropertyItem style_items[]
void FONT_OT_delete(wmOperatorType *ot)
void FONT_OT_textbox_remove(wmOperatorType *ot)
static int copy_text_exec(bContext *C, wmOperator *UNUSED(op))
static bool paste_selection(Object *obedit, ReportList *reports)
static const EnumPropertyItem delete_type_items[]
void FONT_OT_open(wmOperatorType *ot)
void FONT_OT_text_paste_from_file(wmOperatorType *ot)
void FONT_OT_move_select(wmOperatorType *ot)
static const EnumPropertyItem case_items[]
static int insert_text_exec(bContext *C, wmOperator *op)
static int font_open_exec(bContext *C, wmOperator *op)
static int font_unlink_exec(bContext *C, wmOperator *op)
static int textbox_remove_exec(bContext *C, wmOperator *op)
static int move_cursor(bContext *C, int type, const bool select)
static int delete_exec(bContext *C, wmOperator *op)
static int set_style(bContext *C, const int style, const bool clear)
void FONT_OT_case_set(wmOperatorType *ot)
void FONT_OT_case_toggle(wmOperatorType *ot)
static int paste_from_file(bContext *C, ReportList *reports, const char *filename)
static int set_case_exec(bContext *C, wmOperator *op)
void ED_curve_editfont_free(Object *obedit)
static void font_ui_template_init(bContext *C, wmOperator *op)
void FONT_OT_text_paste(wmOperatorType *ot)
static int insert_into_textbuf(Object *obedit, uintptr_t c)
static int line_break_exec(bContext *C, wmOperator *UNUSED(op))
void FONT_OT_text_insert(wmOperatorType *ot)
static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
static int move_exec(bContext *C, wmOperator *op)
static char32_t findaccent(char32_t char1, uint code)
bool ED_curve_editfont_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
void FONT_OT_style_set(wmOperatorType *ot)
static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
static const EnumPropertyItem move_type_items[]
static bool font_paste_utf8(bContext *C, const char *str, const size_t str_len)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void clear(Message *msg)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
_W64 unsigned int uintptr_t
struct EditFont * editfont
struct CharInfo * strinfo
struct CharInfo * textbufinfo
struct PropertyRNA * prop
struct RegionView3D * rv3d
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display, short sort)
void WM_clipboard_text_set(const char *buf, bool selection)
char * WM_clipboard_text_get(bool selection, int *r_len)