Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/curve/editfont.c')
-rw-r--r--source/blender/editors/curve/editfont.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index a9a8901acc6..7cdfafdad43 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -82,7 +82,7 @@ static int kill_selection(Object *obedit, int ins);
static char findaccent(char char1, unsigned int code)
{
char new = 0;
-
+
if (char1 == 'a') {
if (code == '`') new = 224;
else if (code == 39) new = 225;
@@ -214,7 +214,7 @@ static char findaccent(char char1, unsigned int code)
else if (char1 == '+') {
if (code == '-') new = 177;
}
-
+
if (new) return new;
else return char1;
}
@@ -223,7 +223,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
{
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
-
+
if (ef->len < MAXTEXT - 1) {
int x;
@@ -233,7 +233,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
ef->textbufinfo[ef->pos] = cu->curinfo;
ef->textbufinfo[ef->pos].kern = 0;
ef->textbufinfo[ef->pos].mat_nr = obedit->actcol;
-
+
ef->pos++;
ef->len++;
ef->textbuf[ef->len] = '\0';
@@ -378,7 +378,7 @@ static int paste_from_file_exec(bContext *C, wmOperator *op)
{
char *path;
int retval;
-
+
path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
retval = paste_from_file(C, op->reports, path);
MEM_freeN(path);
@@ -391,7 +391,7 @@ static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UN
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return paste_from_file_exec(C, op);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -402,12 +402,12 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
ot->name = "Paste File";
ot->description = "Paste contents from file";
ot->idname = "FONT_OT_text_paste_from_file";
-
+
/* api callbacks */
ot->exec = paste_from_file_exec;
ot->invoke = paste_from_file_invoke;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -433,7 +433,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
char *s;
int a;
float rot[3] = {0.f, 0.f, 0.f};
-
+
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
base = view_layer->basact;
@@ -506,12 +506,12 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
linenum++;
continue;
}
-
+
/* do the translation */
offset[0] = 0;
offset[1] = -linenum;
offset[2] = 0;
-
+
if (rv3d)
mul_mat3_m4_v3(rv3d->viewinv, offset);
@@ -607,11 +607,11 @@ void FONT_OT_style_set(wmOperatorType *ot)
ot->name = "Set Style";
ot->description = "Set font style";
ot->idname = "FONT_OT_style_set";
-
+
/* api callbacks */
ot->exec = set_style_exec;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -630,7 +630,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
return OPERATOR_CANCELLED;
-
+
style = RNA_enum_get(op->ptr, "style");
cu->curinfo.flag ^= style;
@@ -645,11 +645,11 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
ot->name = "Toggle Style";
ot->description = "Toggle font style";
ot->idname = "FONT_OT_style_toggle";
-
+
/* api callbacks */
ot->exec = toggle_style_exec;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -703,7 +703,7 @@ void FONT_OT_select_all(wmOperatorType *ot)
static void copy_selection(Object *obedit)
{
int selstart, selend;
-
+
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@@ -740,7 +740,7 @@ void FONT_OT_text_copy(wmOperatorType *ot)
ot->name = "Copy Text";
ot->description = "Copy selected text to clipboard";
ot->idname = "FONT_OT_text_copy";
-
+
/* api callbacks */
ot->exec = copy_text_exec;
ot->poll = ED_operator_editfont;
@@ -770,7 +770,7 @@ void FONT_OT_text_cut(wmOperatorType *ot)
ot->name = "Cut Text";
ot->description = "Cut selected text to clipboard";
ot->idname = "FONT_OT_text_cut";
-
+
/* api callbacks */
ot->exec = cut_text_exec;
ot->poll = ED_operator_editfont;
@@ -871,7 +871,7 @@ void FONT_OT_text_paste(wmOperatorType *ot)
ot->name = "Paste Text";
ot->description = "Paste text from clipboard";
ot->idname = "FONT_OT_text_paste";
-
+
/* api callbacks */
ot->exec = paste_text_exec;
ot->poll = ED_operator_editfont;
@@ -915,7 +915,7 @@ static int move_cursor(bContext *C, int type, const bool select)
}
cursmove = FO_CURS;
break;
-
+
case LINE_END:
while (ef->pos < ef->len) {
if (ef->textbuf[ef->pos] == 0) break;
@@ -958,7 +958,7 @@ static int move_cursor(bContext *C, int type, const bool select)
case PREV_LINE:
cursmove = FO_CURSUP;
break;
-
+
case NEXT_LINE:
cursmove = FO_CURSDOWN;
break;
@@ -971,7 +971,7 @@ static int move_cursor(bContext *C, int type, const bool select)
cursmove = FO_PAGEDOWN;
break;
}
-
+
if (cursmove == -1)
return OPERATOR_CANCELLED;
@@ -1016,7 +1016,7 @@ void FONT_OT_move(wmOperatorType *ot)
ot->name = "Move Cursor";
ot->description = "Move cursor to position type";
ot->idname = "FONT_OT_move";
-
+
/* api callbacks */
ot->exec = move_exec;
ot->poll = ED_operator_editfont;
@@ -1043,7 +1043,7 @@ void FONT_OT_move_select(wmOperatorType *ot)
ot->name = "Move Select";
ot->description = "Move the cursor while selecting";
ot->idname = "FONT_OT_move_select";
-
+
/* api callbacks */
ot->exec = move_select_exec;
ot->poll = ED_operator_editfont;
@@ -1084,7 +1084,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
ot->name = "Change Spacing";
ot->description = "Change font spacing";
ot->idname = "FONT_OT_change_spacing";
-
+
/* api callbacks */
ot->exec = change_spacing_exec;
ot->poll = ED_operator_editfont;
@@ -1128,7 +1128,7 @@ void FONT_OT_change_character(wmOperatorType *ot)
ot->name = "Change Character";
ot->description = "Change font character code";
ot->idname = "FONT_OT_change_character";
-
+
/* api callbacks */
ot->exec = change_character_exec;
ot->poll = ED_operator_editfont;
@@ -1163,7 +1163,7 @@ void FONT_OT_line_break(wmOperatorType *ot)
ot->name = "Line Break";
ot->description = "Insert line break at cursor position";
ot->idname = "FONT_OT_line_break";
-
+
/* api callbacks */
ot->exec = line_break_exec;
ot->poll = ED_operator_editfont;
@@ -1289,7 +1289,7 @@ void FONT_OT_delete(wmOperatorType *ot)
ot->name = "Delete";
ot->description = "Delete text by cursor position";
ot->idname = "FONT_OT_delete";
-
+
/* api callbacks */
ot->exec = delete_exec;
ot->poll = ED_operator_editfont;
@@ -1312,7 +1312,7 @@ static int insert_text_exec(bContext *C, wmOperator *op)
if (!RNA_struct_property_is_set(op->ptr, "text"))
return OPERATOR_CANCELLED;
-
+
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
len = BLI_strlen_utf8(inserted_utf8);
@@ -1350,7 +1350,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
accentcode = 1;
return OPERATOR_FINISHED;
}
-
+
/* tab should exit editmode, but we allow it to be typed using modifier keys */
if (event_type == TABKEY) {
if ((alt || ctrl || shift) == 0)
@@ -1358,7 +1358,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else
ascii = 9;
}
-
+
if (event_type == BACKSPACEKEY) {
if (alt && ef->len != 0 && ef->pos > 0)
accentcode = 1;
@@ -1394,7 +1394,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else {
BLI_assert(0);
}
-
+
kill_selection(obedit, 1);
text_update_edited(C, obedit, FO_EDIT);
}
@@ -1418,7 +1418,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* reset property? */
if (event_val == 0)
accentcode = 0;
-
+
return OPERATOR_FINISHED;
}
@@ -1428,12 +1428,12 @@ void FONT_OT_text_insert(wmOperatorType *ot)
ot->name = "Insert Text";
ot->description = "Insert text at cursor position";
ot->idname = "FONT_OT_text_insert";
-
+
/* api callbacks */
ot->exec = insert_text_exec;
ot->invoke = insert_text_invoke;
ot->poll = ED_operator_editfont;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1449,14 +1449,14 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_active_object(C);
Curve *cu = obedit->data;
int i;
-
+
if (cu->totbox < 256) {
for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1];
cu->tb[cu->actbox] = cu->tb[cu->actbox - 1];
cu->actbox++;
cu->totbox++;
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1467,15 +1467,15 @@ void FONT_OT_textbox_add(wmOperatorType *ot)
ot->name = "Add Textbox";
ot->description = "Add a new text box";
ot->idname = "FONT_OT_textbox_add";
-
+
/* api callbacks */
ot->exec = textbox_add_exec;
ot->poll = ED_operator_object_active_editable_font;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-
+
+
}
@@ -1490,17 +1490,17 @@ static int textbox_remove_exec(bContext *C, wmOperator *op)
Curve *cu = obedit->data;
int i;
int index = RNA_int_get(op->ptr, "index");
-
-
+
+
if (cu->totbox > 1) {
for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1];
cu->totbox--;
if (cu->actbox >= index)
cu->actbox--;
}
-
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
+
return OPERATOR_FINISHED;
}
@@ -1510,14 +1510,14 @@ void FONT_OT_textbox_remove(wmOperatorType *ot)
ot->name = "Remove Textbox";
ot->description = "Remove the textbox";
ot->idname = "FONT_OT_textbox_remove";
-
+
/* api callbacks */
ot->exec = textbox_remove_exec;
ot->poll = ED_operator_object_active_editable_font;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX);
}
@@ -1530,14 +1530,14 @@ void ED_curve_editfont_make(Object *obedit)
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
int len_wchar;
-
+
if (ef == NULL) {
ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont");
-
+
ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf");
ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo");
}
-
+
/* Convert the original text to wchar_t */
len_wchar = BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4);
BLI_assert(len_wchar == cu->len_wchar);
@@ -1576,7 +1576,7 @@ void ED_curve_editfont_load(Object *obedit)
/* Copy the wchar to UTF-8 */
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1);
-
+
if (cu->strinfo)
MEM_freeN(cu->strinfo);
cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo");
@@ -1608,7 +1608,7 @@ static int set_case(bContext *C, int ccase)
wchar_t *str;
int len;
int selstart, selend;
-
+
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
len = (selend - selstart) + 1;
str = &ef->textbuf[selstart];
@@ -1648,7 +1648,7 @@ void FONT_OT_case_set(wmOperatorType *ot)
ot->name = "Set Case";
ot->description = "Set font case";
ot->idname = "FONT_OT_case_set";
-
+
/* api callbacks */
ot->exec = set_case_exec;
ot->poll = ED_operator_editfont;
@@ -1669,7 +1669,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
EditFont *ef = cu->editfont;
wchar_t *str;
int len, ccase = CASE_UPPER;
-
+
len = wcslen(ef->textbuf);
str = ef->textbuf;
while (len) {
@@ -1681,7 +1681,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
len--;
str++;
}
-
+
return set_case(C, ccase);
}
@@ -1691,7 +1691,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot)
ot->name = "Toggle Case";
ot->description = "Toggle font case";
ot->idname = "FONT_OT_case_toggle";
-
+
/* api callbacks */
ot->exec = toggle_case_exec;
ot->poll = ED_operator_editfont;
@@ -1705,7 +1705,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot)
static void font_ui_template_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
-
+
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
}
@@ -1734,7 +1734,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
if (!op->customdata)
font_ui_template_init(C, op);
-
+
/* hook into UI */
pprop = op->customdata;
@@ -1742,7 +1742,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
/* when creating new ID blocks, use is already 1, but RNA
* pointer use also increases user, so this compensates it */
id_us_min(&font->id);
-
+
RNA_id_pointer_create(&font->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
@@ -1777,7 +1777,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
return font_open_exec(C, op);
RNA_string_set(op->ptr, "filepath", path);
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -1788,15 +1788,15 @@ void FONT_OT_open(wmOperatorType *ot)
ot->name = "Open Font";
ot->idname = "FONT_OT_open";
ot->description = "Load a new font from a file";
-
+
/* api callbacks */
ot->exec = font_open_exec;
ot->invoke = open_invoke;
ot->cancel = font_open_cancel;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
WM_operator_properties_filesel(
ot, FILE_TYPE_FOLDER | FILE_TYPE_FTFONT, FILE_SPECIAL, FILE_OPENFILE,
@@ -1813,7 +1813,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
PropertyPointerRNA pprop;
UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop);
-
+
if (pprop.prop == NULL) {
BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
return OPERATOR_CANCELLED;
@@ -1834,7 +1834,7 @@ void FONT_OT_unlink(wmOperatorType *ot)
ot->name = "Unlink";
ot->idname = "FONT_OT_unlink";
ot->description = "Unlink active font data-block";
-
+
/* api callbacks */
ot->exec = font_unlink_exec;
}