Text object: operators to move cursor to the top or bottom #106196

Merged
Harley Acheson merged 1 commits from pioverfour/blender:dp_font_move_home_end into main 2023-04-19 02:18:31 +02:00
5 changed files with 35 additions and 0 deletions

View File

@ -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},

View File

@ -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},

View File

@ -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'

View File

@ -34,6 +34,8 @@ enum { CASE_LOWER, CASE_UPPER };
enum {
LINE_BEGIN,
LINE_END,
TEXT_BEGIN,
TEXT_END,
PREV_CHAR,
NEXT_CHAR,
PREV_WORD,

View File

@ -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(