62 static char32_t
findaccent(char32_t char1,
const char code)
70 else if (code == 39) {
73 else if (code ==
'^') {
76 else if (code ==
'~') {
79 else if (code ==
'"') {
82 else if (code ==
'o') {
85 else if (code ==
'e') {
88 else if (code ==
'-') {
92 else if (char1 ==
'c') {
96 else if (code ==
'|') {
99 else if (code ==
'o') {
103 else if (char1 ==
'e') {
107 else if (code == 39) {
110 else if (code ==
'^') {
113 else if (code ==
'"') {
117 else if (char1 ==
'i') {
121 else if (code == 39) {
124 else if (code ==
'^') {
127 else if (code ==
'"') {
131 else if (char1 ==
'n') {
136 else if (char1 ==
'o') {
140 else if (code == 39) {
143 else if (code ==
'^') {
146 else if (code ==
'~') {
149 else if (code ==
'"') {
152 else if (code ==
'/') {
155 else if (code ==
'-') {
158 else if (code ==
'e') {
161 else if (code ==
'c') {
164 else if (code ==
'r') {
168 else if (char1 ==
'r') {
173 else if (char1 ==
's') {
178 else if (char1 ==
't') {
183 else if (char1 ==
'u') {
187 else if (code == 39) {
190 else if (code ==
'^') {
193 else if (code ==
'"') {
197 else if (char1 ==
'y') {
201 else if (code ==
'"') {
205 else if (char1 ==
'A') {
209 else if (code == 39) {
212 else if (code ==
'^') {
215 else if (code ==
'~') {
218 else if (code ==
'"') {
221 else if (code ==
'o') {
224 else if (code ==
'e') {
228 else if (char1 ==
'C') {
233 else if (char1 ==
'E') {
237 else if (code == 39) {
240 else if (code ==
'^') {
243 else if (code ==
'"') {
247 else if (char1 ==
'I') {
251 else if (code == 39) {
254 else if (code ==
'^') {
257 else if (code ==
'"') {
261 else if (char1 ==
'N') {
266 else if (char1 ==
'O') {
270 else if (code == 39) {
273 else if (code ==
'^') {
276 else if (code ==
'~') {
279 else if (code ==
'"') {
282 else if (code ==
'/') {
285 else if (code ==
'e') {
289 else if (char1 ==
'U') {
293 else if (code == 39) {
296 else if (code ==
'^') {
299 else if (code ==
'"') {
303 else if (char1 ==
'Y') {
308 else if (char1 ==
'1') {
316 else if (char1 ==
'3') {
321 else if (char1 ==
':') {
326 else if (char1 ==
'-') {
337 else if (char1 ==
'|') {
345 else if (char1 ==
'=') {
350 else if (char1 ==
'+') {
429 int selend, selstart, direction;
435 if (ef->
pos >= selstart) {
436 ef->
pos = selstart + ins;
438 if ((direction == -1) && ins) {
442 getfrom = selend + 1;
446 ef->
len -= ((selend - selstart) + 1);
462 const size_t str_len,
468 int selend, selstart;
471 selstart = selend = 0;
475 if ((ef->
len + str_len) - (selend - selstart) <=
MAXTEXT) {
512 char32_t *mem =
MEM_mallocN((
sizeof(*mem) * (str_len + 1)), __func__);
585 ot->
idname =
"FONT_OT_text_paste_from_file";
624 int nchars = 0, nbytes = 0;
627 const float rot[3] = {0.0f, 0.0f, 0.0f};
630 base = view_layer->
basact;
643 for (tmp = firstline,
a = 0; nbytes <
MAXTEXT &&
a < totline; tmp = tmp->
next,
a++) {
644 size_t nchars_line, nbytes_line;
646 nchars += nchars_line + 1;
647 nbytes += nbytes_line + 1;
666 for (tmp = firstline,
a = 0; cu->
len <
MAXTEXT &&
a < totline; tmp = tmp->
next,
a++) {
672 cu->
len += nbytes_line;
678 cu->
len += nbytes_line;
703 if (
line->line[0] ==
'\0') {
753 int i, selstart, selend;
759 for (i = selstart; i <= selend; i++) {
812 int style,
clear, selstart, selend;
829 ot->
name =
"Toggle Style";
831 ot->
idname =
"FONT_OT_style_toggle";
892 int selstart, selend;
946 int selstart, selend;
1010 } clipboard_system = {
NULL}, clipboard_vfont = {
NULL};
1014 if (clipboard_system.buf ==
NULL) {
1023 if (clipboard_vfont.buf ==
NULL) {
1031 if (clipboard_vfont.buf &&
STREQ(clipboard_vfont.buf, clipboard_system.buf)) {
1035 if ((clipboard_system.len <=
MAXTEXT) &&
1054 if (clipboard_vfont.buf) {
1085 {
LINE_BEGIN,
"LINE_BEGIN", 0,
"Line Begin",
""},
1086 {
LINE_END,
"LINE_END", 0,
"Line End",
""},
1087 {
PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
1088 {
NEXT_CHAR,
"NEXT_CHARACTER", 0,
"Next Character",
""},
1089 {
PREV_WORD,
"PREVIOUS_WORD", 0,
"Previous Word",
""},
1090 {
NEXT_WORD,
"NEXT_WORD", 0,
"Next Word",
""},
1091 {
PREV_LINE,
"PREVIOUS_LINE", 0,
"Previous Line",
""},
1092 {
NEXT_LINE,
"NEXT_LINE", 0,
"Next Line",
""},
1093 {
PREV_PAGE,
"PREVIOUS_PAGE", 0,
"Previous Page",
""},
1094 {
NEXT_PAGE,
"NEXT_PAGE", 0,
"Next Page",
""},
1112 while (ef->
pos > 0) {
1125 while (ef->
pos < ef->
len) {
1186 if (cursmove == -1) {
1196 else if (ef->
pos < 0) {
1233 ot->
name =
"Move Cursor";
1264 ot->
name =
"Move Select";
1266 ot->
idname =
"FONT_OT_move_select";
1281 "Where to move cursor to, to make a selection");
1296 int selstart, selend;
1297 bool changed =
false;
1304 selstart = selend = ef->
pos - 1;
1306 selstart =
max_ii(0, selstart);
1308 for (
int i = selstart; i <= selend; i++) {
1310 CLAMP(kern, -20, 20);
1329 ot->
name =
"Change Spacing";
1331 ot->
idname =
"FONT_OT_change_spacing";
1347 "Amount to decrease or increase character spacing with",
1371 CLAMP(character, 0, 255);
1387 ot->
name =
"Change Character";
1389 ot->
idname =
"FONT_OT_change_character";
1405 "Number to increase or decrease character code with",
1454 {
DEL_PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
1458 {
DEL_NEXT_SEL,
"NEXT_OR_SELECTION", 0,
"Next or Selection",
""},
1459 {
DEL_PREV_SEL,
"PREVIOUS_OR_SELECTION", 0,
"Previous or Selection",
""},
1469 int range[2] = {0, 0};
1470 bool has_select =
false;
1505 range[0] = ef->
pos - 1;
1511 if (ef->
pos >= ef->
len) {
1516 range[1] = ef->
pos + 1;
1540 if (range[0] != range[1]) {
1542 int len_remove = range[1] - range[0];
1543 int len_tail = ef->
len - range[1];
1545 for (
int i = 0; i < 2; i++) {
1547 if (*sel <= range[0]) {
1550 else if (*sel >= range[1]) {
1566 ef->
len -= len_remove;
1597 "Which part of the text to delete");
1609 char *inserted_utf8;
1610 char32_t *inserted_text;
1620 inserted_text =
MEM_callocN(
sizeof(char32_t) * (
len + 1),
"FONT_insert_text");
1623 for (
a = 0;
a <
len;
a++) {
1641 static bool accentcode =
false;
1642 const bool alt =
event->modifier &
KM_ALT;
1643 const bool shift =
event->modifier &
KM_SHIFT;
1644 const bool ctrl =
event->modifier &
KM_CTRL;
1645 char32_t insert_char_override = 0;
1646 char32_t inserted_text[2] = {0};
1653 if (ef->
len != 0 && ef->
pos > 0) {
1660 if (alt && ef->
len != 0 && ef->
pos > 0) {
1668 if ((alt || ctrl || shift) == 0) {
1671 insert_char_override =
'\t';
1674 if (insert_char_override || event->
utf8_buf[0]) {
1675 if (insert_char_override) {
1677 inserted_text[0] = insert_char_override;
1708 if (inserted_text[0]) {
1710 char inserted_utf8[8] = {0};
1722 ot->
name =
"Insert Text";
1724 ot->
idname =
"FONT_OT_text_insert";
1741 "Next typed character will strike through previous, for special character input");
1758 cu->
tb[i] = cu->
tb[i - 1];
1773 ot->
name =
"Add Text Box";
1775 ot->
idname =
"FONT_OT_textbox_add";
1799 for (i = index; i < cu->
totbox; i++) {
1800 cu->
tb[i] = cu->
tb[i + 1];
1803 if (cu->
actbox >= index) {
1817 ot->
name =
"Remove Text Box";
1819 ot->
idname =
"FONT_OT_textbox_remove";
1828 RNA_def_int(
ot->
srna,
"index", 0, 0, INT_MAX,
"Index",
"The current text box", 0, INT_MAX);
1853 ef->
len = len_char32;
1927 int selstart, selend;
1930 len = (selend - selstart) + 1;
1933 if (*
str >=
'a' && *
str <=
'z') {
1941 len = (selend - selstart) + 1;
1944 if (*
str >=
'A' && *
str <=
'Z') {
1997 if (*
str >=
'a' && *
str <=
'z') {
2011 ot->
name =
"Toggle Case";
2013 ot->
idname =
"FONT_OT_case_toggle";
2142 VFont *builtin_font;
2185 const float active_bias_px = 4.0f;
2186 const float mval_fl[2] = {
UNPACK2(mval)};
2188 int i_iter, actbox_select = -1;
2190 float dist_sq_best = dist * dist;
2199 for (i_iter = 0; i_iter < cu->
totbox; i_iter++) {
2200 int i = (i_iter + i_actbox) % cu->
totbox;
2204 float obedit_co[4][3];
2205 float screen_co[4][2];
2211 copy_v3_fl3(obedit_co[0], rect.xmin, rect.ymin, 0.0f);
2212 copy_v3_fl3(obedit_co[1], rect.xmin, rect.ymax, 0.0f);
2213 copy_v3_fl3(obedit_co[2], rect.xmax, rect.ymax, 0.0f);
2214 copy_v3_fl3(obedit_co[3], rect.xmax, rect.ymin, 0.0f);
2216 for (j = 0; j < 4; j++) {
2219 project_ok |= (1 << j);
2223 dist_sq_min = dist_sq_best;
2224 for (j = 0, j_prev = 3; j < 4; j_prev = j++) {
2225 if ((project_ok & (1 << j)) && (project_ok & (1 << j_prev))) {
2227 mval_fl, screen_co[j_prev], screen_co[j]);
2228 if (dist_sq_min > dist_test_sq) {
2229 dist_sq_min = dist_test_sq;
2236 dist_sq_min += active_bias_px;
2239 if (dist_sq_min < dist_sq_best) {
2240 dist_sq_best = dist_sq_min;
2241 actbox_select = i + 1;
2245 if (actbox_select != -1) {
2246 if (cu->
actbox != actbox_select) {
2247 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)
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_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_vfont_select_clamp(struct Object *ob)
bool BKE_vfont_to_curve(struct Object *ob, int mode)
void BKE_vfont_clipboard_set(const char32_t *text_buf, const struct CharInfo *info_buf, size_t len)
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)
bool BKE_vfont_is_builtin(const struct VFont *vfont)
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 * 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_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, size_t maxncpy) ATTR_NONNULL(1
size_t size_t BLI_str_utf32_as_utf8(char *__restrict dst, const char32_t *__restrict src, size_t maxncpy) ATTR_NONNULL(1
unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
size_t size_t size_t BLI_str_utf32_as_utf8_len(const char32_t *src) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONNULL(1
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)
@ ID_RECALC_COPY_ON_WRITE
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_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void ED_view3d_init_mats_rv3d(const struct Object *ob, struct RegionView3D *rv3d)
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 Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const Depsgraph * depsgraph
SyclQueue void void size_t num_bytes void
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[]
static int paste_from_file(bContext *C, ReportList *reports, const char *filepath)
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)
static char32_t findaccent(char32_t char1, const char code)
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 set_case_exec(bContext *C, wmOperator *op)
void ED_curve_editfont_free(Object *obedit)
bool ED_curve_editfont_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params)
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)
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)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
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)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
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)
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
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, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_clipboard_text_set(const char *buf, bool selection)
char * WM_clipboard_text_get(bool selection, int *r_len)