diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 30 |
3 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index beccca51265..032cc4ecbf2 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -187,6 +187,7 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_paste); WM_operatortype_append(TEXT_OT_copy); WM_operatortype_append(TEXT_OT_cut); + WM_operatortype_append(TEXT_OT_duplicate_line); WM_operatortype_append(TEXT_OT_convert_whitespace); WM_operatortype_append(TEXT_OT_uncomment); @@ -297,6 +298,8 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_cut", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", INSERTKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", INSERTKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_item(keymap, "TEXT_OT_duplicate_line", DKEY, KM_PRESS, KM_CTRL, 0); if (U.uiflag & USER_MMB_PASTE) { // XXX not dynamic kmi = WM_keymap_add_item(keymap, "TEXT_OT_paste", MIDDLEMOUSE, KM_PRESS, 0, 0); @@ -353,7 +356,6 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", ENDKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "type", FILE_BOTTOM); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); - RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 2d297dd20d7..07d2dffb95b 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -118,6 +118,7 @@ void TEXT_OT_refresh_pyconstraints(struct wmOperatorType *ot); void TEXT_OT_paste(struct wmOperatorType *ot); void TEXT_OT_copy(struct wmOperatorType *ot); void TEXT_OT_cut(struct wmOperatorType *ot); +void TEXT_OT_duplicate_line(struct wmOperatorType *ot); void TEXT_OT_convert_whitespace(struct wmOperatorType *ot); void TEXT_OT_uncomment(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 730dfb7d979..f60217ba8ac 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -826,6 +826,36 @@ void TEXT_OT_paste(wmOperatorType *ot) RNA_def_boolean(ot->srna, "selection", 0, "Selection", "Paste text selected elsewhere rather than copied (X11 only)"); } +/**************** duplicate operator *******************/ + +static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Text *text= CTX_data_edit_text(C); + + txt_duplicate_line(text); + + 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_duplicate_line(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Duplicate Line"; + ot->idname = "TEXT_OT_duplicate_line"; + ot->description = "Duplicate the current line"; + + /* api callbacks */ + ot->exec = text_duplicate_line_exec; + ot->poll = text_edit_poll; +} + /******************* copy operator *********************/ static void txt_copy_clipboard(Text *text) |