Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editfont.c
| Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | if (obedit->actcol < 1) { | ||||
| obedit->actcol = 1; | obedit->actcol = 1; | ||||
| } | } | ||||
| } | } | ||||
| DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); | DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); | ||||
| WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); | WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); | ||||
| } | } | ||||
| static int kill_selection(Object *obedit, int ins) /* 1 == new character */ | static int kill_selection(Object *obedit, int ins) /* ins == new character len */ | ||||
| { | { | ||||
| Curve *cu = obedit->data; | Curve *cu = obedit->data; | ||||
| EditFont *ef = cu->editfont; | EditFont *ef = cu->editfont; | ||||
| int selend, selstart, direction; | int selend, selstart, direction; | ||||
| int offset = 0; | |||||
| int getfrom; | int getfrom; | ||||
| direction = BKE_vfont_select_get(obedit, &selstart, &selend); | direction = BKE_vfont_select_get(obedit, &selstart, &selend); | ||||
| if (direction) { | if (direction) { | ||||
| int size; | int size; | ||||
| if (ins) { | |||||
| offset = 1; | |||||
| } | |||||
| if (ef->pos >= selstart) { | if (ef->pos >= selstart) { | ||||
| ef->pos = selstart + offset; | ef->pos = selstart + ins; | ||||
| } | } | ||||
| if ((direction == -1) && ins) { | if ((direction == -1) && ins) { | ||||
| selstart++; | selstart += ins; | ||||
| selend++; | selend += ins; | ||||
| } | } | ||||
| getfrom = selend + offset; | getfrom = selend + 1; | ||||
| if (ins == 0) { | size = ef->len - selend; /* This is equivalent to: `(ef->len - getfrom) + 1(null)`. */ | ||||
| getfrom++; | memmove(ef->textbuf + selstart, ef->textbuf + getfrom, sizeof(*ef->textbuf) * size); | ||||
| } | memmove(ef->textbufinfo + selstart, ef->textbufinfo + getfrom, sizeof(CharInfo) * size); | ||||
| size = (ef->len * sizeof(*ef->textbuf)) - (selstart * sizeof(*ef->textbuf)) + | |||||
| (offset * sizeof(*ef->textbuf)); | |||||
| 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->len -= ((selend - selstart) + 1); | ||||
| ef->selstart = ef->selend = 0; | ef->selstart = ef->selend = 0; | ||||
| } | } | ||||
| return direction; | return direction; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 1,164 Lines • ▼ Show 20 Lines | static int insert_text_exec(bContext *C, wmOperator *op) | ||||
| for (a = 0; a < len; a++) { | for (a = 0; a < len; a++) { | ||||
| insert_into_textbuf(obedit, inserted_text[a]); | insert_into_textbuf(obedit, inserted_text[a]); | ||||
| } | } | ||||
| MEM_freeN(inserted_text); | MEM_freeN(inserted_text); | ||||
| MEM_freeN(inserted_utf8); | MEM_freeN(inserted_utf8); | ||||
| kill_selection(obedit, 1); | kill_selection(obedit, len); | ||||
| text_update_edited(C, obedit, FO_EDIT); | text_update_edited(C, obedit, FO_EDIT); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| ▲ Show 20 Lines • Show All 629 Lines • Show Last 20 Lines | |||||