[tcobrowser-cvs] SF.net SVN: tcobrowser:[1010] trunk/bibdesk/BibDocument_Actions.m
Status: Beta
Brought to you by:
amaxwell
From: <ama...@us...> - 2008-10-18 01:34:52
|
Revision: 1010 http://tcobrowser.svn.sourceforge.net/tcobrowser/?rev=1010&view=rev Author: amaxwell Date: 2008-10-18 01:34:47 +0000 (Sat, 18 Oct 2008) Log Message: ----------- Write directly to LyX pipe instead of messing with a shell task. Modified Paths: -------------- trunk/bibdesk/BibDocument_Actions.m Modified: trunk/bibdesk/BibDocument_Actions.m =================================================================== --- trunk/bibdesk/BibDocument_Actions.m 2008-10-07 03:48:49 UTC (rev 1009) +++ trunk/bibdesk/BibDocument_Actions.m 2008-10-18 01:34:47 UTC (rev 1010) @@ -520,6 +520,7 @@ return; NSString *lyxPipePath = [[NSFileManager defaultManager] newestLyXPipePath]; + int fd; if (lyxPipePath == nil) { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Unable to Find LyX Pipe", @"Message in alert dialog when LyX pipe cannot be found") @@ -528,22 +529,25 @@ otherButton:nil informativeTextWithFormat:NSLocalizedString(@"BibDesk was unable to find the LyX pipe." , @"Informative text in alert dialog")]; [alert beginSheetModalForWindow:documentWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; - return; + + } else if (-1 != (fd = open([lyxPipePath fileSystemRepresentation], O_WRONLY))) { + + NSArray *citeKeys = [[self selectedPublications] valueForKey:@"citeKey"]; + NSMutableString *cites = [NSMutableString stringWithString:@"LYXCMD:BibDesk:citation-insert:"]; + [cites appendString:[citeKeys componentsJoinedByString:@","]]; + // pipe uses line buffering + [cites appendString:@"\n"]; + + // presumably the LyX document uses the same encoding as the .bib file, but citekeys should be 7 bit ASCII anyway + NSData *data = [cites dataUsingEncoding:[self documentStringEncoding]]; + + sig_t sig = signal(SIGPIPE, SIG_IGN); + write(fd, [data bytes], [data length]); + signal(SIGPIPE, sig); + close(fd); } - - NSEnumerator *itemEnum = [[self selectedPublications] objectEnumerator]; - BibItem *item; - NSMutableString *cites = [NSMutableString string]; - - while (item = [itemEnum nextObject]) { - if ([cites length] > 0) [cites appendString:@","]; - [cites appendString:[item citeKey]]; - } - - NSString *lyxCmd = [NSString stringWithFormat:@"echo LYXCMD:BibDesk:citation-insert:%@ > \"%@\"", cites, lyxPipePath]; - - [BDSKShellTask runShellCommand:lyxCmd withInputString:nil]; } + - (IBAction)postItemToWeblog:(id)sender{ [NSException raise:BDSKUnimplementedException This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |