aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 7685728d..d560e233 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -501,6 +501,25 @@ YY_BUFFER_STATE yy_scan_string (const char *);
[self insertText:@""];
}
+/*
+ * Copy selected text chunk as RTF to preserve syntax highlighting
+ */
+- (void)copyAsRTF:(id)sender
+{
+
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSTextStorage *textStorage = [self textStorage];
+ NSData *rtf = [textStorage RTFFromRange:[self selectedRange]
+ documentAttributes:nil];
+
+ if (rtf)
+ {
+ [pb declareTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:self];
+ [pb setData:rtf forType:NSRTFPboardType];
+ }
+
+}
+
/*
List of keywords for autocompletion. If you add a keyword here,