diff options
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index cb8daa0f03e..a07493ef8fc 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1333,11 +1333,12 @@ void TEXT_OT_select_word(wmOperatorType *ot) /********************* move lines operators ***********************/ -static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) +static int move_lines_exec(bContext *C, wmOperator *op) { Text *text = CTX_data_edit_text(C); + const int direction = RNA_enum_get(op->ptr, "direction"); - txt_move_lines_up(text); + txt_move_lines(text, direction); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); @@ -1349,44 +1350,25 @@ static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void TEXT_OT_move_lines_up(wmOperatorType *ot) +void TEXT_OT_move_lines(wmOperatorType *ot) { - /* identifiers */ - ot->name = "Move Lines Up"; - ot->idname = "TEXT_OT_move_lines_up"; - ot->description = "Moves the currently selected line(s) up."; - - /* api callbacks */ - ot->exec = move_lines_up_exec; - ot->poll = text_edit_poll; -} - -static int move_lines_down_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Text *text = CTX_data_edit_text(C); - - txt_move_lines_down(text); - - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + static EnumPropertyItem direction_items[]= { + {TXT_MOVE_LINE_UP, "UP", 0, "Up", ""}, + {TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; - /* run the script while editing, evil but useful */ - if (CTX_wm_space_text(C)->live_edit) - text_run_script(C, NULL); - - return OPERATOR_FINISHED; -} - -void TEXT_OT_move_lines_down(wmOperatorType *ot) -{ /* identifiers */ - ot->name = "Move Lines Down"; - ot->idname = "TEXT_OT_move_lines_down"; - ot->description = "Moves the currently selected line(s) down."; + ot->name = "Move Lines"; + ot->idname = "TEXT_OT_move_lines"; + ot->description = "Moves the currently selected line(s) up/down"; /* api callbacks */ - ot->exec = move_lines_down_exec; + ot->exec = move_lines_exec; ot->poll = text_edit_poll; + + /* properties */ + RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", ""); } /******************* previous marker operator *********************/ |