Cleanup: use doxy sections for editfont

This commit is contained in:
Campbell Barton 2019-08-24 12:04:43 +10:00
parent dc434bc273
commit fd43854fa3
1 changed files with 151 additions and 61 deletions

View File

@ -71,7 +71,11 @@
static int kill_selection(Object *obedit, int ins);
/************************* utilities ******************************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Internal Utilities
* \{ */
static wchar_t findaccent(wchar_t char1, unsigned int code)
{
@ -440,8 +444,48 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
static int kill_selection(Object *obedit, int ins) /* 1 == new character */
{
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
int selend, selstart, direction;
int offset = 0;
int getfrom;
direction = BKE_vfont_select_get(obedit, &selstart, &selend);
if (direction) {
int size;
if (ins) {
offset = 1;
}
if (ef->pos >= selstart) {
ef->pos = selstart + offset;
}
if ((direction == -1) && ins) {
selstart++;
selend++;
}
getfrom = selend + offset;
if (ins == 0) {
getfrom++;
}
size = (ef->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t));
memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size);
memmove(ef->textbufinfo + selstart,
ef->textbufinfo + getfrom,
((ef->len - selstart) + offset) * sizeof(CharInfo));
ef->len -= ((selend - selstart) + 1);
ef->selstart = ef->selend = 0;
}
return (direction);
}
/** \} */
/* -------------------------------------------------------------------- */
/* Generic Paste Functions */
/** \name Generic Paste Functions
* \{ */
/* text_update_edited(C, scene, obedit, 1, FO_EDIT); */
static bool font_paste_wchar(Object *obedit,
@ -506,8 +550,11 @@ static bool font_paste_utf8(bContext *C, const char *str, const size_t str_len)
return retval;
}
/** \} */
/* -------------------------------------------------------------------- */
/* Paste From File*/
/** \name Paste From File Operator
* \{ */
static int paste_from_file(bContext *C, ReportList *reports, const char *filename)
{
@ -585,7 +632,11 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
FILE_SORT_ALPHA);
}
/******************* text to object operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Text To Object
* \{ */
static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
{
@ -703,46 +754,11 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
}
}
/********************** utilities ***************************/
/** \} */
static int kill_selection(Object *obedit, int ins) /* 1 == new character */
{
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
int selend, selstart, direction;
int offset = 0;
int getfrom;
direction = BKE_vfont_select_get(obedit, &selstart, &selend);
if (direction) {
int size;
if (ins) {
offset = 1;
}
if (ef->pos >= selstart) {
ef->pos = selstart + offset;
}
if ((direction == -1) && ins) {
selstart++;
selend++;
}
getfrom = selend + offset;
if (ins == 0) {
getfrom++;
}
size = (ef->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t));
memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size);
memmove(ef->textbufinfo + selstart,
ef->textbufinfo + getfrom,
((ef->len - selstart) + offset) * sizeof(CharInfo));
ef->len -= ((selend - selstart) + 1);
ef->selstart = ef->selend = 0;
}
return (direction);
}
/******************* set style operator ********************/
/* -------------------------------------------------------------------- */
/** \name Set Style Operator
* \{ */
static const EnumPropertyItem style_items[] = {
{CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""},
@ -806,7 +822,11 @@ void FONT_OT_style_set(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear style rather than setting it");
}
/******************* toggle style operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Toggle Style Operator
* \{ */
static int toggle_style_exec(bContext *C, wmOperator *op)
{
@ -845,8 +865,11 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to");
}
/** \} */
/* -------------------------------------------------------------------- */
/* Select All */
/** \name Select All Operator
* \{ */
static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
{
@ -883,7 +906,11 @@ void FONT_OT_select_all(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******************* copy text operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Copy Text Operator
* \{ */
static void copy_selection(Object *obedit)
{
@ -932,7 +959,11 @@ void FONT_OT_text_copy(wmOperatorType *ot)
ot->poll = ED_operator_editfont;
}
/******************* cut text operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Cut Text Operator
* \{ */
static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
{
@ -966,7 +997,11 @@ void FONT_OT_text_cut(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******************* paste text operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Paste Text Operator
* \{ */
static bool paste_selection(Object *obedit, ReportList *reports)
{
@ -1066,7 +1101,11 @@ void FONT_OT_text_paste(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/************************ move operator ************************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Move Operator
* \{ */
static const EnumPropertyItem move_type_items[] = {
{LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
@ -1232,7 +1271,11 @@ void FONT_OT_move(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
}
/******************* move select operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Move Select Operator
* \{ */
static int move_select_exec(bContext *C, wmOperator *op)
{
@ -1264,7 +1307,11 @@ void FONT_OT_move_select(wmOperatorType *ot)
"Where to move cursor to, to make a selection");
}
/************************* change spacing **********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Change Spacing
* \{ */
static int change_spacing_exec(bContext *C, wmOperator *op)
{
@ -1314,7 +1361,11 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
20);
}
/************************* change character **********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Change Character
* \{ */
static int change_character_exec(bContext *C, wmOperator *op)
{
@ -1368,7 +1419,11 @@ void FONT_OT_change_character(wmOperatorType *ot)
255);
}
/******************* line break operator ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Line Break Operator
* \{ */
static int line_break_exec(bContext *C, wmOperator *UNUSED(op))
{
@ -1400,7 +1455,11 @@ void FONT_OT_line_break(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******************* delete operator **********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Delete Operator
* \{ */
static const EnumPropertyItem delete_type_items[] = {
{DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
@ -1549,7 +1608,11 @@ void FONT_OT_delete(wmOperatorType *ot)
"Which part of the text to delete");
}
/*********************** insert text operator *************************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Insert Text Operator
* \{ */
static int insert_text_exec(bContext *C, wmOperator *op)
{
@ -1700,7 +1763,12 @@ void FONT_OT_text_insert(wmOperatorType *ot)
"Next typed character will strike through previous, for special character input");
}
/*********************** textbox add operator *************************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Textbox Add Operator
* \{ */
static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit = CTX_data_active_object(C);
@ -1736,7 +1804,11 @@ void FONT_OT_textbox_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/*********************** textbox remove operator *************************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Textbox Remove Operator
* \{ */
static int textbox_remove_exec(bContext *C, wmOperator *op)
{
@ -1778,7 +1850,11 @@ void FONT_OT_textbox_remove(wmOperatorType *ot)
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX);
}
/***************** editmode enter/exit ********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Editmode Enter/Exit
* \{ */
void ED_curve_editfont_make(Object *obedit)
{
@ -1851,7 +1927,11 @@ void ED_curve_editfont_free(Object *obedit)
BKE_curve_editfont_free((Curve *)obedit->data);
}
/********************** set case operator *********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Set Case Operator
* \{ */
static const EnumPropertyItem case_items[] = {
{CASE_LOWER, "LOWER", 0, "Lower", ""},
@ -1920,7 +2000,11 @@ void FONT_OT_case_set(wmOperatorType *ot)
RNA_def_enum(ot->srna, "case", case_items, CASE_LOWER, "Case", "Lower or upper case");
}
/********************** toggle case operator *********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Toggle Case Operator
* \{ */
static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
{
@ -2071,7 +2155,11 @@ void FONT_OT_open(wmOperatorType *ot)
FILE_SORT_ALPHA);
}
/******************* delete operator *********************/
/** \} */
/* -------------------------------------------------------------------- */
/** \name Delete Operator
* \{ */
static int font_unlink_exec(bContext *C, wmOperator *op)
{
@ -2190,3 +2278,5 @@ bool ED_curve_editfont_select_pick(
return false;
}
}
/** \} */