diff --git a/scripts/presets/keyconfig/keymap_data/blender_default.py b/scripts/presets/keyconfig/keymap_data/blender_default.py index 8382f686c5b..c6537818f8e 100644 --- a/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5562,60 +5562,68 @@ def km_font(params): ("font.move", {"type": 'HOME', "value": 'PRESS'}, {"properties": [("type", 'LINE_BEGIN')]}), ("font.move", {"type": 'END', "value": 'PRESS'}, {"properties": [("type", 'LINE_END')]}), ("font.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_CHARACTER')]}), ("font.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_CHARACTER')]}), ("font.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_WORD')]}), ("font.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True, "repeat": True}, {"properties": [("type", 'NEXT_WORD')]}), ("font.move", {"type": 'UP_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_LINE')]}), ("font.move", {"type": 'DOWN_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_LINE')]}), ("font.move", {"type": 'PAGE_UP', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_PAGE')]}), ("font.move", {"type": 'PAGE_DOWN', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_PAGE')]}), + ("font.move", {"type": 'HOME', "value": 'PRESS', "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_BEGIN')]}), + ("font.move", {"type": 'END', "value": 'PRESS', "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_END')]}), ("font.move_select", {"type": 'HOME', "value": 'PRESS', "shift": True}, {"properties": [("type", 'LINE_BEGIN')]}), ("font.move_select", {"type": 'END', "value": 'PRESS', "shift": True}, {"properties": [("type", 'LINE_END')]}), ("font.move_select", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_CHARACTER')]}), ("font.move_select", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_CHARACTER')]}), ("font.move_select", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_WORD')]}), ("font.move_select", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, {"properties": [("type", 'NEXT_WORD')]}), ("font.move_select", {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_LINE')]}), ("font.move_select", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_LINE')]}), ("font.move_select", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_PAGE')]}), ("font.move_select", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_PAGE')]}), + ("font.move_select", {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_BEGIN')]}), + ("font.move_select", {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_END')]}), ("font.change_spacing", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", -1)]}), ("font.change_spacing", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", 1)]}), ("font.change_character", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", 1)]}), ("font.change_character", {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", -1)]}), ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True, "repeat": True}, None), ("font.line_break", {"type": 'RET', "value": 'PRESS', "repeat": True}, None), ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True, "repeat": True}, None), ("font.text_insert", {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("accent", True)]}), *_template_items_context_menu("VIEW3D_MT_edit_font_context_menu", params.context_menu_event), ]) return keymap diff --git a/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index f141566e7cc..e6fabb886a9 100644 --- a/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -3758,60 +3758,68 @@ def km_font(params): ("font.move", {"type": 'HOME', "value": 'PRESS'}, {"properties": [("type", 'LINE_BEGIN')]}), ("font.move", {"type": 'END', "value": 'PRESS'}, {"properties": [("type", 'LINE_END')]}), ("font.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_CHARACTER')]}), ("font.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_CHARACTER')]}), ("font.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_WORD')]}), ("font.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True, "repeat": True}, {"properties": [("type", 'NEXT_WORD')]}), ("font.move", {"type": 'UP_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_LINE')]}), ("font.move", {"type": 'DOWN_ARROW', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_LINE')]}), ("font.move", {"type": 'PAGE_UP', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'PREVIOUS_PAGE')]}), ("font.move", {"type": 'PAGE_DOWN', "value": 'PRESS', "repeat": True}, {"properties": [("type", 'NEXT_PAGE')]}), + ("font.move", {"type": 'HOME', "value": 'PRESS', "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_BEGIN')]}), + ("font.move", {"type": 'END', "value": 'PRESS', "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_END')]}), ("font.move_select", {"type": 'HOME', "value": 'PRESS', "shift": True}, {"properties": [("type", 'LINE_BEGIN')]}), ("font.move_select", {"type": 'END', "value": 'PRESS', "shift": True}, {"properties": [("type", 'LINE_END')]}), ("font.move_select", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_CHARACTER')]}), ("font.move_select", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_CHARACTER')]}), ("font.move_select", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_WORD')]}), ("font.move_select", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, {"properties": [("type", 'NEXT_WORD')]}), ("font.move_select", {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_LINE')]}), ("font.move_select", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_LINE')]}), ("font.move_select", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'PREVIOUS_PAGE')]}), ("font.move_select", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True, "repeat": True}, {"properties": [("type", 'NEXT_PAGE')]}), + ("font.move_select", {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_BEGIN')]}), + ("font.move_select", {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True, "repeat": True}, + {"properties": [("type", 'TEXT_END')]}), ("font.change_spacing", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", -1)]}), ("font.change_spacing", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", 1)]}), ("font.change_character", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", 1)]}), ("font.change_character", {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True, "repeat": True}, {"properties": [("delta", -1)]}), ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True, "repeat": True}, None), ("font.line_break", {"type": 'RET', "value": 'PRESS'}, None), ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), ("font.text_insert", {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, {"properties": [("accent", True)]}), *_template_items_context_menu("VIEW3D_MT_edit_font_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), ]) return keymap diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 461788215e3..37fdfd3123e 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -1787,40 +1787,45 @@ class VIEW3D_MT_select_edit_surface(Menu): layout.separator() layout.operator("curve.select_row") layout.separator() layout.operator("curve.select_more") layout.operator("curve.select_less") class VIEW3D_MT_select_edit_text(Menu): bl_label = "Select" def draw(self, _context): layout = self.layout layout.operator("font.select_all", text="All") layout.separator() + layout.operator("font.move_select", text="Top").type = 'TEXT_BEGIN' + layout.operator("font.move_select", text="Bottom").type = 'TEXT_END' + + layout.separator() + layout.operator("font.move_select", text="Previous Block").type = 'PREVIOUS_PAGE' layout.operator("font.move_select", text="Next Block").type = 'NEXT_PAGE' layout.separator() layout.operator("font.move_select", text="Line Begin").type = 'LINE_BEGIN' layout.operator("font.move_select", text="Line End").type = 'LINE_END' layout.separator() layout.operator("font.move_select", text="Previous Line").type = 'PREVIOUS_LINE' layout.operator("font.move_select", text="Next Line").type = 'NEXT_LINE' layout.separator() layout.operator("font.move_select", text="Previous Word").type = 'PREVIOUS_WORD' layout.operator("font.move_select", text="Next Word").type = 'NEXT_WORD' class VIEW3D_MT_select_edit_metaball(Menu): diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c index b6f9a23a3cd..4f17d5e3dea 100644 --- a/source/blender/blenkernel/intern/vfont.c +++ b/source/blender/blenkernel/intern/vfont.c @@ -1416,64 +1416,72 @@ static bool vfont_to_curve(Object *ob, if (selboxes && (i >= selstart) && (i <= selend)) { EditFontSelBox *sb; sb = &selboxes[i - selstart]; sb->rot = -ct->rot; } } } } if (selboxes) { ct = chartransdata; for (i = 0; i <= selend; i++, ct++) { if (i >= selstart) { selboxes[i - selstart].x = ct->xof * font_size; selboxes[i - selstart].y = (ct->yof - 0.25f) * font_size; selboxes[i - selstart].h = font_size; } } } - if (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN) && + if (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN, FO_TEXTBEGIN, FO_TEXTEND) && iter_data->status == VFONT_TO_CURVE_INIT) { ct = &chartransdata[ef->pos]; + const int last_line = lnr; + if (ELEM(mode, FO_CURSUP, FO_PAGEUP) && ct->linenr == 0) { /* pass */ } - else if (ELEM(mode, FO_CURSDOWN, FO_PAGEDOWN) && ct->linenr == lnr) { + else if (ELEM(mode, FO_CURSDOWN, FO_PAGEDOWN) && ct->linenr == last_line) { /* pass */ } else { switch (mode) { case FO_CURSUP: lnr = ct->linenr - 1; break; case FO_CURSDOWN: lnr = ct->linenr + 1; break; case FO_PAGEUP: lnr = ct->linenr - 10; break; case FO_PAGEDOWN: lnr = ct->linenr + 10; break; + case FO_TEXTBEGIN: + lnr = 0; + break; + case FO_TEXTEND: + lnr = last_line; + break; } cnr = ct->charnr; /* Seek for char with `lnr` & `cnr`. */ ef->pos = 0; ct = chartransdata; for (i = 0; i < slen; i++) { if (ct->linenr == lnr) { if ((ct->charnr == cnr) || ((ct + 1)->charnr == 0)) { break; } } else if (ct->linenr > lnr) { break; } ef->pos++; ct++; } } } diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index 61a18dbd3e3..66404718bba 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -24,41 +24,43 @@ extern "C" { enum { DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; enum { CASE_LOWER, CASE_UPPER }; enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD, PREV_LINE, NEXT_LINE, PREV_PAGE, - NEXT_PAGE + NEXT_PAGE, + TEXT_BEGIN, + TEXT_END }; typedef enum eVisible_Types { HIDDEN = true, VISIBLE = false, } eVisible_Types; typedef enum eEndPoint_Types { FIRST = true, LAST = false, } eEndPoint_Types; typedef enum eCurveElem_Types { CURVE_VERTEX = 0, CURVE_SEGMENT, } eCurveElem_Types; /* internal select utils */ /** * Returns 1 in case (de)selection was successful. diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index f96bb85d53e..b09c20d4d09 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1127,40 +1127,42 @@ void FONT_OT_text_paste(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ /* -------------------------------------------------------------------- */ /** \name Move Operator * \{ */ static const EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line 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", ""}, + {TEXT_BEGIN, "TEXT_BEGIN", 0, "Text Top", ""}, + {TEXT_END, "TEXT_END", 0, "Text Bottom", ""}, {0, NULL, 0, NULL, NULL}, }; static int move_cursor(bContext *C, int type, const bool select) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obedit = CTX_data_edit_object(C); Curve *cu = obedit->data; EditFont *ef = cu->editfont; int cursmove = -1; if ((select) && (ef->selstart == 0)) { ef->selstart = ef->selend = ef->pos + 1; } switch (type) { case LINE_BEGIN: while (ef->pos > 0) { if (ef->textbuf[ef->pos - 1] == '\n') { break; @@ -1208,40 +1210,48 @@ static int move_cursor(bContext *C, int type, const bool select) } case PREV_CHAR: BLI_str_cursor_step_prev_utf32(ef->textbuf, ef->len, &ef->pos); cursmove = FO_CURS; break; case NEXT_CHAR: BLI_str_cursor_step_next_utf32(ef->textbuf, ef->len, &ef->pos); cursmove = FO_CURS; break; case PREV_LINE: cursmove = FO_CURSUP; break; case NEXT_LINE: cursmove = FO_CURSDOWN; break; + case TEXT_BEGIN: + cursmove = FO_TEXTBEGIN; + break; + + case TEXT_END: + cursmove = FO_TEXTEND; + break; + case PREV_PAGE: cursmove = FO_PAGEUP; break; case NEXT_PAGE: cursmove = FO_PAGEDOWN; break; } if (cursmove == -1) { return OPERATOR_CANCELLED; } if (ef->pos > ef->len) { ef->pos = ef->len; } else if (ef->pos >= MAXTEXT) { ef->pos = MAXTEXT; } else if (ef->pos < 0) { diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h index 42be4dc63cc..7f7294c673a 100644 --- a/source/blender/makesdna/DNA_vfont_types.h +++ b/source/blender/makesdna/DNA_vfont_types.h @@ -24,30 +24,32 @@ typedef struct VFont { /** 1024 = FILE_MAX. */ char filepath[1024]; struct VFontData *data; struct PackedFile *packedfile; /* runtime only, holds memory for freetype to read from * TODO: replace this with #blf_font_new() style loading. */ struct PackedFile *temp_pf; } VFont; /* *************** FONT ****************** */ #define FO_EDIT 0 #define FO_CURS 1 #define FO_CURSUP 2 #define FO_CURSDOWN 3 #define FO_DUPLI 4 #define FO_PAGEUP 8 #define FO_PAGEDOWN 9 -#define FO_SELCHANGE 10 +#define FO_TEXTBEGIN 10 +#define FO_TEXTEND 11 +#define FO_SELCHANGE 12 /* BKE_vfont_to_curve will move the cursor in these cases */ -#define FO_CURS_IS_MOTION(mode) (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN)) +#define FO_CURS_IS_MOTION(mode) (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN, FO_TEXTBEGIN, FO_TEXTEND)) #define FO_BUILTIN_NAME "" #ifdef __cplusplus } #endif