Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-04 20:17:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-04 20:17:09 +0400
commitb6edcc4b33e782b4a91a61d1c46136c52a4172c9 (patch)
tree9a70fa74cc51ca3ba6b91463848c82b559cb09bc /source/blender/editors/space_text/text_ops.c
parent1fd397d2d6ce5f9036c606963060eaf5f49d72c4 (diff)
make text move up/down into a single operator with a direction property
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r--source/blender/editors/space_text/text_ops.c50
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 *********************/