WIP: VFONT: Text Object Word Selection #107519
@ -1202,8 +1202,10 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
|
||||
case PREV_WORD: {
|
||||
int pos = ef->pos;
|
||||
/* Only use_init_step if there is space to the left. */
|
||||
bool space_left = pos > 0 && ELEM(ef->textbuf[pos - 1], ' ', '\n', '\t');
|
||||
BLI_str_cursor_step_utf32(
|
||||
ef->textbuf, ef->len, &pos, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM, true);
|
||||
ef->textbuf, ef->len, &pos, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM, space_left);
|
||||
ef->pos = pos;
|
||||
cursmove = FO_CURS;
|
||||
break;
|
||||
@ -1211,8 +1213,10 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
|
||||
case NEXT_WORD: {
|
||||
int pos = ef->pos;
|
||||
/* Only use_init_step if there is space to the right. */
|
||||
bool space_right = ELEM(ef->textbuf[pos], ' ', '\n', '\t');
|
||||
BLI_str_cursor_step_utf32(
|
||||
ef->textbuf, ef->len, &pos, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM, true);
|
||||
ef->textbuf, ef->len, &pos, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM, space_right);
|
||||
ef->pos = pos;
|
||||
cursmove = FO_CURS;
|
||||
break;
|
||||
@ -1921,9 +1925,18 @@ void FONT_OT_selection_set(struct wmOperatorType *ot)
|
||||
|
||||
static int font_select_word_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
move_cursor(C, NEXT_CHAR, false);
|
||||
move_cursor(C, PREV_WORD, false);
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Curve *cu = obedit->data;
|
||||
EditFont *ef = cu->editfont;
|
||||
|
||||
if (ef->pos > 0 && !ELEM(ef->textbuf[ef->pos - 1], ' ', '\n', '\t')) {
|
||||
/* We are at the end or middle of a word, so move back. */
|
||||
move_cursor(C, PREV_WORD, false);
|
||||
}
|
||||
|
||||
move_cursor(C, NEXT_WORD, true);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user