diff options
author | Joshua Leung <aligorith@gmail.com> | 2012-05-04 18:27:13 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2012-05-04 18:27:13 +0400 |
commit | 2bc29ff4260e28dd89409255997858ca447ad51f (patch) | |
tree | 3ffc5961c796571371f1edaaaaa709fc953e1e62 /source/blender/editors/space_text/text_ops.c | |
parent | e62f13ac311eec269abb6a9429b29279dc642cec (diff) |
Patch [#30654] Wiki Quick Hack: Text editor move lines up/down
Submitted by: Justin Dailey (dail)
Patch allows the current line (or selected lines) to be moved up and down with
Ctrl+Shift+Up and Ctrl+Shift+Down. Has undo/redo support and operators in python
menu.
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index f60217ba8ac..cb8daa0f03e 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1331,6 +1331,64 @@ void TEXT_OT_select_word(wmOperatorType *ot) ot->poll = text_edit_poll; } +/********************* move lines operators ***********************/ + +static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Text *text = CTX_data_edit_text(C); + + txt_move_lines_up(text); + + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + + /* 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_up(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); + + /* 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."; + + /* api callbacks */ + ot->exec = move_lines_down_exec; + ot->poll = text_edit_poll; +} + /******************* previous marker operator *********************/ static int text_previous_marker_exec(bContext *C, wmOperator *UNUSED(op)) |