diff options
Diffstat (limited to 'macosx/tkMacOSXClipboard.c')
-rw-r--r-- | macosx/tkMacOSXClipboard.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 639e82f..07a8419 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id$ */ #include "tkMacOSXPrivate.h" @@ -22,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 && @@ -37,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]; } @@ -47,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(); @@ -127,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; } @@ -167,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; } /* @@ -196,7 +207,6 @@ TkMacOSXSelDeadWindow( if (winPtr && winPtr == (TkWindow *)clipboardOwner) { clipboardOwner = NULL; } - return Success; } /* @@ -223,6 +233,7 @@ TkSelUpdateClipboard( /* Info about the content. */ { NSPasteboard *pb = [NSPasteboard generalPasteboard]; + changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; } @@ -302,7 +313,7 @@ TkSuspendClipboard(void) /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 |