Blender V4.5
editfont.cc File Reference
#include <algorithm>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <cwchar>
#include <fcntl.h>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLI_string_cursor_utf8.h"
#include "BLI_utildefines.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_text_types.h"
#include "DNA_vfont_types.h"
#include "BKE_context.hh"
#include "BKE_curve.hh"
#include "BKE_global.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_library.hh"
#include "BKE_main.hh"
#include "BKE_object.hh"
#include "BKE_report.hh"
#include "BKE_vfont.hh"
#include "BLI_string_utf8.h"
#include "BLT_translation.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_curve.hh"
#include "ED_object.hh"
#include "ED_outliner.hh"
#include "ED_screen.hh"
#include "ED_view3d.hh"
#include "UI_interface.hh"
#include "curve_intern.hh"

Go to the source code of this file.

Macros

#define MAXTEXT   32766

Functions

Internal Utilities
static int kill_selection (Object *obedit, int ins)
static char32_t findaccent (char32_t char1, const char code)
static int insert_into_textbuf (Object *obedit, uintptr_t c)
static void text_update_edited (bContext *C, Object *obedit, const eEditFontMode mode)
static void font_select_update_primary_clipboard (Object *obedit)
Generic Copy Functions
static char * font_select_to_buffer (Object *obedit)
Generic Paste Functions
static bool font_paste_wchar (Object *obedit, const char32_t *str, const size_t str_len, const CharInfo *str_info)
static bool font_paste_utf8 (bContext *C, const char *str, const size_t str_len)
Paste From File Operator
static wmOperatorStatus paste_from_file (bContext *C, ReportList *reports, const char *filepath)
static wmOperatorStatus paste_from_file_exec (bContext *C, wmOperator *op)
static wmOperatorStatus paste_from_file_invoke (bContext *C, wmOperator *op, const wmEvent *)
void FONT_OT_text_paste_from_file (wmOperatorType *ot)
Insert Unicode Character
static void text_insert_unicode_cancel (bContext *C, void *arg_block, void *)
static void text_insert_unicode_confirm (bContext *C, void *arg_block, void *arg_string)
static uiBlockwm_block_insert_unicode_create (bContext *C, ARegion *region, void *arg_string)
static wmOperatorStatus text_insert_unicode_invoke (bContext *C, wmOperator *, const wmEvent *)
void FONT_OT_text_insert_unicode (wmOperatorType *ot)
Text To Object
static void txt_add_object (bContext *C, const TextLine *firstline, int totline, const float offset[3])
void ED_text_to_object (bContext *C, const Text *text, const bool split_lines)
Toggle Style Operator
static wmOperatorStatus toggle_style_exec (bContext *C, wmOperator *op)
void FONT_OT_style_toggle (wmOperatorType *ot)
Select All Operator
static wmOperatorStatus font_select_all_exec (bContext *C, wmOperator *)
void FONT_OT_select_all (wmOperatorType *ot)
Copy Text Operator
static void copy_selection (Object *obedit)
static wmOperatorStatus copy_text_exec (bContext *C, wmOperator *)
void FONT_OT_text_copy (wmOperatorType *ot)
Cut Text Operator
static wmOperatorStatus cut_text_exec (bContext *C, wmOperator *)
void FONT_OT_text_cut (wmOperatorType *ot)
Paste Text Operator
static bool paste_selection (Object *obedit, ReportList *reports)
static wmOperatorStatus paste_text_exec (bContext *C, wmOperator *op)
void FONT_OT_text_paste (wmOperatorType *ot)
Move Select Operator
static wmOperatorStatus move_select_exec (bContext *C, wmOperator *op)
void FONT_OT_move_select (wmOperatorType *ot)
Change Spacing
static wmOperatorStatus change_spacing_exec (bContext *C, wmOperator *op)
void FONT_OT_change_spacing (wmOperatorType *ot)
Change Character
static wmOperatorStatus change_character_exec (bContext *C, wmOperator *op)
void FONT_OT_change_character (wmOperatorType *ot)
Line Break Operator
static wmOperatorStatus line_break_exec (bContext *C, wmOperator *)
void FONT_OT_line_break (wmOperatorType *ot)
Insert Text Operator
static wmOperatorStatus insert_text_exec (bContext *C, wmOperator *op)
static wmOperatorStatus insert_text_invoke (bContext *C, wmOperator *op, const wmEvent *event)
void FONT_OT_text_insert (wmOperatorType *ot)
Font Selection Operator
static int font_cursor_text_index_from_event (bContext *C, Object *obedit, const wmEvent *event)
static void font_cursor_set_apply (bContext *C, const wmEvent *event)
static wmOperatorStatus font_selection_set_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus font_selection_set_modal (bContext *C, wmOperator *, const wmEvent *event)
void FONT_OT_selection_set (wmOperatorType *ot)
Select Word Operator
static wmOperatorStatus font_select_word_exec (bContext *C, wmOperator *)
void FONT_OT_select_word (wmOperatorType *ot)
Text-Box Add Operator
static wmOperatorStatus textbox_add_exec (bContext *C, wmOperator *)
void FONT_OT_textbox_add (wmOperatorType *ot)
Text-Box Remove Operator
static wmOperatorStatus textbox_remove_exec (bContext *C, wmOperator *op)
void FONT_OT_textbox_remove (wmOperatorType *ot)
Editmode Enter/Exit
void ED_curve_editfont_make (Object *obedit)
void ED_curve_editfont_load (Object *obedit)
void ED_curve_editfont_free (Object *obedit)
Toggle Case Operator
static wmOperatorStatus toggle_case_exec (bContext *C, wmOperator *)
void FONT_OT_case_toggle (wmOperatorType *ot)
static void font_ui_template_init (bContext *C, wmOperator *op)
static void font_open_cancel (bContext *, wmOperator *op)
static wmOperatorStatus font_open_exec (bContext *C, wmOperator *op)
static wmOperatorStatus open_invoke (bContext *C, wmOperator *op, const wmEvent *)
void FONT_OT_open (wmOperatorType *ot)

Set Style Operator

static const EnumPropertyItem style_items []
static wmOperatorStatus set_style (bContext *C, const int style, const bool clear)
static wmOperatorStatus set_style_exec (bContext *C, wmOperator *op)
void FONT_OT_style_set (wmOperatorType *ot)

Move Operator

static const EnumPropertyItem move_type_items []
static bool move_cursor_drop_select (Object *obedit, int dir)
static wmOperatorStatus move_cursor (bContext *C, int type, const bool select)
static wmOperatorStatus move_exec (bContext *C, wmOperator *op)
void FONT_OT_move (wmOperatorType *ot)

Delete Operator

static const EnumPropertyItem delete_type_items []
static wmOperatorStatus delete_exec (bContext *C, wmOperator *op)
void FONT_OT_delete (wmOperatorType *ot)
static wmOperatorStatus font_unlink_exec (bContext *C, wmOperator *op)
void FONT_OT_unlink (wmOperatorType *ot)
bool ED_curve_editfont_select_pick (bContext *C, const int mval[2], const SelectPick_Params &params)

Set Case Operator

static const EnumPropertyItem case_items []
static wmOperatorStatus set_case (bContext *C, int ccase)
static wmOperatorStatus set_case_exec (bContext *C, wmOperator *op)
void FONT_OT_case_set (wmOperatorType *ot)

Macro Definition Documentation

◆ MAXTEXT

Function Documentation

◆ change_character_exec()

◆ change_spacing_exec()

◆ copy_selection()

◆ copy_text_exec()

wmOperatorStatus copy_text_exec ( bContext * C,
wmOperator *  )
static

◆ cut_text_exec()

◆ delete_exec()

◆ ED_curve_editfont_free()

void ED_curve_editfont_free ( Object * obedit)

◆ ED_curve_editfont_load()

◆ ED_curve_editfont_make()

◆ ED_curve_editfont_select_pick()

◆ ED_text_to_object()

◆ findaccent()

char32_t findaccent ( char32_t char1,
const char code )
static

Definition at line 77 of file editfont.cc.

References findaccent().

Referenced by findaccent(), and insert_text_invoke().

◆ font_cursor_set_apply()

◆ font_cursor_text_index_from_event()

◆ font_open_cancel()

void font_open_cancel ( bContext * ,
wmOperator * op )
static

Definition at line 2448 of file editfont.cc.

References wmOperator::customdata, and font_open_cancel().

Referenced by font_open_cancel(), and FONT_OT_open().

◆ font_open_exec()

◆ FONT_OT_case_set()

◆ FONT_OT_case_toggle()

◆ FONT_OT_change_character()

◆ FONT_OT_change_spacing()

◆ FONT_OT_delete()

◆ FONT_OT_line_break()

◆ FONT_OT_move()

◆ FONT_OT_move_select()

◆ FONT_OT_open()

◆ FONT_OT_select_all()

◆ FONT_OT_select_word()

◆ FONT_OT_selection_set()

◆ FONT_OT_style_set()

◆ FONT_OT_style_toggle()

◆ FONT_OT_text_copy()

◆ FONT_OT_text_cut()

◆ FONT_OT_text_insert()

◆ FONT_OT_text_insert_unicode()

◆ FONT_OT_text_paste()

◆ FONT_OT_text_paste_from_file()

◆ FONT_OT_textbox_add()

◆ FONT_OT_textbox_remove()

◆ FONT_OT_unlink()

◆ font_paste_utf8()

bool font_paste_utf8 ( bContext * C,
const char * str,
const size_t str_len )
static

◆ font_paste_wchar()

bool font_paste_wchar ( Object * obedit,
const char32_t * str,
const size_t str_len,
const CharInfo * str_info )
static

◆ font_select_all_exec()

◆ font_select_to_buffer()

◆ font_select_update_primary_clipboard()

◆ font_select_word_exec()

◆ font_selection_set_invoke()

◆ font_selection_set_modal()

◆ font_ui_template_init()

◆ font_unlink_exec()

◆ insert_into_textbuf()

◆ insert_text_exec()

◆ insert_text_invoke()

◆ kill_selection()

◆ line_break_exec()

◆ move_cursor()

◆ move_cursor_drop_select()

bool move_cursor_drop_select ( Object * obedit,
int dir )
static

Implement standard behavior from GUI text editing fields (including Blender's UI) where horizontal motion drops the selection and places the cursor at the selection bounds (based on the motion direction) instead of moving the cursor.

Definition at line 1346 of file editfont.cc.

References BKE_vfont_select_get(), BLI_assert_unreachable, Object::data, Curve::editfont, move_cursor_drop_select(), and EditFont::pos.

Referenced by move_cursor(), and move_cursor_drop_select().

◆ move_exec()

wmOperatorStatus move_exec ( bContext * C,
wmOperator * op )
static

Definition at line 1502 of file editfont.cc.

References C, move_cursor(), move_exec(), wmOperator::ptr, and RNA_enum_get().

Referenced by FONT_OT_move(), and move_exec().

◆ move_select_exec()

wmOperatorStatus move_select_exec ( bContext * C,
wmOperator * op )
static

Definition at line 1533 of file editfont.cc.

References C, move_cursor(), move_select_exec(), wmOperator::ptr, and RNA_enum_get().

Referenced by FONT_OT_move_select(), and move_select_exec().

◆ open_invoke()

◆ paste_from_file()

◆ paste_from_file_exec()

◆ paste_from_file_invoke()

◆ paste_selection()

bool paste_selection ( Object * obedit,
ReportList * reports )
static

◆ paste_text_exec()

◆ set_case()

◆ set_case_exec()

wmOperatorStatus set_case_exec ( bContext * C,
wmOperator * op )
static

Definition at line 2371 of file editfont.cc.

References C, wmOperator::ptr, RNA_enum_get(), set_case(), and set_case_exec().

Referenced by FONT_OT_case_set(), and set_case_exec().

◆ set_style()

◆ set_style_exec()

wmOperatorStatus set_style_exec ( bContext * C,
wmOperator * op )
static

◆ text_insert_unicode_cancel()

void text_insert_unicode_cancel ( bContext * C,
void * arg_block,
void *  )
static

◆ text_insert_unicode_confirm()

void text_insert_unicode_confirm ( bContext * C,
void * arg_block,
void * arg_string )
static

◆ text_insert_unicode_invoke()

◆ text_update_edited()

◆ textbox_add_exec()

◆ textbox_remove_exec()

◆ toggle_case_exec()

◆ toggle_style_exec()

◆ txt_add_object()

◆ wm_block_insert_unicode_create()

Variable Documentation

◆ case_items

const EnumPropertyItem case_items[]
static
Initial value:
= {
{CASE_LOWER, "LOWER", 0, "Lower", ""},
{CASE_UPPER, "UPPER", 0, "Upper", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ CASE_LOWER
@ CASE_UPPER

Definition at line 2344 of file editfont.cc.

Referenced by FONT_OT_case_set().

◆ delete_type_items

const EnumPropertyItem delete_type_items[]
static
Initial value:
= {
{DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
{DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
{DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{DEL_SELECTION, "SELECTION", 0, "Selection", ""},
{DEL_NEXT_SEL, "NEXT_OR_SELECTION", 0, "Next or Selection", ""},
{DEL_PREV_SEL, "PREVIOUS_OR_SELECTION", 0, "Previous or Selection", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ DEL_SELECTION
@ DEL_PREV_WORD
@ DEL_PREV_SEL
@ DEL_PREV_CHAR
@ DEL_NEXT_WORD
@ DEL_NEXT_CHAR
@ DEL_NEXT_SEL

Definition at line 1730 of file editfont.cc.

Referenced by FONT_OT_delete(), and PARTICLE_OT_delete().

◆ move_type_items

const EnumPropertyItem move_type_items[]
static
Initial value:
= {
{LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
{LINE_END, "LINE_END", 0, "Line End", ""},
{TEXT_BEGIN, "TEXT_BEGIN", 0, "Text Begin", ""},
{TEXT_END, "TEXT_END", 0, "Text End", ""},
{PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
{NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
{PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
{PREV_LINE, "PREVIOUS_LINE", 0, "Previous Line", ""},
{NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
{PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
{NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
{0, nullptr, 0, nullptr, nullptr},
}
#define NEXT_CHAR(fmt)
@ NEXT_LINE
@ TEXT_BEGIN
@ TEXT_END
@ LINE_BEGIN
@ PREV_WORD
@ PREV_LINE
@ PREV_CHAR
@ LINE_END
@ PREV_PAGE
@ NEXT_PAGE
@ NEXT_WORD

Definition at line 1325 of file editfont.cc.

Referenced by FONT_OT_move(), and FONT_OT_move_select().

◆ style_items

const EnumPropertyItem style_items[]
static
Initial value:
= {
{CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""},
{CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""},
{CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""},
{CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ CU_CHINFO_UNDERLINE
@ CU_CHINFO_BOLD
@ CU_CHINFO_ITALIC
@ CU_CHINFO_SMALLCAPS

Definition at line 970 of file editfont.cc.

Referenced by FONT_OT_style_set(), and FONT_OT_style_toggle().