Text object: operators to move cursor to the top or bottom
This adds new movement types TEXT_BEGIN and TEXT_END to allow FONT_OT_move and FONT_OT_move_select operators move the text cursor (caret) to the top and bottom of the text. Pull Request: https://projects.blender.org/blender/blender/pulls/106196
This commit is contained in:
parent
846d78b09a
commit
6d2351d26b
|
@ -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.0)]}),
|
||||
("font.change_spacing", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -1803,6 +1803,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'
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ enum { CASE_LOWER, CASE_UPPER };
|
|||
enum {
|
||||
LINE_BEGIN,
|
||||
LINE_END,
|
||||
TEXT_BEGIN,
|
||||
TEXT_END,
|
||||
PREV_CHAR,
|
||||
NEXT_CHAR,
|
||||
PREV_WORD,
|
||||
|
|
|
@ -1135,6 +1135,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", ""},
|
||||
|
@ -1188,6 +1190,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(
|
||||
|
|
Loading…
Reference in New Issue