From a8848a1c7e392b98602f6212f90a27777239afa4 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Tue, 28 Mar 2023 02:15:06 +0200 Subject: [PATCH] Font: add options to move the cursor to the top or bottom The FONT_OT_move and FONT_OT_move_select operators had most of the usual operations (char, line, block, page), but the option to go to the top or bottom of the "file" were lacking, whereas they had been implemented in the text editor. I found these shortcuts lacking while editing many text objects in a scene, as these operations are ubiquitous in text editors. This commit adds the options using the rather standard Ctrl + Home and Ctrl + End shortcuts to move. The same shortcuts select by using Shift as well. Both the Blender default and Industry compatible keymaps have been updated. --- .../presets/keyconfig/keymap_data/blender_default.py | 8 ++++++++ .../keymap_data/industry_compatible_data.py | 8 ++++++++ scripts/startup/bl_ui/space_view3d.py | 5 +++++ source/blender/editors/curve/curve_intern.h | 2 ++ source/blender/editors/curve/editfont.c | 12 ++++++++++++ 5 files changed, 35 insertions(+) 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 @@ -5579,6 +5579,10 @@ def km_font(params): {"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}, @@ -5599,6 +5603,10 @@ def km_font(params): {"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}, 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 @@ -3775,6 +3775,10 @@ def km_font(params): {"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}, @@ -3795,6 +3799,10 @@ def km_font(params): {"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}, 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 @@ -1804,6 +1804,11 @@ class VIEW3D_MT_select_edit_text(Menu): 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' diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index 61a18dbd3e3..c561d77cf26 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -34,6 +34,8 @@ enum { CASE_LOWER, CASE_UPPER }; enum { LINE_BEGIN, LINE_END, + TEXT_BEGIN, + TEXT_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index f96bb85d53e..50575071060 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1136,6 +1136,8 @@ void FONT_OT_text_paste(wmOperatorType *ot) static const EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, + {TEXT_BEGIN, "TEXT_BEGIN", 0, "Text Begin", ""}, + {TEXT_END, "TEXT_END", 0, "Text End", ""}, {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, @@ -1189,6 +1191,16 @@ static int move_cursor(bContext *C, int type, const bool select) cursmove = FO_CURS; break; + case TEXT_BEGIN: + ef->pos = 0; + cursmove = FO_CURS; + break; + + case TEXT_END: + ef->pos = ef->len; + cursmove = FO_CURS; + break; + case PREV_WORD: { int pos = ef->pos; BLI_str_cursor_step_utf32( -- 2.30.2