summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXClipboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXClipboard.c')
-rw-r--r--macosx/tkMacOSXClipboard.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c
index 7cd9c30..07a8419 100644
--- a/macosx/tkMacOSXClipboard.c
+++ b/macosx/tkMacOSXClipboard.c
@@ -20,8 +20,10 @@ static Tk_Window clipboardOwner = NULL;
#pragma mark TKApplication(TKClipboard)
@implementation TKApplication(TKClipboard)
-- (void)tkProvidePasteboard:(TkDisplay *)dispPtr
- pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
+- (void) tkProvidePasteboard: (TkDisplay *) dispPtr
+ pasteboard: (NSPasteboard *) sender
+ provideDataForType: (NSString *) type
+{
NSMutableString *string = [NSMutableString new];
if (dispPtr && dispPtr->clipboardActive &&
@@ -35,6 +37,7 @@ static Tk_Window clipboardOwner = NULL;
NSString *s = [[NSString alloc] initWithBytesNoCopy:
cbPtr->buffer length:cbPtr->length
encoding:NSUTF8StringEncoding freeWhenDone:NO];
+
[string appendString:s];
[s release];
}
@@ -45,18 +48,25 @@ static Tk_Window clipboardOwner = NULL;
[sender setString:string forType:type];
[string release];
}
-- (void)tkProvidePasteboard:(TkDisplay *)dispPtr {
+
+- (void) tkProvidePasteboard: (TkDisplay *) dispPtr
+{
if (dispPtr && dispPtr->clipboardActive) {
[self tkProvidePasteboard:dispPtr
pasteboard:[NSPasteboard generalPasteboard]
provideDataForType:NSStringPboardType];
}
}
-- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
+
+- (void) pasteboard: (NSPasteboard *) sender
+ provideDataForType: (NSString *) type
+{
[self tkProvidePasteboard:TkGetDisplayList() pasteboard:sender
provideDataForType:type];
}
-- (void)tkCheckPasteboard {
+
+- (void) tkCheckPasteboard
+{
if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] !=
changeCount) {
TkDisplay *dispPtr = TkGetDisplayList();
@@ -125,12 +135,13 @@ TkSelGetSelection(
if (type) {
string = [pb stringForType:type];
}
- result = proc(clientData, interp, string ? (char*)[string UTF8String]
- : "");
+ result = proc(clientData, interp, string ? [string UTF8String] : "");
} else {
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s selection doesn't exist or form \"%s\" not defined",
+ Tk_GetAtomName(tkwin, selection),
+ Tk_GetAtomName(tkwin, target)));
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
}
return result;
}
@@ -165,9 +176,11 @@ XSetSelectionOwner(
clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL;
if (!dispPtr->clipboardActive) {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
+
changeCount = [pb declareTypes:[NSArray array] owner:NSApp];
}
}
+ return Success;
}
/*
@@ -194,7 +207,6 @@ TkMacOSXSelDeadWindow(
if (winPtr && winPtr == (TkWindow *)clipboardOwner) {
clipboardOwner = NULL;
}
- return Success;
}
/*
@@ -221,6 +233,7 @@ TkSelUpdateClipboard(
/* Info about the content. */
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
+
changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:NSApp];
}