Page Menu
Home
Search
Configure Global Search
Log In
Files
F20837
text_duplicate_line.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Justin Dailey (dail)
Nov 13 2013, 4:28 PM
Size
5 KB
Subscribers
None
text_duplicate_line.diff
View Options
Index: release/scripts/startup/bl_ui/space_text.py
===================================================================
--- release/scripts/startup/bl_ui/space_text.py (revision 45403)
+++ release/scripts/startup/bl_ui/space_text.py (working copy)
@@ -273,6 +273,7 @@
layout.operator("text.cut")
layout.operator("text.copy")
layout.operator("text.paste")
+ layout.operator("text.duplicate_line")
layout.separator()
Index: source/blender/blenkernel/BKE_text.h
===================================================================
--- source/blender/blenkernel/BKE_text.h (revision 45403)
+++ source/blender/blenkernel/BKE_text.h (working copy)
@@ -96,6 +96,7 @@
void txt_comment (struct Text *text);
void txt_indent (struct Text *text);
void txt_uncomment (struct Text *text);
+void txt_duplicate_line (struct Text *text);
int setcurr_tab_spaces (struct Text *text, int space);
void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, const unsigned char color[4], int group, int flags);
@@ -169,6 +170,8 @@
#define UNDO_COMMENT 034
#define UNDO_UNCOMMENT 035
+#define UNDO_DUPLICATE 040
+
/* Marker flags */
#define TMARK_TEMP 0x01 /* Remove on non-editing events, don't save */
#define TMARK_EDITALL 0x02 /* Edit all markers of the same group as one */
Index: source/blender/blenkernel/intern/text.c
===================================================================
--- source/blender/blenkernel/intern/text.c (revision 45403)
+++ source/blender/blenkernel/intern/text.c (working copy)
@@ -2205,6 +2205,9 @@
text->undo_pos--;
break;
+ case UNDO_DUPLICATE:
+ txt_delete_line(text, text->curl->next);
+ break;
default:
//XXX error("Undo buffer error - resetting");
text->undo_pos= -1;
@@ -2402,6 +2405,9 @@
txt_uncomment(text);
}
break;
+ case UNDO_DUPLICATE:
+ txt_duplicate_line(text);
+ break;
default:
//XXX error("Undo buffer error - resetting");
text->undo_pos= -1;
@@ -2543,6 +2549,23 @@
txt_clean_text(text);
}
+void txt_duplicate_line(Text *text)
+{
+ TextLine *textline;
+
+ if (!text || !text->curl) return;
+
+ if (text->curl == text->sell) {
+ textline = txt_new_line(text->curl->line);
+ BLI_insertlinkafter(&text->lines, text->curl, textline);
+
+ txt_make_dirty(text);
+ txt_clean_text(text);
+
+ if (!undoing) txt_undo_add_op(text, UNDO_DUPLICATE);
+ }
+}
+
void txt_delete_char(Text *text)
{
unsigned int c='\n';
Index: source/blender/editors/space_text/space_text.c
===================================================================
--- source/blender/editors/space_text/space_text.c (revision 45403)
+++ source/blender/editors/space_text/space_text.c (working copy)
@@ -187,6 +187,7 @@
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 @@
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_SHIFT | 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);
Index: source/blender/editors/space_text/text_intern.h
===================================================================
--- source/blender/editors/space_text/text_intern.h (revision 45403)
+++ source/blender/editors/space_text/text_intern.h (working copy)
@@ -118,6 +118,7 @@
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);
Index: source/blender/editors/space_text/text_ops.c
===================================================================
--- source/blender/editors/space_text/text_ops.c (revision 45403)
+++ source/blender/editors/space_text/text_ops.c (working copy)
@@ -826,6 +826,35 @@
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)
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4e/c7/adecbb9828bae4bdd0713883d175
Event Timeline
Log In to Comment