Blender V4.3
editfont.cc File Reference
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <cwchar>
#include <fcntl.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.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_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, CharInfo *str_info)
 
static bool font_paste_utf8 (bContext *C, const char *str, const size_t str_len)
 
Paste From File Operator
static int paste_from_file (bContext *C, ReportList *reports, const char *filepath)
 
static int paste_from_file_exec (bContext *C, wmOperator *op)
 
static int 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 int 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 int toggle_style_exec (bContext *C, wmOperator *op)
 
void FONT_OT_style_toggle (wmOperatorType *ot)
 
Select All Operator
static int font_select_all_exec (bContext *C, wmOperator *)
 
void FONT_OT_select_all (wmOperatorType *ot)
 
Copy Text Operator
static void copy_selection (Object *obedit)
 
static int copy_text_exec (bContext *C, wmOperator *)
 
void FONT_OT_text_copy (wmOperatorType *ot)
 
Cut Text Operator
static int 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 int paste_text_exec (bContext *C, wmOperator *op)
 
void FONT_OT_text_paste (wmOperatorType *ot)
 
Move Select Operator
static int move_select_exec (bContext *C, wmOperator *op)
 
void FONT_OT_move_select (wmOperatorType *ot)
 
Change Spacing
static int change_spacing_exec (bContext *C, wmOperator *op)
 
void FONT_OT_change_spacing (wmOperatorType *ot)
 
Change Character
static int change_character_exec (bContext *C, wmOperator *op)
 
void FONT_OT_change_character (wmOperatorType *ot)
 
Line Break Operator
static int line_break_exec (bContext *C, wmOperator *)
 
void FONT_OT_line_break (wmOperatorType *ot)
 
Insert Text Operator
static int insert_text_exec (bContext *C, wmOperator *op)
 
static int 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 int font_selection_set_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int font_selection_set_modal (bContext *C, wmOperator *, const wmEvent *event)
 
void FONT_OT_selection_set (wmOperatorType *ot)
 
Select Word Operator
static int font_select_word_exec (bContext *C, wmOperator *)
 
void FONT_OT_select_word (wmOperatorType *ot)
 
Text-Box Add Operator
static int textbox_add_exec (bContext *C, wmOperator *)
 
void FONT_OT_textbox_add (wmOperatorType *ot)
 
Text-Box Remove Operator
static int 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 int 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 int font_open_exec (bContext *C, wmOperator *op)
 
static int open_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
void FONT_OT_open (wmOperatorType *ot)
 

Set Style Operator

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

Move Operator

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

Delete Operator

static const EnumPropertyItem delete_type_items []
 
static int delete_exec (bContext *C, wmOperator *op)
 
void FONT_OT_delete (wmOperatorType *ot)
 
static int 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 int set_case (bContext *C, int ccase)
 
static int 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()

static int copy_text_exec ( bContext * C,
wmOperator *  )
static

Definition at line 1100 of file editfont.cc.

References copy_selection(), CTX_data_edit_object(), and OPERATOR_FINISHED.

Referenced by FONT_OT_text_copy().

◆ cut_text_exec()

◆ delete_exec()

◆ ED_curve_editfont_free()

void ED_curve_editfont_free ( Object * obedit)

Definition at line 2262 of file editfont.cc.

References BKE_curve_editfont_free(), and Object::data.

Referenced by blender::ed::object::editmode_load_free_ex().

◆ ED_curve_editfont_load()

◆ ED_curve_editfont_make()

◆ ED_curve_editfont_select_pick()

◆ ED_text_to_object()

◆ findaccent()

static char32_t findaccent ( char32_t char1,
const char code )
static

Definition at line 72 of file editfont.cc.

Referenced by insert_text_invoke().

◆ font_cursor_set_apply()

◆ font_cursor_text_index_from_event()

static int font_cursor_text_index_from_event ( bContext * C,
Object * obedit,
const wmEvent * event )
static

◆ font_open_cancel()

static void font_open_cancel ( bContext * ,
wmOperator * op )
static

Definition at line 2379 of file editfont.cc.

References wmOperator::customdata, and MEM_freeN().

Referenced by 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()

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

◆ font_paste_wchar()

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

◆ font_select_all_exec()

◆ font_select_to_buffer()

static char * font_select_to_buffer ( Object * obedit)
static

◆ font_select_update_primary_clipboard()

static void font_select_update_primary_clipboard ( Object * obedit)
static

◆ font_select_word_exec()

◆ font_selection_set_invoke()

static int font_selection_set_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

◆ font_selection_set_modal()

static int font_selection_set_modal ( bContext * C,
wmOperator * ,
const wmEvent * event )
static

◆ font_ui_template_init()

static void font_ui_template_init ( bContext * C,
wmOperator * op )
static

◆ font_unlink_exec()

◆ insert_into_textbuf()

◆ insert_text_exec()

◆ insert_text_invoke()

◆ kill_selection()

◆ line_break_exec()

◆ move_cursor()

◆ move_exec()

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

Definition at line 1431 of file editfont.cc.

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

Referenced by FONT_OT_move().

◆ move_select_exec()

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

Definition at line 1462 of file editfont.cc.

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

Referenced by FONT_OT_move_select().

◆ open_invoke()

◆ paste_from_file()

static int paste_from_file ( bContext * C,
ReportList * reports,
const char * filepath )
static

◆ paste_from_file_exec()

static int paste_from_file_exec ( bContext * C,
wmOperator * op )
static

◆ paste_from_file_invoke()

static int paste_from_file_invoke ( bContext * C,
wmOperator * op,
const wmEvent *  )
static

◆ paste_selection()

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

Definition at line 1165 of file editfont.cc.

References BKE_report(), BKE_vfont_clipboard_get(), font_paste_wchar(), len, and RPT_WARNING.

Referenced by paste_text_exec().

◆ paste_text_exec()

◆ set_case()

◆ set_case_exec()

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

Definition at line 2300 of file editfont.cc.

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

Referenced by FONT_OT_case_set().

◆ set_style()

◆ set_style_exec()

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

Definition at line 960 of file editfont.cc.

References clear(), wmOperator::ptr, RNA_boolean_get(), RNA_enum_get(), and set_style().

Referenced by FONT_OT_style_set().

◆ text_insert_unicode_cancel()

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

Definition at line 657 of file editfont.cc.

References CTX_wm_window(), and UI_popup_block_close().

Referenced by wm_block_insert_unicode_create().

◆ text_insert_unicode_confirm()

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

◆ text_insert_unicode_invoke()

static int text_insert_unicode_invoke ( bContext * C,
wmOperator * ,
const wmEvent *  )
static

◆ text_update_edited()

◆ textbox_add_exec()

◆ textbox_remove_exec()

◆ toggle_case_exec()

static int toggle_case_exec ( bContext * C,
wmOperator *  )
static

◆ 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 2273 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 1659 of file editfont.cc.

Referenced by FONT_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 1280 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 926 of file editfont.cc.

Referenced by FONT_OT_style_set(), and FONT_OT_style_toggle().