You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(23) |
Apr
(254) |
May
(252) |
Jun
(209) |
Jul
(198) |
Aug
(192) |
Sep
(207) |
Oct
(120) |
Nov
(179) |
Dec
(52) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(48) |
Feb
(69) |
Mar
(129) |
Apr
(250) |
May
(113) |
Jun
(177) |
Jul
(228) |
Aug
(155) |
Sep
(218) |
Oct
(185) |
Nov
(109) |
Dec
(88) |
2009 |
Jan
(83) |
Feb
(39) |
Mar
(70) |
Apr
(47) |
May
(48) |
Jun
(67) |
Jul
(61) |
Aug
(97) |
Sep
(221) |
Oct
(141) |
Nov
(70) |
Dec
(61) |
2010 |
Jan
(45) |
Feb
(76) |
Mar
(178) |
Apr
(106) |
May
(57) |
Jun
(32) |
Jul
(64) |
Aug
(98) |
Sep
(96) |
Oct
(19) |
Nov
(34) |
Dec
(117) |
2011 |
Jan
(55) |
Feb
(48) |
Mar
(64) |
Apr
(21) |
May
(39) |
Jun
(53) |
Jul
(99) |
Aug
(56) |
Sep
(39) |
Oct
(26) |
Nov
(19) |
Dec
(69) |
2012 |
Jan
(17) |
Feb
(40) |
Mar
(17) |
Apr
|
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
(10) |
Sep
(10) |
Oct
(38) |
Nov
(48) |
Dec
(70) |
2013 |
Jan
(43) |
Feb
(47) |
Mar
(39) |
Apr
(37) |
May
(25) |
Jun
(6) |
Jul
(20) |
Aug
(49) |
Sep
(33) |
Oct
(34) |
Nov
(75) |
Dec
(6) |
2014 |
Jan
(32) |
Feb
(10) |
Mar
(17) |
Apr
|
May
|
Jun
(26) |
Jul
(5) |
Aug
|
Sep
(4) |
Oct
(23) |
Nov
(80) |
Dec
(48) |
2015 |
Jan
(80) |
Feb
(50) |
Mar
(58) |
Apr
(20) |
May
(11) |
Jun
(16) |
Jul
(24) |
Aug
(27) |
Sep
(56) |
Oct
(30) |
Nov
(16) |
Dec
(6) |
2016 |
Jan
(31) |
Feb
(14) |
Mar
(23) |
Apr
(17) |
May
(40) |
Jun
(12) |
Jul
(17) |
Aug
(9) |
Sep
(32) |
Oct
(36) |
Nov
(23) |
Dec
(9) |
2017 |
Jan
(37) |
Feb
(23) |
Mar
(65) |
Apr
(22) |
May
(6) |
Jun
(3) |
Jul
|
Aug
|
Sep
(3) |
Oct
(22) |
Nov
(63) |
Dec
(71) |
2018 |
Jan
(83) |
Feb
(21) |
Mar
(35) |
Apr
(44) |
May
(14) |
Jun
(12) |
Jul
(8) |
Aug
(18) |
Sep
(10) |
Oct
(145) |
Nov
(144) |
Dec
(76) |
2019 |
Jan
(18) |
Feb
(28) |
Mar
(5) |
Apr
(208) |
May
(291) |
Jun
(158) |
Jul
(27) |
Aug
(8) |
Sep
(10) |
Oct
(83) |
Nov
(41) |
Dec
(31) |
2020 |
Jan
(16) |
Feb
(46) |
Mar
(100) |
Apr
(78) |
May
(69) |
Jun
(71) |
Jul
(28) |
Aug
(131) |
Sep
(176) |
Oct
(89) |
Nov
(147) |
Dec
(19) |
2021 |
Jan
(19) |
Feb
(25) |
Mar
(91) |
Apr
(98) |
May
(14) |
Jun
(44) |
Jul
(8) |
Aug
(3) |
Sep
(38) |
Oct
(57) |
Nov
(97) |
Dec
(74) |
2022 |
Jan
(89) |
Feb
(47) |
Mar
(15) |
Apr
(50) |
May
(54) |
Jun
(56) |
Jul
(80) |
Aug
(12) |
Sep
(11) |
Oct
(60) |
Nov
(48) |
Dec
(4) |
2023 |
Jan
(75) |
Feb
(49) |
Mar
(84) |
Apr
(24) |
May
(13) |
Jun
(74) |
Jul
(32) |
Aug
(66) |
Sep
(50) |
Oct
(38) |
Nov
(105) |
Dec
(181) |
2024 |
Jan
(21) |
Feb
(49) |
Mar
(77) |
Apr
(84) |
May
(20) |
Jun
(71) |
Jul
(53) |
Aug
(33) |
Sep
(54) |
Oct
(124) |
Nov
(151) |
Dec
(73) |
2025 |
Jan
(61) |
Feb
(17) |
Mar
(136) |
Apr
(72) |
May
(200) |
Jun
(238) |
Jul
(91) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ho...@us...> - 2007-04-28 20:14:32
|
Revision: 1925 http://skim-app.svn.sourceforge.net/skim-app/?rev=1925&view=rev Author: hofman Date: 2007-04-28 13:14:20 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Parse and lookup pdfsync in background using a DO. Modified Paths: -------------- trunk/SKApplication.m trunk/SKDocument.m trunk/SKPDFSynchronizer.h trunk/SKPDFSynchronizer.m trunk/SKPDFView.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-28 17:13:26 UTC (rev 1924) +++ trunk/SKApplication.m 2007-04-28 20:14:20 UTC (rev 1925) @@ -114,14 +114,9 @@ if ([[NSFileManager defaultManager] fileExistsAtPath:[file path]] && [[NSFileManager defaultManager] fileExistsAtPath:source]) { SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:file display:YES error:NULL]; - unsigned int pageIndex; - NSPoint point; - if ([document respondsToSelector:@selector(synchronizer)] && [document respondsToSelector:@selector(pdfView)] && - [[document synchronizer] getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:source]) { - - [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; - } + if ([document respondsToSelector:@selector(synchronizer)]) + [[document synchronizer] findPageLocationForLine:[lineNumber intValue] inFile:source]; } else { [command setScriptErrorNumber:NSArgumentsWrongScriptError]; Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-04-28 17:13:26 UTC (rev 1924) +++ trunk/SKDocument.m 2007-04-28 20:14:20 UTC (rev 1925) @@ -76,6 +76,8 @@ - (void)dealloc { [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKey:SKAutoCheckFileUpdateKey]; [[NSNotificationCenter defaultCenter] removeObserver:self]; + [synchronizer stopDOServer]; + [synchronizer release]; [fileUpdateTimer invalidate]; [fileUpdateTimer release]; [lastChangedDate release]; @@ -83,7 +85,6 @@ [pdfData release]; [noteDicts release]; [readNotesAccessoryView release]; - [synchronizer release]; [super dealloc]; } @@ -599,11 +600,46 @@ - (SKPDFSynchronizer *)synchronizer { if (synchronizer == nil) { synchronizer = [[SKPDFSynchronizer alloc] init]; + [synchronizer setDelegate:self]; [synchronizer setFileName:[[[self fileName] stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdfsync"]]; } return synchronizer; } +- (void)synchronizer:(SKPDFSynchronizer *)synchronizer foundLine:(int)line inFile:(NSString *)file { + if ([[NSFileManager defaultManager] fileExistsAtPath:file]) { + + NSString *editorPreset = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorPresetKey]; + NSString *editorCmd = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorCommandKey]; + NSMutableString *cmdString = [[[[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorArgumentsKey] mutableCopy] autorelease]; + + if ([editorPreset isEqualToString:@""] == NO) { + NSString *appPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:editorPreset]; + NSString *toolPath = appPath ? [NSBundle pathForResource:editorCmd ofType:nil inDirectory:appPath] : nil; + if (toolPath) { + editorCmd = toolPath; + } else { + // Emacs has its tool in Emacs.app/Contents/MacOS/bin/ + toolPath = [[[[NSBundle bundleWithPath:appPath] executablePath] stringByAppendingPathComponent:@"bin"] stringByAppendingPathComponent:cmdString]; + if ([[NSFileManager defaultManager] isExecutableFileAtPath:toolPath]) + editorCmd = toolPath; + } + } + + [cmdString replaceOccurrencesOfString:@"%file" withString:file options:NSLiteralSearch range: NSMakeRange(0, [cmdString length] )]; + [cmdString replaceOccurrencesOfString:@"%line" withString:[NSString stringWithFormat:@"%d", line] options:NSLiteralSearch range:NSMakeRange(0, [cmdString length])]; + [cmdString insertString:@" " atIndex:0]; + [cmdString insertString:editorCmd atIndex:0]; + + [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", cmdString, nil]]; + } +} + +- (void)synchronizer:(SKPDFSynchronizer *)synchronizer foundLocation:(NSPoint)point atPageIndex:(unsigned int)pageIndex { + [[self pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; +} + + #pragma mark Accessors - (SKMainWindowController *)mainWindowController { Modified: trunk/SKPDFSynchronizer.h =================================================================== --- trunk/SKPDFSynchronizer.h 2007-04-28 17:13:26 UTC (rev 1924) +++ trunk/SKPDFSynchronizer.h 2007-04-28 20:14:20 UTC (rev 1925) @@ -37,6 +37,7 @@ */ #import <Cocoa/Cocoa.h> +#import <libkern/OSAtomic.h> @interface SKPDFSynchronizer : NSObject { @@ -44,20 +45,40 @@ NSDate *lastModDate; NSMutableArray *pages; NSMutableDictionary *lines; + + id delegate; + + NSLock *lock; + + id serverOnMainThread; + id serverOnServerThread; + NSConnection *mainThreadConnection; + NSConnection *localThreadConnection; + + volatile int32_t shouldKeepRunning __attribute__ ((aligned (4))); } + +- (id)delegate; +- (void)setDelegate:(id)newDelegate; + - (NSString *)fileName; - (void)setFileName:(NSString *)newFileName; -- (BOOL)parsePdfsyncFile; -- (BOOL)parsePdfsyncFileIfNeeded; +- (void)findLineForLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex; +- (void)findPageLocationForLine:(int)line inFile:(NSString *)file; -- (BOOL)getLine:(int *)line file:(NSString **)file forLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex; -- (BOOL)getPageIndex:(unsigned int *)pageIndex location:(NSPoint *)point forLine:(int)line inFile:(NSString *)file; +- (void)stopDOServer; @end +@interface NSObject (SKPDFSynchronizerDelegate) +- (void)synchronizer:(SKPDFSynchronizer *)synchronizer foundLine:(int)line inFile:(NSString *)file; +- (void)synchronizer:(SKPDFSynchronizer *)synchronizer foundLocation:(NSPoint)point atPageIndex:(unsigned int)pageIndex; +@end + + @interface NSMutableDictionary (SKExtensions) - (void)setIntValue:(int)value forKey:(id)key; - (void)setFloatValue:(float)value forKey:(id)key; Modified: trunk/SKPDFSynchronizer.m =================================================================== --- trunk/SKPDFSynchronizer.m 2007-04-28 17:13:26 UTC (rev 1924) +++ trunk/SKPDFSynchronizer.m 2007-04-28 20:14:20 UTC (rev 1925) @@ -39,8 +39,96 @@ #import "SKPDFSynchronizer.h" #import "NSCharacterSet_SKExtensions.h" #import "NSScanner_SKExtensions.h" +#import <Carbon/Carbon.h> +// NSFileManager is not thread safe +static BOOL SKFileExistsAtPath(NSString *path) { + if (path == nil) + return NO; + + FSRef ref; + + return noErr == FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &ref, NULL); +} + +static NSDate *SKFileModificationDateAtPath(NSString *path) { + static NSDate* jan1904 = nil; + if (jan1904 == nil) + jan1904 = [[NSDate dateWithString:@"1904-01-01 00:00:00 +0000"] retain]; + + FSCatalogInfo info; + FSRef fileRef; + + if (NO == CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath:path], &fileRef)) + return nil; + + if (noErr == FSGetCatalogInfo( &fileRef, kFSCatInfoContentMod, &info, NULL,NULL, NULL )) + return nil; + + union { + UTCDateTime local; + UInt64 shifted; + } time; + + time.local = info.contentModDate; + if (time.shifted) + return [[[NSDate alloc] initWithTimeInterval:time.shifted / 65536 sinceDate:jan1904] autorelease]; + else + return nil; +} + +static NSString *SKTeXSourceFile(NSString *file, NSString *base) { + if ([[file pathExtension] caseInsensitiveCompare:@"tex"] != NSOrderedSame) + file = [file stringByAppendingPathExtension:@"tex"]; + if ([file hasPrefix:@"/"] == NO) + file = [base stringByAppendingPathComponent:file]; + return file; +} + +static NSMutableDictionary *SKRecordForRecordIndex(NSMutableDictionary *records, int recordIndex) { + NSNumber *recordNumber = [[NSNumber alloc] initWithInt:recordIndex]; + NSMutableDictionary *record = [records objectForKey:recordNumber]; + if (record == nil) { + record = [[NSMutableDictionary alloc] initWithObjectsAndKeys:recordNumber, @"recordIndex", nil]; + [records setObject:record forKey:recordNumber]; + [record release]; + } + [recordNumber release]; + return record; +} + +#pragma mark - + +@protocol SKPDFSynchronizerServerThread +- (oneway void)cleanup; +- (oneway void)serverFindLineForLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex; +- (oneway void)serverFindPageLocationForLine:(int)line inFile:(bycopy NSString *)file; +@end + +@protocol SKPDFSynchronizerMainThread +- (oneway void)setLocalServer:(byref id)anObject; +- (oneway void)serverFoundLine:(int)line inFile:(bycopy NSString *)file; +- (oneway void)serverFoundLocation:(NSPoint)point atPageIndex:(unsigned int)pageIndex; +@end + +#pragma mark - + +@interface SKPDFSynchronizer (Private) + +- (NSDate *)lastModDate; +- (void)setLastModDate:(NSDate *)date; + +- (void)runDOServerForPorts:(NSArray *)ports; + +// these following methods only be called on the server thread +- (BOOL)parsePdfsyncFile; +- (BOOL)parsePdfsyncFileIfNeeded; + +@end + +#pragma mark - + @implementation SKPDFSynchronizer // Offset of coordinates in PDFKit and what pdfsync tells us. Don't know what they are; is this implementation dependent? @@ -52,11 +140,32 @@ lines = [[NSMutableDictionary alloc] init]; fileName = nil; lastModDate = nil; + + lock = [[NSLock alloc] init]; + + NSPort *port1 = [NSPort port]; + NSPort *port2 = [NSPort port]; + + mainThreadConnection = [[NSConnection alloc] initWithReceivePort:port1 sendPort:port2]; + [mainThreadConnection setRootObject:self]; + [mainThreadConnection enableMultipleThreads]; + + // these will be set when the background thread sets up + localThreadConnection = nil; + serverOnMainThread = nil; + serverOnServerThread = nil; + + shouldKeepRunning = 1; + + // run a background thread to connect to the remote server + // this will connect back to the connection we just set up + [NSThread detachNewThreadSelector:@selector(runDOServerForPorts:) toTarget:self withObject:[NSArray arrayWithObjects:port2, port1, nil]]; } return self; } - (void)dealloc { + [lock release]; [pages release]; [lines release]; [fileName release]; @@ -64,11 +173,28 @@ [super dealloc]; } +#pragma mark Accessors + +- (id)delegate { + return [[delegate retain] autorelease]; +} + +- (void)setDelegate:(id)newDelegate { + if (delegate != newDelegate) { + [delegate release]; + delegate = [newDelegate retain]; + } +} + - (NSString *)fileName { - return [[fileName retain] autorelease]; + [lock lock]; + NSString *file = [[fileName retain] autorelease]; + [lock unlock]; + return file; } - (void)setFileName:(NSString *)newFileName { + [lock lock]; if (fileName != newFileName) { if ([fileName isEqualToString:newFileName] == NO && lastModDate) { [lastModDate release]; @@ -77,58 +203,169 @@ [fileName release]; fileName = [newFileName retain]; } + [lock unlock]; } +- (NSDate *)lastModDate { + [lock lock]; + NSDate *date = [[lastModDate retain] autorelease]; + [lock unlock]; + return date; +} + +- (void)setLastModDate:(NSDate *)date { + [lock lock]; + if (date != lastModDate) { + [lastModDate release]; + lastModDate = [date retain]; + } + [lock unlock]; +} + +#pragma mark API +#pragma mark | DO server + +- (void)stopDOServer { + // this cleans up the connections, ports and proxies on both sides + [serverOnServerThread cleanup]; + // we're in the main thread, so set the stop flag + OSAtomicCompareAndSwap32Barrier(1, 0, (int32_t *)&shouldKeepRunning); + + // clean up the connection in the main thread; don't invalidate the ports, since they're still in use + [mainThreadConnection setRootObject:nil]; + [mainThreadConnection invalidate]; + [mainThreadConnection release]; + mainThreadConnection = nil; + + [serverOnServerThread release]; + serverOnServerThread = nil; +} + +#pragma mark | Finding + +- (void)findLineForLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex { + while (serverOnServerThread == nil) + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + [serverOnServerThread serverFindLineForLocation:point inRect:rect atPageIndex:pageIndex]; +} + +- (void)findPageLocationForLine:(int)line inFile:(NSString *)file { + while (serverOnServerThread == nil) + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + [serverOnServerThread serverFindPageLocationForLine:line inFile:file]; +} + +#pragma mark Main thread +#pragma mark | DO server + +- (oneway void)setLocalServer:(byref id)anObject { + [anObject setProtocolForProxy:@protocol(SKPDFSynchronizerServerThread)]; + serverOnServerThread = [anObject retain]; +} + +#pragma mark | Finding + +- (oneway void)serverFoundLine:(int)line inFile:(bycopy NSString *)file { + if (shouldKeepRunning && [delegate respondsToSelector:@selector(synchronizer:foundLine:inFile:)]) + [delegate synchronizer:self foundLine:line inFile:file]; +} + +- (oneway void)serverFoundLocation:(NSPoint)point atPageIndex:(unsigned int)pageIndex { + if (shouldKeepRunning && [delegate respondsToSelector:@selector(synchronizer:foundLocation:atPageIndex:)]) + [delegate synchronizer:self foundLocation:point atPageIndex:pageIndex]; +} + +#pragma mark Server thread +#pragma mark | DO server + +- (oneway void)cleanup { + // clean up the connection in the server thread + [localThreadConnection setRootObject:nil]; + + // this frees up the CFMachPorts created in -init + [[localThreadConnection receivePort] invalidate]; + [[localThreadConnection sendPort] invalidate]; + [localThreadConnection invalidate]; + [localThreadConnection release]; + localThreadConnection = nil; + + [serverOnMainThread release]; + serverOnMainThread = nil; +} + +- (void)runDOServerForPorts:(NSArray *)ports { + // detach a new thread to run this + NSAssert(localThreadConnection == nil, @"server is already running"); + + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t *)&shouldKeepRunning); + + @try { + // we'll use this to communicate between threads on the localhost + localThreadConnection = [[NSConnection alloc] initWithReceivePort:[ports objectAtIndex:0] sendPort:[ports objectAtIndex:1]]; + if(localThreadConnection == nil) + @throw @"Unable to get default connection"; + [localThreadConnection setRootObject:self]; + + serverOnMainThread = [[localThreadConnection rootProxy] retain]; + [serverOnMainThread setProtocolForProxy:@protocol(SKPDFSynchronizerMainThread)]; + // handshake, this sets the proxy at the other side + [serverOnMainThread setLocalServer:self]; + + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + BOOL didRun; + + // see http://lists.apple.com/archives/cocoa-dev/2006/Jun/msg01054.html for a helpful explanation of NSRunLoop + do { + [pool release]; + pool = [NSAutoreleasePool new]; + didRun = [rl runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; + } while (shouldKeepRunning == 1 && didRun); + } + @catch(id exception) { + NSLog(@"Discarding exception \"%@\" raised in object %@", exception, self); + // reset the flag so we can start over; shouldn't be necessary + OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t *)&shouldKeepRunning); + } + + @finally { + [pool release]; + } +} + - (BOOL)parsePdfsyncFileIfNeeded { - NSFileManager *fm = [NSFileManager defaultManager]; + NSString *theFileName = [self fileName]; - if (fileName == nil || [fm fileExistsAtPath:fileName] == NO) + if (theFileName == nil || SKFileExistsAtPath(theFileName) == NO) return NO; - NSDate *modDate = [[fm fileAttributesAtPath:fileName traverseLink:NO] fileModificationDate]; - - if (lastModDate == nil || [modDate compare:lastModDate] == NSOrderedDescending) + NSDate *modDate = SKFileModificationDateAtPath(theFileName); + NSDate *currentModDate = [self lastModDate]; + + if (currentModDate == nil || [modDate compare:currentModDate] == NSOrderedDescending) return [self parsePdfsyncFile]; return YES; } -static NSString *SKTeXSourceFile(NSString *file, NSString *base) { - if ([[file pathExtension] caseInsensitiveCompare:@"tex"] != NSOrderedSame) - file = [file stringByAppendingPathExtension:@"tex"]; - if ([file hasPrefix:@"/"] == NO) - file = [base stringByAppendingPathComponent:file]; - return file; -} +#pragma mark | Parsing and Finding -static NSMutableDictionary *SKRecordForRecordIndex(NSMutableDictionary *records, int recordIndex) { - NSNumber *recordNumber = [[NSNumber alloc] initWithInt:recordIndex]; - NSMutableDictionary *record = [records objectForKey:recordNumber]; - if (record == nil) { - record = [[NSMutableDictionary alloc] initWithObjectsAndKeys:recordNumber, @"recordIndex", nil]; - [records setObject:record forKey:recordNumber]; - [record release]; - } - [recordNumber release]; - return record; -} - - (BOOL)parsePdfsyncFile { - NSFileManager *fm = [NSFileManager defaultManager]; + NSString *theFileName = [self fileName]; [pages removeAllObjects]; [lines removeAllObjects]; - if ([fm fileExistsAtPath:fileName] == NO) + if (SKFileExistsAtPath(theFileName) == NO) return NO; - [lastModDate release]; - lastModDate = [[[fm fileAttributesAtPath:fileName traverseLink:NO] fileModificationDate] retain]; + [self setLastModDate:SKFileModificationDateAtPath(theFileName)]; - NSString *basePath = [fileName stringByDeletingLastPathComponent]; + NSString *basePath = [theFileName stringByDeletingLastPathComponent]; NSMutableDictionary *records = [NSMutableDictionary dictionary]; NSMutableArray *files = [NSMutableArray array]; - NSString *pdfsyncString = [NSString stringWithContentsOfFile:fileName encoding:NSUTF8StringEncoding error:NULL]; + NSString *pdfsyncString = [NSString stringWithContentsOfFile:theFileName encoding:NSUTF8StringEncoding error:NULL]; NSString *file; int recordIndex, line; float x, y; @@ -165,7 +402,7 @@ [scanner scanCharactersFromSet:[NSCharacterSet newlineCharacterSet] intoString:NULL]; - while ([scanner scanCharacter:&ch]) { + while (shouldKeepRunning && [scanner scanCharacter:&ch]) { if (ch == 'l') { if ([scanner scanInt:&recordIndex] && [scanner scanInt:&line]) { @@ -226,15 +463,15 @@ [pages makeObjectsPerformSelector:@selector(sortUsingDescriptors:) withObject:[NSArray arrayWithObjects:ySortDescriptor, xSortDescriptor, nil]]; - return YES; + return shouldKeepRunning; } -- (BOOL)getLine:(int *)line file:(NSString **)file forLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex { +- (oneway void)serverFindLineForLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex { int foundLine = -1; NSString *foundFile = nil; NSDictionary *record = nil; - if ([self parsePdfsyncFileIfNeeded] && pageIndex < [pages count]) { + if (shouldKeepRunning && [self parsePdfsyncFileIfNeeded] && pageIndex < [pages count]) { NSDictionary *beforeRecord = nil; NSDictionary *afterRecord = nil; @@ -293,18 +530,16 @@ } - if (line) *line = foundLine; - if (file) *file = foundFile; - - return record != nil; + if (shouldKeepRunning) + [serverOnMainThread serverFoundLine:foundLine inFile:foundFile]; } -- (BOOL)getPageIndex:(unsigned int *)pageIndex location:(NSPoint *)point forLine:(int)line inFile:(NSString *)file { +- (oneway void)serverFindPageLocationForLine:(int)line inFile:(bycopy NSString *)file { unsigned int foundPageIndex = NSNotFound; NSPoint foundPoint = NSZeroPoint; NSDictionary *record = nil; - if (file && [self parsePdfsyncFileIfNeeded] && [lines objectForKey:file]) { + if (shouldKeepRunning && file && [self parsePdfsyncFileIfNeeded] && [lines objectForKey:file]) { NSDictionary *beforeRecord = nil; NSDictionary *afterRecord = nil; @@ -347,14 +582,13 @@ } } - if (pageIndex) *pageIndex = foundPageIndex; - if (point) *point = foundPoint; - - return record != nil; + if (shouldKeepRunning) + [serverOnMainThread serverFoundLocation:foundPoint atPageIndex:foundPageIndex]; } @end +#pragma mark - @implementation NSMutableDictionary (SKExtensions) Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-28 17:13:26 UTC (rev 1924) +++ trunk/SKPDFView.m 2007-04-28 20:14:20 UTC (rev 1925) @@ -2671,44 +2671,14 @@ if ([document respondsToSelector:@selector(synchronizer)]) { - SKPDFSynchronizer *synchronizer = [document synchronizer]; NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; PDFPage *page = [self pageForPoint:mouseLoc nearest:YES]; NSPoint location = [self convertPoint:mouseLoc toPage:page]; unsigned int pageIndex = [[self document] indexForPage:page]; PDFSelection *sel = [page selectionForLineAtPoint:location]; NSRect rect = sel ? [sel boundsForPage:page] : NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0); - NSString *file = nil; - int line = -1; - if ([synchronizer getLine:&line file:&file forLocation:location inRect:rect atPageIndex:pageIndex] && - [[NSFileManager defaultManager] fileExistsAtPath:file]) { - - NSString *editorPreset = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorPresetKey]; - NSString *editorCmd = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorCommandKey]; - NSMutableString *cmdString = [[[[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorArgumentsKey] mutableCopy] autorelease]; - - if ([editorPreset isEqualToString:@""] == NO) { - NSString *appPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:editorPreset]; - NSString *toolPath = appPath ? [NSBundle pathForResource:editorCmd ofType:nil inDirectory:appPath] : nil; - if (toolPath) { - editorCmd = toolPath; - } else { - // Emacs has its tool in Emacs.app/Contents/MacOS/bin/ - toolPath = [[[[NSBundle bundleWithPath:appPath] executablePath] stringByAppendingPathComponent:@"bin"] stringByAppendingPathComponent:cmdString]; - if ([[NSFileManager defaultManager] isExecutableFileAtPath:toolPath]) - editorCmd = toolPath; - } - } - - [cmdString replaceOccurrencesOfString:@"%file" withString:file options:NSLiteralSearch range: NSMakeRange(0, [cmdString length] )]; - [cmdString replaceOccurrencesOfString:@"%line" withString:[NSString stringWithFormat:@"%d", line] options:NSLiteralSearch range:NSMakeRange(0, [cmdString length])]; - [cmdString insertString:@" " atIndex:0]; - [cmdString insertString:editorCmd atIndex:0]; - - [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", cmdString, nil]]; - - } else NSBeep(); + [[document synchronizer] findLineForLocation:location inRect:rect atPageIndex:pageIndex]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-28 17:13:32
|
Revision: 1924 http://skim-app.svn.sourceforge.net/skim-app/?rev=1924&view=rev Author: hofman Date: 2007-04-28 10:13:26 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Add a pref for preset of text editor for pdfsync. Try to find tool to open editor in the bundle of the preset. Add a new preset. Modified Paths: -------------- trunk/Dutch.lproj/PreferenceWindow.nib/info.nib trunk/Dutch.lproj/PreferenceWindow.nib/keyedobjects.nib trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib trunk/InitialUserDefaults.plist trunk/SKPDFView.m trunk/SKPreferenceController.m trunk/SKStringConstants.h trunk/SKStringConstants.m Modified: trunk/Dutch.lproj/PreferenceWindow.nib/info.nib =================================================================== --- trunk/Dutch.lproj/PreferenceWindow.nib/info.nib 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/Dutch.lproj/PreferenceWindow.nib/info.nib 2007-04-28 17:13:26 UTC (rev 1924) @@ -3,11 +3,15 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>69 58 356 240 0 0 1440 938 </string> + <string>68 59 356 240 0 0 1440 938 </string> <key>IBFramework Version</key> <string>446.1</string> <key>IBLockedObjects</key> <array/> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> <key>IBSystem Version</key> <string>8P135</string> </dict> Modified: trunk/Dutch.lproj/PreferenceWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/InitialUserDefaults.plist =================================================================== --- trunk/InitialUserDefaults.plist 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/InitialUserDefaults.plist 2007-04-28 17:13:26 UTC (rev 1924) @@ -121,8 +121,10 @@ </data> <key>SKAutoCheckFileUpdate</key> <false/> + <key>SKTeXEditorPreset</key> + <string>TextMate</string> <key>SKTeXEditorCommand</key> - <string>/Applications/TextMate.app/Contents/Resources/mate</string> + <string>mate</string> <key>SKTeXEditorArguments</key> <string>-l %line "%file"</string> <key>SUCheckAtStartup</key> @@ -177,6 +179,7 @@ <key>sync</key> <array> <string>SKAutoCheckFileUpdate</string> + <string>SKTeXEditorPreset</string> <string>SKTeXEditorCommand</string> <string>SKTeXEditorArguments</string> </array> Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/SKPDFView.m 2007-04-28 17:13:26 UTC (rev 1924) @@ -2684,9 +2684,23 @@ if ([synchronizer getLine:&line file:&file forLocation:location inRect:rect atPageIndex:pageIndex] && [[NSFileManager defaultManager] fileExistsAtPath:file]) { + NSString *editorPreset = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorPresetKey]; NSString *editorCmd = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorCommandKey]; NSMutableString *cmdString = [[[[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorArgumentsKey] mutableCopy] autorelease]; + if ([editorPreset isEqualToString:@""] == NO) { + NSString *appPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:editorPreset]; + NSString *toolPath = appPath ? [NSBundle pathForResource:editorCmd ofType:nil inDirectory:appPath] : nil; + if (toolPath) { + editorCmd = toolPath; + } else { + // Emacs has its tool in Emacs.app/Contents/MacOS/bin/ + toolPath = [[[[NSBundle bundleWithPath:appPath] executablePath] stringByAppendingPathComponent:@"bin"] stringByAppendingPathComponent:cmdString]; + if ([[NSFileManager defaultManager] isExecutableFileAtPath:toolPath]) + editorCmd = toolPath; + } + } + [cmdString replaceOccurrencesOfString:@"%file" withString:file options:NSLiteralSearch range: NSMakeRange(0, [cmdString length] )]; [cmdString replaceOccurrencesOfString:@"%line" withString:[NSString stringWithFormat:@"%d", line] options:NSLiteralSearch range:NSMakeRange(0, [cmdString length])]; [cmdString insertString:@" " atIndex:0]; Modified: trunk/SKPreferenceController.m =================================================================== --- trunk/SKPreferenceController.m 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/SKPreferenceController.m 2007-04-28 17:13:26 UTC (rev 1924) @@ -43,9 +43,9 @@ #import <Sparkle/Sparkle.h> static float SKDefaultFontSizes[] = {8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 16.0, 18.0, 20.0, 24.0, 28.0, 32.0, 48.0, 64.0}; -static NSString *SKTeXEditors[] = {@"TextMate", @"BBEdit", @"TextWrangler", @"Emacs"}; -static NSString *SKTeXEditorCommands[] = {@"mate", @"bbedit", @"edit", @"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"}; -static NSString *SKTeXEditorArguments[] = {@"-l %line \"%file\"", @"+%line \"%file\"", @"+%line \"%file\"", @"--no-wait +%line \"%file\""}; +static NSString *SKTeXEditors[] = {@"TextMate", @"BBEdit", @"TextWrangler", @"Emacs", @"Aquamacs Emacs"}; +static NSString *SKTeXEditorCommands[] = {@"mate", @"bbedit", @"edit", @"emacsclient", @"emacsclient"}; +static NSString *SKTeXEditorArguments[] = {@"-l %line \"%file\"", @"+%line \"%file\"", @"+%line \"%file\"", @"--no-wait +%line \"%file\"", @"--no-wait +%line \"%file\""}; @implementation SKPreferenceController @@ -100,14 +100,13 @@ } - (void)windowDidLoad { - NSString *editorCmd = [[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorCommandKey]; - NSString *editorArgs = [[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorArgumentsKey]; + NSString *editorPreset = [[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorPresetKey]; int i = sizeof(SKTeXEditors) / sizeof(NSString *); int index = -1; while (i--) { [texEditorPopUpButton insertItemWithTitle:SKTeXEditors[i] atIndex:0]; - if ([SKTeXEditorCommands[i] isEqualToString:editorCmd] && [SKTeXEditorArguments[i] isEqualToString:editorArgs]) + if ([SKTeXEditors[i] isEqualToString:editorPreset]) index = i; } @@ -168,10 +167,12 @@ - (IBAction)changeTeXEditorPreset:(id)sender { int index = [sender indexOfSelectedItem]; if (index < [sender numberOfItems] - 1) { + [[NSUserDefaults standardUserDefaults] setObject:[sender titleOfSelectedItem] forKey:SKTeXEditorPresetKey]; [[NSUserDefaults standardUserDefaults] setObject:SKTeXEditorCommands[index] forKey:SKTeXEditorCommandKey]; [[NSUserDefaults standardUserDefaults] setObject:SKTeXEditorArguments[index] forKey:SKTeXEditorArgumentsKey]; [self setCustomTeXEditor:NO]; } else { + [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:SKTeXEditorPresetKey]; [self setCustomTeXEditor:YES]; } } Modified: trunk/SKStringConstants.h =================================================================== --- trunk/SKStringConstants.h 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/SKStringConstants.h 2007-04-28 17:13:26 UTC (rev 1924) @@ -38,6 +38,7 @@ extern NSString *SKAutoCheckFileUpdateKey; +extern NSString *SKTeXEditorPresetKey; extern NSString *SKTeXEditorArgumentsKey; extern NSString *SKTeXEditorCommandKey; extern NSString *SKBackgroundColorKey; Modified: trunk/SKStringConstants.m =================================================================== --- trunk/SKStringConstants.m 2007-04-28 16:23:07 UTC (rev 1923) +++ trunk/SKStringConstants.m 2007-04-28 17:13:26 UTC (rev 1924) @@ -39,6 +39,7 @@ #import "SKStringConstants.h" NSString *SKAutoCheckFileUpdateKey = @"SKAutoCheckFileUpdate"; +NSString *SKTeXEditorPresetKey = @"SKTeXEditorPreset"; NSString *SKTeXEditorArgumentsKey = @"SKTeXEditorArguments"; NSString *SKTeXEditorCommandKey = @"SKTeXEditorCommand"; NSString *SKBackgroundColorKey = @"SKBackgroundColor"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-28 16:23:10
|
Revision: 1923 http://skim-app.svn.sourceforge.net/skim-app/?rev=1923&view=rev Author: hofman Date: 2007-04-28 09:23:07 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Fix lookup in dictionary action. The URL needs has three slashes (really). Only add the menu item when there is a selection. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-28 12:45:44 UTC (rev 1922) +++ trunk/SKPDFView.m 2007-04-28 16:23:07 UTC (rev 1923) @@ -845,7 +845,7 @@ if (nil == text) NSBeep(); else - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[@"dict://" stringByAppendingString:text]]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[@"dict:///" stringByAppendingString:text]]]; } - (NSMenu *)menuForEvent:(NSEvent *)theEvent { @@ -981,7 +981,7 @@ long version; OSStatus err = Gestalt(gestaltSystemVersion, &version); - if (noErr == err && version < 0x00001050) { + if ([[self currentSelection] string] && noErr == err && version < 0x00001050) { [menu addItem:[NSMenuItem separatorItem]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-28 12:45:55
|
Revision: 1922 http://skim-app.svn.sourceforge.net/skim-app/?rev=1922&view=rev Author: hofman Date: 2007-04-28 05:45:44 -0700 (Sat, 28 Apr 2007) Log Message: ----------- return error strings when script errors occur Modified Paths: -------------- trunk/SKApplication.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-28 12:32:17 UTC (rev 1921) +++ trunk/SKApplication.m 2007-04-28 12:45:44 UTC (rev 1922) @@ -123,10 +123,14 @@ [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; } - } else + } else { [command setScriptErrorNumber:NSArgumentsWrongScriptError]; - } else + [command setScriptErrorString:@"File does not exist."]; + } + } else { [command setScriptErrorNumber:NSArgumentsWrongScriptError]; + [command setScriptErrorString:@"File argument is not a file."]; + } return nil; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-28 12:32:23
|
Revision: 1921 http://skim-app.svn.sourceforge.net/skim-app/?rev=1921&view=rev Author: hofman Date: 2007-04-28 05:32:17 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/SKApplication.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-28 09:58:12 UTC (rev 1920) +++ trunk/SKApplication.m 2007-04-28 12:32:17 UTC (rev 1921) @@ -106,9 +106,9 @@ if ([file isKindOfClass:[NSURL class]] && [source isKindOfClass:[NSURL class]]) { source = [source path]; - if ([[[source pathExtension] pathExtension] length] == 0) + if ([[source pathExtension] length] == 0) source = [source stringByAppendingPathExtension:@"tex"]; - else if ([[[source pathExtension] pathExtension] caseInsensitiveCompare:@"tex"] == NO) + else if ([[source pathExtension] caseInsensitiveCompare:@"tex"] == NO) source = [[source stringByDeletingPathExtension] stringByAppendingPathExtension:@"tex"]; if ([[NSFileManager defaultManager] fileExistsAtPath:[file path]] && [[NSFileManager defaultManager] fileExistsAtPath:source]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-28 09:58:14
|
Revision: 1920 http://skim-app.svn.sourceforge.net/skim-app/?rev=1920&view=rev Author: hofman Date: 2007-04-28 02:58:12 -0700 (Sat, 28 Apr 2007) Log Message: ----------- add some comments to script and simplify extension replacement Modified Paths: -------------- trunk/displayline Modified: trunk/displayline =================================================================== --- trunk/displayline 2007-04-27 21:15:52 UTC (rev 1919) +++ trunk/displayline 2007-04-28 09:58:12 UTC (rev 1920) @@ -4,14 +4,17 @@ # # Usage: displayline LINE PDFFILE [TEXSOURCEFILE] +# get arguments, expand tilde in paths line=$1 file="${2/#~/$HOME}" if [ $# -gt 2 ]; then source="${3/#~/$HOME}" else -source="${file/%.pdf/.tex}" +# derive source file from pdf file +source="${file%.pdf}.tex" fi +# expand relative paths if [ "${file:0:1}" != "/" ]; then file="${PWD}/${file}" fi @@ -19,4 +22,5 @@ source="${PWD}/${source}" fi +# call the AppleScript /usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 21:15:53
|
Revision: 1919 http://skim-app.svn.sourceforge.net/skim-app/?rev=1919&view=rev Author: hofman Date: 2007-04-27 14:15:52 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Update localizable strings Modified Paths: -------------- trunk/Dutch.lproj/Localizable.strings trunk/English.lproj/Localizable.strings trunk/Italian.lproj/Localizable.strings Modified: trunk/Dutch.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/English.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/Localizable.strings =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 19:03:12
|
Revision: 1918 http://skim-app.svn.sourceforge.net/skim-app/?rev=1918&view=rev Author: hofman Date: 2007-04-27 12:03:10 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Do some more validation and cleaning of URLs passed through applescript open command. Modified Paths: -------------- trunk/SKApplication.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-27 17:25:35 UTC (rev 1917) +++ trunk/SKApplication.m 2007-04-27 19:03:10 UTC (rev 1918) @@ -95,26 +95,38 @@ if ([file isKindOfClass:[NSArray class]]) file = [file lastObject]; + if ([file isKindOfClass:[NSString class]]) + file = [NSURL fileURLWithPath:file]; if (source == nil) source = file; + if ([source isKindOfClass:[NSString class]]) + source = [NSURL fileURLWithPath:source]; - if ([file isKindOfClass:[NSURL class]] && [source isKindOfClass:[NSURL class]] && - [[NSFileManager defaultManager] fileExistsAtPath:[source path]]) { + if ([file isKindOfClass:[NSURL class]] && [source isKindOfClass:[NSURL class]]) { - SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:file display:YES error:NULL]; - unsigned int pageIndex; - NSPoint point; + source = [source path]; + if ([[[source pathExtension] pathExtension] length] == 0) + source = [source stringByAppendingPathExtension:@"tex"]; + else if ([[[source pathExtension] pathExtension] caseInsensitiveCompare:@"tex"] == NO) + source = [[source stringByDeletingPathExtension] stringByAppendingPathExtension:@"tex"]; - if ([document respondsToSelector:@selector(synchronizer)] && [document respondsToSelector:@selector(pdfView)] && - [[document synchronizer] getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:[source path]]) { + if ([[NSFileManager defaultManager] fileExistsAtPath:[file path]] && [[NSFileManager defaultManager] fileExistsAtPath:source]) { - [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; - } - - } else { + SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:file display:YES error:NULL]; + unsigned int pageIndex; + NSPoint point; + + if ([document respondsToSelector:@selector(synchronizer)] && [document respondsToSelector:@selector(pdfView)] && + [[document synchronizer] getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:source]) { + + [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; + } + + } else + [command setScriptErrorNumber:NSArgumentsWrongScriptError]; + } else [command setScriptErrorNumber:NSArgumentsWrongScriptError]; - } return nil; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 17:25:36
|
Revision: 1917 http://skim-app.svn.sourceforge.net/skim-app/?rev=1917&view=rev Author: hofman Date: 2007-04-27 10:25:35 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Do some checks when executing open command. Modified Paths: -------------- trunk/SKApplication.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-27 17:11:02 UTC (rev 1916) +++ trunk/SKApplication.m 2007-04-27 17:25:35 UTC (rev 1917) @@ -99,16 +99,21 @@ if (source == nil) source = file; - if ([file isKindOfClass:[NSURL class]] == NO || [source isKindOfClass:[NSURL class]] == NO) { - [command setScriptErrorNumber:NSArgumentsWrongScriptError]; - } else if ([[NSFileManager defaultManager] fileExistsAtPath:[source path]]) { + if ([file isKindOfClass:[NSURL class]] && [source isKindOfClass:[NSURL class]] && + [[NSFileManager defaultManager] fileExistsAtPath:[source path]]) { + SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:file display:YES error:NULL]; - SKPDFSynchronizer *synchronizer = [document synchronizer]; unsigned int pageIndex; NSPoint point; - if ([synchronizer getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:[source path]]) + if ([document respondsToSelector:@selector(synchronizer)] && [document respondsToSelector:@selector(pdfView)] && + [[document synchronizer] getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:[source path]]) { + [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; + } + + } else { + [command setScriptErrorNumber:NSArgumentsWrongScriptError]; } return nil; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 17:11:08
|
Revision: 1916 http://skim-app.svn.sourceforge.net/skim-app/?rev=1916&view=rev Author: hofman Date: 2007-04-27 10:11:02 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Fix pdfsync support. Files are passed to the script command as an array. Wrong syntax for argument substring in bash. Non-empty 4-char code for script argument. Modified Paths: -------------- trunk/SKApplication.m trunk/Skim.sdef trunk/displayline Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-27 15:43:34 UTC (rev 1915) +++ trunk/SKApplication.m 2007-04-27 17:11:02 UTC (rev 1916) @@ -89,10 +89,13 @@ id file = [command directParameter]; id lineNumber = [args objectForKey:@"line"]; id source = [args objectForKey:@"source"]; - - if (lineNumber == nil) + + if (lineNumber == nil || ([file isKindOfClass:[NSArray class]] && [file count] != 1)) return [super handleOpenScriptCommand:command]; + if ([file isKindOfClass:[NSArray class]]) + file = [file lastObject]; + if (source == nil) source = file; Modified: trunk/Skim.sdef =================================================================== --- trunk/Skim.sdef 2007-04-27 15:43:34 UTC (rev 1915) +++ trunk/Skim.sdef 2007-04-27 17:11:02 UTC (rev 1916) @@ -154,7 +154,7 @@ <direct-parameter description="The file(s) to be opened."> <type type="file" list="yes"/> </direct-parameter> - <parameter name="at TeX line" code="" type="integer" optional="yes" + <parameter name="at TeX line" code="Line" type="integer" optional="yes" description="Go to a location in the PDF corresponding to the line in a TeX source file."> <cocoa key="line"/> </parameter> Modified: trunk/displayline =================================================================== --- trunk/displayline 2007-04-27 15:43:34 UTC (rev 1915) +++ trunk/displayline 2007-04-27 17:11:02 UTC (rev 1916) @@ -6,17 +6,17 @@ line=$1 file="${2/#~/$HOME}" -if [ $# -gt 3 ]; then +if [ $# -gt 2 ]; then source="${3/#~/$HOME}" else source="${file/%.pdf/.tex}" fi -if [ "${file:-1}" != "/" ]; then +if [ "${file:0:1}" != "/" ]; then file="${PWD}/${file}" fi -if [ "${source:-1}" != "/" ]; then -file="${PWD}/${source}" +if [ "${source:0:1}" != "/" ]; then +source="${PWD}/${source}" fi -/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open file POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" +/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 15:43:35
|
Revision: 1915 http://skim-app.svn.sourceforge.net/skim-app/?rev=1915&view=rev Author: hofman Date: 2007-04-27 08:43:34 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Expand file names passed to the script, and pass them as POSIX file to the script. Modified Paths: -------------- trunk/displayline Modified: trunk/displayline =================================================================== --- trunk/displayline 2007-04-27 15:39:50 UTC (rev 1914) +++ trunk/displayline 2007-04-27 15:43:34 UTC (rev 1915) @@ -5,11 +5,18 @@ # Usage: displayline LINE PDFFILE [TEXSOURCEFILE] line=$1 -file="$2" +file="${2/#~/$HOME}" if [ $# -gt 3 ]; then -source="$3" +source="${3/#~/$HOME}" else -source="$2" +source="${file/%.pdf/.tex}" fi -/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open file display POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" +if [ "${file:-1}" != "/" ]; then +file="${PWD}/${file}" +fi +if [ "${source:-1}" != "/" ]; then +file="${PWD}/${source}" +fi + +/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open file POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 15:39:56
|
Revision: 1914 http://skim-app.svn.sourceforge.net/skim-app/?rev=1914&view=rev Author: hofman Date: 2007-04-27 08:39:50 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Remove custom AS command class. Use custom arguments for the 'open' command instead. Handle handleOpenScriptCommand in our Application subclass. Modified Paths: -------------- trunk/SKApplication.m trunk/Skim.sdef trunk/Skim.xcodeproj/project.pbxproj trunk/displayline Removed Paths: ------------- trunk/SKDisplayTeXLineCommand.h trunk/SKDisplayTeXLineCommand.m Modified: trunk/SKApplication.m =================================================================== --- trunk/SKApplication.m 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/SKApplication.m 2007-04-27 15:39:50 UTC (rev 1914) @@ -40,9 +40,16 @@ #import "SKStringConstants.h" #import "SKMainWindowController.h" #import "SKDocument.h" +#import "SKPDFSynchronizer.h" +#import "SKPDFView.h" NSString *SKApplicationWillTerminateNotification = @"SKApplicationWillTerminateNotification"; +@interface NSApplication (NSApplicationPrivateDeclarations) +- (id)handleOpenScriptCommand:(NSScriptCommand *)command; +@end + + @interface NSMenu (SKExtensions) - (int)indexOfItemWithTarget:(id)target; @end @@ -77,6 +84,33 @@ [super terminate:sender]; } +- (id)handleOpenScriptCommand:(NSScriptCommand *)command { + NSDictionary *args = [command evaluatedArguments]; + id file = [command directParameter]; + id lineNumber = [args objectForKey:@"line"]; + id source = [args objectForKey:@"source"]; + + if (lineNumber == nil) + return [super handleOpenScriptCommand:command]; + + if (source == nil) + source = file; + + if ([file isKindOfClass:[NSURL class]] == NO || [source isKindOfClass:[NSURL class]] == NO) { + [command setScriptErrorNumber:NSArgumentsWrongScriptError]; + } else if ([[NSFileManager defaultManager] fileExistsAtPath:[source path]]) { + SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:file display:YES error:NULL]; + SKPDFSynchronizer *synchronizer = [document synchronizer]; + unsigned int pageIndex; + NSPoint point; + + if ([synchronizer getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:[source path]]) + [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; + } + + return nil; +} + - (void)reorganizeWindowsItem:(NSWindow *)aWindow { NSMenu *windowsMenu = [self windowsMenu]; NSWindowController *windowController = [aWindow windowController]; Deleted: trunk/SKDisplayTeXLineCommand.h =================================================================== --- trunk/SKDisplayTeXLineCommand.h 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/SKDisplayTeXLineCommand.h 2007-04-27 15:39:50 UTC (rev 1914) @@ -1,43 +0,0 @@ -// -// SKDisplayLineCommand.h -// Skim -// -// Created by Christiaan Hofman on 4/22/07. -/* - This software is Copyright (c) 2007 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <Cocoa/Cocoa.h> - - -@interface SKDisplayTeXLineCommand : NSScriptCommand -@end Deleted: trunk/SKDisplayTeXLineCommand.m =================================================================== --- trunk/SKDisplayTeXLineCommand.m 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/SKDisplayTeXLineCommand.m 2007-04-27 15:39:50 UTC (rev 1914) @@ -1,99 +0,0 @@ -// -// SKDisplayLineCommand.m -// Skim -// -// Created by Christiaan Hofman on 4/22/07. -/* - This software is Copyright (c) 2007 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SKDisplayTeXLineCommand.h" -#import "SKDocument.h" -#import "SKPDFSynchronizer.h" -#import "SKPDFView.h" - - -@implementation SKDisplayTeXLineCommand - -- (id)performDefaultImplementation { - id lineNumber = [self directParameter]; - NSDictionary *args = [self evaluatedArguments]; - id file = [args objectForKey:@"file"]; - id source = [args objectForKey:@"source"]; - NSURL *fileURL = nil; - - if (source == nil) - source = file; - - if ([source isKindOfClass:[NSURL class]]) { - source = [source path]; - } else if ([source isKindOfClass:[NSString class]]) { - if ([source hasPrefix:@"file://"]) - source = [[NSURL URLWithString:source] path]; - else - source = [source stringByStandardizingPath]; - } - - if ([[source pathExtension] length] == 0) - source = [source stringByAppendingPathExtension:@"tex"]; - else if ([[source pathExtension] caseInsensitiveCompare:@"tex"] != NSOrderedSame) - source = [[source stringByDeletingPathExtension] stringByAppendingPathExtension:@"tex"]; - - if ([file isKindOfClass:[NSURL class]]) { - fileURL = file; - } else if ([source isKindOfClass:[NSString class]]) { - if ([file hasPrefix:@"file://"]) - fileURL = [NSURL URLWithString:file]; - else - fileURL = [NSURL fileURLWithPath:[file stringByStandardizingPath]]; - } - - file = [fileURL path]; - if ([[file pathExtension] length] == 0) - fileURL = [NSURL fileURLWithPath:[file stringByAppendingPathExtension:@"pdf"]]; - else if ([[file pathExtension] caseInsensitiveCompare:@"pdf"] != NSOrderedSame) - fileURL = [NSURL fileURLWithPath:[[file stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdf"]]; - - if (fileURL && source && [[NSFileManager defaultManager] fileExistsAtPath:source]) { - SKDocument *document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:YES error:NULL]; - SKPDFSynchronizer *synchronizer = [document synchronizer]; - unsigned int pageIndex; - NSPoint point; - - if ([synchronizer getPageIndex:&pageIndex location:&point forLine:[lineNumber intValue] inFile:source]) - [[document pdfView] displayLineAtPoint:point inPageAtIndex:pageIndex]; - } - - return nil; -} - -@end Modified: trunk/Skim.sdef =================================================================== --- trunk/Skim.sdef 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/Skim.sdef 2007-04-27 15:39:50 UTC (rev 1914) @@ -154,6 +154,14 @@ <direct-parameter description="The file(s) to be opened."> <type type="file" list="yes"/> </direct-parameter> + <parameter name="at TeX line" code="" type="integer" optional="yes" + description="Go to a location in the PDF corresponding to the line in a TeX source file."> + <cocoa key="line"/> + </parameter> + <parameter name="from source" type="file" code="SrcF" optional="yes" + description="The TeX source file. By default this is derived from the file."> + <cocoa key="source"/> + </parameter> <!-- According to TN2106, 'open' should return the resulting document object. However, the Cocoa implementation does not do this yet. @@ -589,26 +597,6 @@ </direct-parameter> </command> - <command name="display TeX line" code="SKIMDTLn" - description="Open the file, and go to a location in the PDF corresponding to the line in a TeX file."> - <cocoa class="SKDisplayTeXLineCommand"/> - <direct-parameter type="integer" - description="The line number in the TeX file."> - </direct-parameter> - <parameter name="in" code="File" optional="no" - description="The PDF file"> - <type type="text"/> - <type type="file"/> - <cocoa key="file"/> - </parameter> - <parameter name="from source" code="SrcF" optional="yes" - description="The TeX source file. By default this is derived from the pdf file."> - <type type="text"/> - <type type="file"/> - <cocoa key="source"/> - </parameter> - </command> - </suite> </dictionary> Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-04-27 15:39:50 UTC (rev 1914) @@ -65,7 +65,6 @@ CE15832F0BA0740000D5B03F /* UnderlineNoteAdorn.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE15832B0BA073FF00D5B03F /* UnderlineNoteAdorn.tiff */; }; CE1E25680BDA61E80011D9DD /* ReadNotesAccessoryView.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE1E25660BDA61E80011D9DD /* ReadNotesAccessoryView.nib */; }; CE1E2B290BDAB6180011D9DD /* SKPDFSynchronizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */; }; - CE1E2E600BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E2E5E0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m */; }; CE1E2F130BDB86A20011D9DD /* displayline in Resources */ = {isa = PBXBuildFile; fileRef = CE1E2F120BDB86A10011D9DD /* displayline */; }; CE1E301D0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E301B0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m */; }; CE1E30290BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E30270BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m */; }; @@ -302,8 +301,6 @@ CE1E259F0BDA6E570011D9DD /* Italian */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Italian; path = Italian.lproj/ReadNotesAccessoryView.nib; sourceTree = "<group>"; }; CE1E2B260BDAB6180011D9DD /* SKPDFSynchronizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKPDFSynchronizer.h; sourceTree = "<group>"; }; CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKPDFSynchronizer.m; sourceTree = "<group>"; }; - CE1E2E5D0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDisplayTeXLineCommand.h; sourceTree = "<group>"; }; - CE1E2E5E0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDisplayTeXLineCommand.m; sourceTree = "<group>"; }; CE1E2F120BDB86A10011D9DD /* displayline */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = displayline; sourceTree = "<group>"; }; CE1E301A0BDB9D5C0011D9DD /* NSScanner_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScanner_SKExtensions.h; sourceTree = "<group>"; }; CE1E301B0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSScanner_SKExtensions.m; sourceTree = "<group>"; }; @@ -782,8 +779,6 @@ CE0464A10B84E3E400C11E4A /* OBUtilities.m */, CE1E2B260BDAB6180011D9DD /* SKPDFSynchronizer.h */, CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */, - CE1E2E5D0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.h */, - CE1E2E5E0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m */, ); name = Miscellaneous; sourceTree = "<group>"; @@ -1155,7 +1150,6 @@ CE4294A30BBD29120016FDC2 /* SKReadingBar.m in Sources */, CEE106150BCBB72C00BF2D3E /* SKNotesDocument.m in Sources */, CE1E2B290BDAB6180011D9DD /* SKPDFSynchronizer.m in Sources */, - CE1E2E600BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m in Sources */, CE1E301D0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m in Sources */, CE1E30290BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m in Sources */, CE4972510BDE898F00D7F1D2 /* SKMainWindow.m in Sources */, Modified: trunk/displayline =================================================================== --- trunk/displayline 2007-04-27 11:54:43 UTC (rev 1913) +++ trunk/displayline 2007-04-27 15:39:50 UTC (rev 1914) @@ -12,4 +12,4 @@ source="$2" fi -/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "display TeX line "${line}" in \""${file}"\" from source \""${source}"\"" -e "end tell" +/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "open file display POSIX file \""${file}"\" at TeX line "${line}" from source POSIX file \""${source}"\"" -e "end tell" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 11:54:46
|
Revision: 1913 http://skim-app.svn.sourceforge.net/skim-app/?rev=1913&view=rev Author: hofman Date: 2007-04-27 04:54:43 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Show hover window quicker Modified Paths: -------------- trunk/SKPDFHoverWindow.m Modified: trunk/SKPDFHoverWindow.m =================================================================== --- trunk/SKPDFHoverWindow.m 2007-04-27 09:56:39 UTC (rev 1912) +++ trunk/SKPDFHoverWindow.m 2007-04-27 11:54:43 UTC (rev 1913) @@ -346,7 +346,7 @@ [annotation release]; annotation = [note retain]; - NSDate *date = [NSDate dateWithTimeIntervalSinceNow:[self isVisible] ? 0.1 : 1.5]; + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:[self isVisible] ? 0.1 : 1.0]; timer = [[NSTimer alloc] initWithFireDate:date interval:0 target:self selector:@selector(timerFired:) userInfo:NULL repeats:NO]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-27 09:56:43
|
Revision: 1912 http://skim-app.svn.sourceforge.net/skim-app/?rev=1912&view=rev Author: hofman Date: 2007-04-27 02:56:39 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Change extension in description. Modified Paths: -------------- trunk/displayline Modified: trunk/displayline =================================================================== --- trunk/displayline 2007-04-27 02:56:28 UTC (rev 1911) +++ trunk/displayline 2007-04-27 09:56:39 UTC (rev 1912) @@ -1,8 +1,8 @@ #!/bin/sh -# displayline.sh (Skim) +# displayline (Skim) # -# Usage: displayline.sh LINE PDFFILE [TEXSOURCEFILE] +# Usage: displayline LINE PDFFILE [TEXSOURCEFILE] line=$1 file="$2" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-04-27 02:56:29
|
Revision: 1911 http://skim-app.svn.sourceforge.net/skim-app/?rev=1911&view=rev Author: amaxwell Date: 2007-04-26 19:56:28 -0700 (Thu, 26 Apr 2007) Log Message: ----------- support for looking up the current selection in Dictionary Modified Paths: -------------- trunk/BDSKZoomablePDFView.m trunk/SKPDFView.m Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2007-04-27 02:30:16 UTC (rev 1910) +++ trunk/BDSKZoomablePDFView.m 2007-04-27 02:56:28 UTC (rev 1911) @@ -164,6 +164,15 @@ [[NSSavePanel savePanel] beginSheetForDirectory:nil file:(name ? name : NSLocalizedString(@"Untitled.pdf", @"Default file name for saved PDF")) modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(saveDocumentSheetDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } +- (void)lookUpCurrentSelectionInDictionary:(id)sender; +{ + NSString *text = [[self currentSelection] string]; + if (nil == text) + NSBeep(); + else + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[@"dict://" stringByAppendingString:text]]]; +} + - (NSMenu *)menuForEvent:(NSEvent *)theEvent; { NSMenu *menu = [super menuForEvent:theEvent]; @@ -182,6 +191,20 @@ [menu addItem:item]; [item release]; + if ([self currentSelection]) { + long version; + OSStatus err = Gestalt(gestaltSystemVersion, &version); + + if (noErr == err && version < 0x00001050) { + + [menu addItem:[NSMenuItem separatorItem]]; + + item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:NSLocalizedString(@"Look Up in Dictionary", @"") action:@selector(lookUpCurrentSelectionInDictionary:) keyEquivalent:@""]; + [menu addItem:item]; + [item release]; + } + } + [menu addItem:[NSMenuItem separatorItem]]; item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:[NSLocalizedString(@"Save PDF As", @"Menu item title") stringByAppendingFormat:@"%C", 0x2026] action:@selector(saveDocumentAs:) keyEquivalent:@""]; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-27 02:30:16 UTC (rev 1910) +++ trunk/SKPDFView.m 2007-04-27 02:56:28 UTC (rev 1911) @@ -839,6 +839,15 @@ [cursor set]; } +- (void)lookUpCurrentSelectionInDictionary:(id)sender; +{ + NSString *text = [[self currentSelection] string]; + if (nil == text) + NSBeep(); + else + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[@"dict://" stringByAppendingString:text]]]; +} + - (NSMenu *)menuForEvent:(NSEvent *)theEvent { NSMenu *menu = [super menuForEvent:theEvent]; NSMenu *submenu; @@ -969,6 +978,17 @@ } } + long version; + OSStatus err = Gestalt(gestaltSystemVersion, &version); + + if (noErr == err && version < 0x00001050) { + + [menu addItem:[NSMenuItem separatorItem]]; + + item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:NSLocalizedString(@"Look Up in Dictionary", @"") action:@selector(lookUpCurrentSelectionInDictionary:) keyEquivalent:@""]; + [menu addItem:item]; + [item release]; + } } return menu; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-04-27 02:30:26
|
Revision: 1910 http://skim-app.svn.sourceforge.net/skim-app/?rev=1910&view=rev Author: amaxwell Date: 2007-04-26 19:30:16 -0700 (Thu, 26 Apr 2007) Log Message: ----------- rename function to avoid using Apple's prefix, and declare as static Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-26 21:45:24 UTC (rev 1909) +++ trunk/SKPDFView.m 2007-04-27 02:30:16 UTC (rev 1910) @@ -61,7 +61,7 @@ NSString *SKSkimNotePboardType = @"SKSkimNotePboardType"; -CGMutablePathRef CGCreatePathWithRoundRectInRect(CGRect rect, float radius); +static CGMutablePathRef SKCGCreatePathWithRoundRectInRect(CGRect rect, float radius); @interface PDFDocument (SKExtensions) - (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection toPage:(PDFPage *)page atPoint:(NSPoint)point; @@ -242,7 +242,7 @@ float color[4] = { 0.0, 0.0, 0.0, 1.0 }; NSRect rect = NSInsetRect(NSIntegralRect(bounds), 0.5 * lineWidth, 0.5 * lineWidth); if (isLink) { - CGMutablePathRef path = CGCreatePathWithRoundRectInRect(*(CGRect *)&rect, 2.0); + CGMutablePathRef path = SKCGCreatePathWithRoundRectInRect(*(CGRect *)&rect, 2.0); color[3] = 0.1; CGContextSetFillColor(context, color); CGContextBeginPath(context); @@ -2682,7 +2682,7 @@ #pragma mark Core Graphics extension -CGMutablePathRef CGCreatePathWithRoundRectInRect(CGRect rect, float radius) +static CGMutablePathRef SKCGCreatePathWithRoundRectInRect(CGRect rect, float radius) { // Make sure radius doesn't exceed a maximum size to avoid artifacts: radius = fmin(radius, 0.5f * fmin(rect.size.width, rect.size.height)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-26 21:45:26
|
Revision: 1909 http://skim-app.svn.sourceforge.net/skim-app/?rev=1909&view=rev Author: hofman Date: 2007-04-26 14:45:24 -0700 (Thu, 26 Apr 2007) Log Message: ----------- Check some validity after parsing pdfsync file. Modified Paths: -------------- trunk/SKPDFSynchronizer.m Modified: trunk/SKPDFSynchronizer.m =================================================================== --- trunk/SKPDFSynchronizer.m 2007-04-26 21:18:40 UTC (rev 1908) +++ trunk/SKPDFSynchronizer.m 2007-04-26 21:45:24 UTC (rev 1909) @@ -165,10 +165,8 @@ [scanner scanCharactersFromSet:[NSCharacterSet newlineCharacterSet] intoString:NULL]; - while ([scanner isAtEnd] == NO) { + while ([scanner scanCharacter:&ch]) { - [scanner scanCharacter:&ch]; - if (ch == 'l') { if ([scanner scanInt:&recordIndex] && [scanner scanInt:&line]) { // we ignore the column @@ -236,7 +234,7 @@ NSString *foundFile = nil; NSDictionary *record = nil; - if (pageIndex >= [pages count] && [self parsePdfsyncFileIfNeeded]) { + if ([self parsePdfsyncFileIfNeeded] && pageIndex < [pages count]) { NSDictionary *beforeRecord = nil; NSDictionary *afterRecord = nil; @@ -306,7 +304,7 @@ NSPoint foundPoint = NSZeroPoint; NSDictionary *record = nil; - if (file && [lines objectForKey:file] && [self parsePdfsyncFileIfNeeded]) { + if (file && [self parsePdfsyncFileIfNeeded] && [lines objectForKey:file]) { NSDictionary *beforeRecord = nil; NSDictionary *afterRecord = nil; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-26 21:18:55
|
Revision: 1908 http://skim-app.svn.sourceforge.net/skim-app/?rev=1908&view=rev Author: hofman Date: 2007-04-26 14:18:40 -0700 (Thu, 26 Apr 2007) Log Message: ----------- avoid early return and always set values of pointer arguments. Modified Paths: -------------- trunk/SKPDFSynchronizer.m Modified: trunk/SKPDFSynchronizer.m =================================================================== --- trunk/SKPDFSynchronizer.m 2007-04-26 12:58:53 UTC (rev 1907) +++ trunk/SKPDFSynchronizer.m 2007-04-26 21:18:40 UTC (rev 1908) @@ -232,134 +232,127 @@ } - (BOOL)getLine:(int *)line file:(NSString **)file forLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned int)pageIndex { - if ([self parsePdfsyncFileIfNeeded] == NO) - return NO; - if (pageIndex >= [pages count]) - return NO; - - NSDictionary *beforeRecord = nil; - NSDictionary *afterRecord = nil; - NSMutableDictionary *atRecords = [NSMutableDictionary dictionary]; - NSEnumerator *recordEnum = [[pages objectAtIndex:pageIndex] objectEnumerator]; + int foundLine = -1; + NSString *foundFile = nil; NSDictionary *record = nil; - while (record = [recordEnum nextObject]) { - if ([record objectForKey:@"line"] == nil) - continue; - float x = [[record objectForKey:@"x"] floatValue]; - float y = [[record objectForKey:@"y"] floatValue]; - if (y > NSMaxY(rect)) { - beforeRecord = record; - } else if (y < NSMinY(rect)) { - afterRecord = record; - break; - } else if (x < NSMinX(rect)) { - beforeRecord = record; - } else if (x > NSMaxX(rect)) { - afterRecord = record; - break; - } else { - [atRecords setObject:record forKey:[NSNumber numberWithFloat:fabs(x - point.x)]]; + if (pageIndex >= [pages count] && [self parsePdfsyncFileIfNeeded]) { + + NSDictionary *beforeRecord = nil; + NSDictionary *afterRecord = nil; + NSMutableDictionary *atRecords = [NSMutableDictionary dictionary]; + NSEnumerator *recordEnum = [[pages objectAtIndex:pageIndex] objectEnumerator]; + + while (record = [recordEnum nextObject]) { + if ([record objectForKey:@"line"] == nil) + continue; + float x = [[record objectForKey:@"x"] floatValue]; + float y = [[record objectForKey:@"y"] floatValue]; + if (y > NSMaxY(rect)) { + beforeRecord = record; + } else if (y < NSMinY(rect)) { + afterRecord = record; + break; + } else if (x < NSMinX(rect)) { + beforeRecord = record; + } else if (x > NSMaxX(rect)) { + afterRecord = record; + break; + } else { + [atRecords setObject:record forKey:[NSNumber numberWithFloat:fabs(x - point.x)]]; + } } - } - - record = nil; - if ([atRecords count]) { - NSNumber *nearest = [[[atRecords allKeys] sortedArrayUsingSelector:@selector(compare:)] objectAtIndex:0]; - record = [atRecords objectForKey:nearest]; - } else if (beforeRecord && afterRecord) { - float beforeX = [[beforeRecord objectForKey:@"x"] floatValue]; - float beforeY = [[beforeRecord objectForKey:@"y"] floatValue]; - float afterX = [[afterRecord objectForKey:@"x"] floatValue]; - float afterY = [[afterRecord objectForKey:@"y"] floatValue]; - if (beforeY - point.y < point.y - afterY) + + record = nil; + if ([atRecords count]) { + NSNumber *nearest = [[[atRecords allKeys] sortedArrayUsingSelector:@selector(compare:)] objectAtIndex:0]; + record = [atRecords objectForKey:nearest]; + } else if (beforeRecord && afterRecord) { + float beforeX = [[beforeRecord objectForKey:@"x"] floatValue]; + float beforeY = [[beforeRecord objectForKey:@"y"] floatValue]; + float afterX = [[afterRecord objectForKey:@"x"] floatValue]; + float afterY = [[afterRecord objectForKey:@"y"] floatValue]; + if (beforeY - point.y < point.y - afterY) + record = beforeRecord; + else if (beforeY - point.y > point.y - afterY) + record = afterRecord; + else if (beforeX - point.x < point.x - afterX) + record = beforeRecord; + else if (beforeX - point.x > point.x - afterX) + record = afterRecord; + else + record = beforeRecord; + } else if (beforeRecord) { record = beforeRecord; - else if (beforeY - point.y > point.y - afterY) + } else if (afterRecord) { record = afterRecord; - else if (beforeX - point.x < point.x - afterX) - record = beforeRecord; - else if (beforeX - point.x > point.x - afterX) - record = afterRecord; - else - record = beforeRecord; - } else if (beforeRecord) { - record = beforeRecord; - } else if (afterRecord) { - record = afterRecord; + } + + if (record) { + foundLine = [[record objectForKey:@"line"] intValue]; + foundFile = [record objectForKey:@"file"]; + } + } - if (record) { - if (line) - *line = [[record objectForKey:@"line"] intValue]; - if (file) - *file = [record objectForKey:@"file"]; - return YES; - } else { - if (line) - *line = -1; - if (file) - *file = nil; - return NO; - } + if (line) *line = foundLine; + if (file) *file = foundFile; + + return record != nil; } - (BOOL)getPageIndex:(unsigned int *)pageIndex location:(NSPoint *)point forLine:(int)line inFile:(NSString *)file { - if ([self parsePdfsyncFileIfNeeded] == NO) - return NO; - if (line < 0 || file == nil || [lines objectForKey:file] == nil) - return NO; - - NSDictionary *beforeRecord = nil; - NSDictionary *afterRecord = nil; - NSDictionary *atRecord = nil; - NSEnumerator *recordEnum = [[lines objectForKey:file] objectEnumerator]; + unsigned int foundPageIndex = NSNotFound; + NSPoint foundPoint = NSZeroPoint; NSDictionary *record = nil; - while (record = [recordEnum nextObject]) { - if ([record objectForKey:@"page"] == nil) - continue; - int l = [[record objectForKey:@"line"] intValue]; - if (l < line) { - beforeRecord = record; - } else if (l > line) { - afterRecord = record; - break; - } else { - atRecord = record; - break; + if (file && [lines objectForKey:file] && [self parsePdfsyncFileIfNeeded]) { + + NSDictionary *beforeRecord = nil; + NSDictionary *afterRecord = nil; + NSDictionary *atRecord = nil; + NSEnumerator *recordEnum = [[lines objectForKey:file] objectEnumerator]; + + while (record = [recordEnum nextObject]) { + if ([record objectForKey:@"page"] == nil) + continue; + int l = [[record objectForKey:@"line"] intValue]; + if (l < line) { + beforeRecord = record; + } else if (l > line) { + afterRecord = record; + break; + } else { + atRecord = record; + break; + } } - } - - if (atRecord) { - record = atRecord; - } else if (beforeRecord && afterRecord) { - int beforeLine = [[beforeRecord objectForKey:@"line"] intValue]; - int afterLine = [[afterRecord objectForKey:@"line"] intValue]; - if (beforeLine - line < line - afterLine) + + if (atRecord) { + record = atRecord; + } else if (beforeRecord && afterRecord) { + int beforeLine = [[beforeRecord objectForKey:@"line"] intValue]; + int afterLine = [[afterRecord objectForKey:@"line"] intValue]; + if (beforeLine - line > line - afterLine) + record = afterRecord; + else + record = beforeRecord; + } else if (beforeRecord) { record = beforeRecord; - else if (beforeLine - line > line - afterLine) + } else if (afterRecord) { record = afterRecord; - else - record = beforeRecord; - } else if (beforeRecord) { - record = beforeRecord; - } else if (afterRecord) { - record = afterRecord; + } + + if (record) { + foundPageIndex = [[record objectForKey:@"page"] unsignedIntValue]; + foundPoint = NSMakePoint([[record objectForKey:@"x"] floatValue], [[record objectForKey:@"y"] floatValue]); + } } - if (record) { - if (pageIndex) - *pageIndex = [[record objectForKey:@"page"] unsignedIntValue]; - if (point) - *point = NSMakePoint([[record objectForKey:@"x"] floatValue], [[record objectForKey:@"y"] floatValue]); - return YES; - } else { - if (pageIndex) - *pageIndex = NSNotFound; - if (point) - *point = NSZeroPoint; - return NO; - } + if (pageIndex) *pageIndex = foundPageIndex; + if (point) *point = foundPoint; + + return record != nil; } @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-26 12:58:58
|
Revision: 1907 http://skim-app.svn.sourceforge.net/skim-app/?rev=1907&view=rev Author: hofman Date: 2007-04-26 05:58:53 -0700 (Thu, 26 Apr 2007) Log Message: ----------- remove extension from shel script file Modified Paths: -------------- trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/displayline Removed Paths: ------------- trunk/displayline.sh Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-04-26 12:46:20 UTC (rev 1906) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-04-26 12:58:53 UTC (rev 1907) @@ -66,7 +66,7 @@ CE1E25680BDA61E80011D9DD /* ReadNotesAccessoryView.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE1E25660BDA61E80011D9DD /* ReadNotesAccessoryView.nib */; }; CE1E2B290BDAB6180011D9DD /* SKPDFSynchronizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */; }; CE1E2E600BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E2E5E0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m */; }; - CE1E2F130BDB86A20011D9DD /* displayline.sh in Resources */ = {isa = PBXBuildFile; fileRef = CE1E2F120BDB86A10011D9DD /* displayline.sh */; }; + CE1E2F130BDB86A20011D9DD /* displayline in Resources */ = {isa = PBXBuildFile; fileRef = CE1E2F120BDB86A10011D9DD /* displayline */; }; CE1E301D0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E301B0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m */; }; CE1E30290BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1E30270BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m */; }; CE1E39E10BDBD6AC0011D9DD /* skimnotes in Resources */ = {isa = PBXBuildFile; fileRef = CEF3BF750B99CA2900E12E3D /* skimnotes */; }; @@ -304,7 +304,7 @@ CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKPDFSynchronizer.m; sourceTree = "<group>"; }; CE1E2E5D0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDisplayTeXLineCommand.h; sourceTree = "<group>"; }; CE1E2E5E0BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDisplayTeXLineCommand.m; sourceTree = "<group>"; }; - CE1E2F120BDB86A10011D9DD /* displayline.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = displayline.sh; sourceTree = "<group>"; }; + CE1E2F120BDB86A10011D9DD /* displayline */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = displayline; sourceTree = "<group>"; }; CE1E301A0BDB9D5C0011D9DD /* NSScanner_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScanner_SKExtensions.h; sourceTree = "<group>"; }; CE1E301B0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSScanner_SKExtensions.m; sourceTree = "<group>"; }; CE1E30260BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSCharacterSet_SKExtensions.h; sourceTree = "<group>"; }; @@ -594,7 +594,7 @@ CE67BB240BC44AC9007B6929 /* ZoomValues.strings */, 45A3BD380B4F097D002B297F /* InitialUserDefaults.plist */, CE41A6CB0B975E5000ECF819 /* Skim.sdef */, - CE1E2F120BDB86A10011D9DD /* displayline.sh */, + CE1E2F120BDB86A10011D9DD /* displayline */, ); name = Resources; sourceTree = "<group>"; @@ -1027,7 +1027,7 @@ CE7C5D050BD8062C0011315D /* ArrowNoteAdorn.tiff in Resources */, CE7C5D190BD8086C0011315D /* ToolbarArrowNote.tiff in Resources */, CE1E25680BDA61E80011D9DD /* ReadNotesAccessoryView.nib in Resources */, - CE1E2F130BDB86A20011D9DD /* displayline.sh in Resources */, + CE1E2F130BDB86A20011D9DD /* displayline in Resources */, CE1E39E10BDBD6AC0011D9DD /* skimnotes in Resources */, ); runOnlyForDeploymentPostprocessing = 0; Copied: trunk/displayline (from rev 1896, trunk/displayline.sh) =================================================================== --- trunk/displayline (rev 0) +++ trunk/displayline 2007-04-26 12:58:53 UTC (rev 1907) @@ -0,0 +1,15 @@ +#!/bin/sh + +# displayline.sh (Skim) +# +# Usage: displayline.sh LINE PDFFILE [TEXSOURCEFILE] + +line=$1 +file="$2" +if [ $# -gt 3 ]; then +source="$3" +else +source="$2" +fi + +/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "display TeX line "${line}" in \""${file}"\" from source \""${source}"\"" -e "end tell" Deleted: trunk/displayline.sh =================================================================== --- trunk/displayline.sh 2007-04-26 12:46:20 UTC (rev 1906) +++ trunk/displayline.sh 2007-04-26 12:58:53 UTC (rev 1907) @@ -1,15 +0,0 @@ -#!/bin/sh - -# displayline.sh (Skim) -# -# Usage: displayline.sh LINE PDFFILE [TEXSOURCEFILE] - -line=$1 -file="$2" -if [ $# -gt 3 ]; then -source="$3" -else -source="$2" -fi - -/usr/bin/osascript -e "tell application \"Skim\"" -e "activate" -e "display TeX line "${line}" in \""${file}"\" from source \""${source}"\"" -e "end tell" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-26 12:46:26
|
Revision: 1906 http://skim-app.svn.sourceforge.net/skim-app/?rev=1906&view=rev Author: hofman Date: 2007-04-26 05:46:20 -0700 (Thu, 26 Apr 2007) Log Message: ----------- Add links to Wiki and FAQ in help. Modified Paths: -------------- trunk/Dutch.lproj/Skim Help/skim.texi trunk/English.lproj/Skim Help/skim.texi trunk/Italian.lproj/Skim Help/skim.texi Modified: trunk/Dutch.lproj/Skim Help/skim.texi =================================================================== --- trunk/Dutch.lproj/Skim Help/skim.texi 2007-04-25 17:36:55 UTC (rev 1905) +++ trunk/Dutch.lproj/Skim Help/skim.texi 2007-04-26 12:46:20 UTC (rev 1906) @@ -1159,6 +1159,8 @@ @heading Weblocaties @itemize @item @uref{http://skim-app.sourceforge.net, Skim Website} +@item @uref{http://skim-ap.sourceforge.net/wiki, Skim Wiki} +@item @uref{http://skim-ap.sourceforge.net/wiki/index.php/FAQ, Skim FAQ} @item @uref{http://skim-app.sourceforge.net/manual, Online kopie van deze handleiding} @end itemize Modified: trunk/English.lproj/Skim Help/skim.texi =================================================================== --- trunk/English.lproj/Skim Help/skim.texi 2007-04-25 17:36:55 UTC (rev 1905) +++ trunk/English.lproj/Skim Help/skim.texi 2007-04-26 12:46:20 UTC (rev 1906) @@ -1153,6 +1153,8 @@ @heading Online Resources @itemize @item @uref{http://skim-app.sourceforge.net, Skim Website} +@item @uref{http://skim-ap.sourceforge.net/wiki, Skim Wiki} +@item @uref{http://skim-ap.sourceforge.net/wiki/index.php/FAQ, Skim FAQ} @item @uref{http://skim-app.sourceforge.net/manual, Online copy of this manual} @end itemize Modified: trunk/Italian.lproj/Skim Help/skim.texi =================================================================== --- trunk/Italian.lproj/Skim Help/skim.texi 2007-04-25 17:36:55 UTC (rev 1905) +++ trunk/Italian.lproj/Skim Help/skim.texi 2007-04-26 12:46:20 UTC (rev 1906) @@ -1094,6 +1094,8 @@ @heading Online Resources @itemize @item @uref{http://skim-app.sourceforge.net, Skim Website} +@item @uref{http://skim-ap.sourceforge.net/wiki, Skim Wiki} +@item @uref{http://skim-ap.sourceforge.net/wiki/index.php/FAQ, Skim FAQ} @item @uref{http://skim-app.sourceforge.net/manual, Online copy of this manual} @end itemize This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-25 17:37:02
|
Revision: 1905 http://skim-app.svn.sourceforge.net/skim-app/?rev=1905&view=rev Author: hofman Date: 2007-04-25 10:36:55 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Improve selection when starting behind a note. Implement selection extension using Shift. Only the modifier at mousedown is relevant, not while dragging. Modified Paths: -------------- trunk/PDFSelection_SKExtensions.h trunk/SKPDFAnnotationNote.m trunk/SKPDFView.h trunk/SKPDFView.m Modified: trunk/PDFSelection_SKExtensions.h =================================================================== --- trunk/PDFSelection_SKExtensions.h 2007-04-25 12:33:46 UTC (rev 1904) +++ trunk/PDFSelection_SKExtensions.h 2007-04-25 17:36:55 UTC (rev 1905) @@ -46,3 +46,10 @@ - (NSAttributedString *)contextString; @end + +@interface PDFSelection (PDFSelectionPrivateDeclarations) + +- (int)numberOfRangesOnPage:(PDFPage *)page; +- (NSRange)rangeAtIndex:(int)index onPage:(PDFPage *)page; + +@end Modified: trunk/SKPDFAnnotationNote.m =================================================================== --- trunk/SKPDFAnnotationNote.m 2007-04-25 12:33:46 UTC (rev 1904) +++ trunk/SKPDFAnnotationNote.m 2007-04-25 17:36:55 UTC (rev 1905) @@ -39,6 +39,7 @@ #import "SKPDFAnnotationNote.h" #import "SKStringConstants.h" #import "PDFPage_SKExtensions.h" +#import "PDFSelection_SKExtensions.h" #import "SKPDFView.h" enum { @@ -72,10 +73,6 @@ - (void)drawWithBox:(CGPDFBox)box inContext:(CGContextRef)context; @end -@interface PDFSelection (PDFSelectionPrivateDeclarations) -- (int)numberOfRangesOnPage:(PDFPage *)page; -- (NSRange)rangeAtIndex:(int)index onPage:(PDFPage *)page; -@end @implementation PDFAnnotation (SKExtensions) Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2007-04-25 12:33:46 UTC (rev 1904) +++ trunk/SKPDFView.h 2007-04-25 17:36:55 UTC (rev 1905) @@ -79,6 +79,7 @@ PDFAnnotation *activeAnnotation; PDFAnnotationTextWidget *editAnnotation; + PDFSelection *wasSelection; NSRect wasBounds; NSPoint wasStartPoint; NSPoint wasEndPoint; @@ -88,6 +89,8 @@ BOOL draggingAnnotation; BOOL draggingStartPoint; BOOL mouseDownInAnnotation; + BOOL extendSelection; + BOOL rectSelection; int trackingRect; NSMutableArray *hoverRects; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-25 12:33:46 UTC (rev 1904) +++ trunk/SKPDFView.m 2007-04-25 17:36:55 UTC (rev 1905) @@ -50,6 +50,7 @@ #import "SKReadingBar.h" #import "SKDocument.h" #import "SKPDFSynchronizer.h" +#import "PDFSelection_SKExtensions.h" NSString *SKPDFViewToolModeChangedNotification = @"SKPDFViewToolModeChangedNotification"; NSString *SKPDFViewAnnotationModeChangedNotification = @"SKPDFViewAnnotationModeChangedNotification"; @@ -62,6 +63,10 @@ CGMutablePathRef CGCreatePathWithRoundRectInRect(CGRect rect, float radius); +@interface PDFDocument (SKExtensions) +- (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection toPage:(PDFPage *)page atPoint:(NSPoint)point; +@end + @interface PDFView (PDFViewPrivateDeclarations) - (void)pdfViewControlHit:(id)sender; - (void)removeAnnotationControl; @@ -600,9 +605,10 @@ [self setActiveAnnotation:nil]; mouseDownLoc = [theEvent locationInWindow]; + unsigned int modifiers = [theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask; - if ([theEvent modifierFlags] & NSCommandKeyMask) { - if ([theEvent modifierFlags] & NSShiftKeyMask) + if (modifiers & NSCommandKeyMask) { + if (modifiers & NSShiftKeyMask) [self pdfsyncWithEvent:theEvent]; else [self selectSnapshotWithEvent:theEvent]; @@ -618,10 +624,32 @@ [self dragReadingBarWithEvent:theEvent]; } else if ([[self document] isLocked] || [self selectAnnotationWithEvent:theEvent] == NO) { PDFAreaOfInterest area = [self areaOfInterestForMouse:theEvent]; - if (area == kPDFNoArea || (area == kPDFPageArea && [[page selectionForRect:NSMakeRect(p.x - 30.0, p.y - 40.0, 60.0, 80.0)] string] == nil)) + if (area == kPDFNoArea || (area == kPDFPageArea && [[page selectionForRect:NSMakeRect(p.x - 30.0, p.y - 40.0, 60.0, 80.0)] string] == nil)) { [self dragWithEvent:theEvent]; - else + } else { + if (nil == activeAnnotation && mouseDownInAnnotation) { + if (modifiers & NSAlternateKeyMask) { + rectSelection = YES; + extendSelection = NO; + [self setCurrentSelection:NO]; + } else if (modifiers & NSShiftKeyMask) { + rectSelection = NO; + extendSelection = YES; + wasSelection = [[self currentSelection] retain]; + if (page == nil) { + p = [self convertPoint:mouseDownLoc fromView:nil]; + page = [self pageForPoint:p nearest:YES]; + p = [self convertPoint:p toPage:page]; + } + [self setCurrentSelection:[[self document] selectionByExtendingSelection:wasSelection toPage:page atPoint:p]]; + } else { + rectSelection = NO; + extendSelection = NO; + [self setCurrentSelection:NO]; + } + } [super mouseDown:theEvent]; + } } break; } @@ -642,6 +670,8 @@ switch (toolMode) { case SKTextToolMode: mouseDownInAnnotation = NO; + [wasSelection release]; + wasSelection = nil; if (draggingAnnotation) { draggingAnnotation = NO; if ([[activeAnnotation type] isEqualToString:@"Square"] || [[activeAnnotation type] isEqualToString:@"Square"]) { @@ -693,9 +723,11 @@ p2 = [self convertPoint:p2 toPage:page2]; PDFSelection *sel = nil; - if ([theEvent modifierFlags] & NSAlternateKeyMask) { + if (rectSelection) { // how to handle multipage selection? Preview.app's behavior is screwy as well, so we'll do the same thing sel = [page1 selectionForRect:rectWithCorners(p1, p2)]; + } else if (extendSelection) { + sel = [[self document] selectionByExtendingSelection:wasSelection toPage:page2 atPoint:p2]; } else { sel = [[self document] selectionFromPage:page1 atPoint:p1 toPage:page2 atPoint:p2]; } @@ -2676,3 +2708,32 @@ } return path; } + + +@implementation PDFDocument (SKExtensions) + +- (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection toPage:(PDFPage *)page atPoint:(NSPoint)point { + PDFSelection *sel = selection; + NSArray *pages = [selection pages]; + + if ([pages count] && [selection respondsToSelector:@selector(numberOfRangesOnPage:)] && [selection respondsToSelector:@selector(rangeAtIndex:onPage:)]) { + PDFPage *firstPage = [pages objectAtIndex:0]; + PDFPage *lastPage = [pages lastObject]; + unsigned int pageIndex = [self indexForPage:page]; + unsigned int firstPageIndex = [self indexForPage:firstPage]; + unsigned int lastPageIndex = [self indexForPage:lastPage]; + int firstChar = [selection rangeAtIndex:0 onPage:firstPage].location; + int lastChar = NSMaxRange([selection rangeAtIndex:[selection numberOfRangesOnPage:lastPage] - 1 onPage:lastPage]) - 1; + NSRect firstRect = [firstPage characterBoundsAtIndex:firstChar]; + NSRect lastRect = [lastPage characterBoundsAtIndex:lastChar]; + + if (pageIndex < firstPageIndex || (pageIndex == firstPageIndex && (point.y > NSMaxY(firstRect) || (point.y > NSMinY(firstRect) && point.x < NSMinX(firstRect))))) + sel = [self selectionFromPage:page atPoint:point toPage:lastPage atPoint:NSMakePoint(NSMaxX(lastRect), NSMidY(lastRect))]; + if (pageIndex > lastPageIndex || (pageIndex == lastPageIndex && (point.y < NSMinY(lastRect) || (point.y < NSMaxY(lastRect) && point.x > NSMaxX(lastRect))))) + sel = [self selectionFromPage:firstPage atPoint:NSMakePoint(NSMinX(firstRect), NSMidY(firstRect)) toPage:page atPoint:point]; + } + return sel; +} + +@end + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-25 12:33:47
|
Revision: 1904 http://skim-app.svn.sourceforge.net/skim-app/?rev=1904&view=rev Author: hofman Date: 2007-04-25 05:33:46 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Use static c-style arrays for some constant entries. Modified Paths: -------------- trunk/Dutch.lproj/PreferenceWindow.nib/info.nib trunk/Dutch.lproj/PreferenceWindow.nib/keyedobjects.nib trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib trunk/SKPreferenceController.h trunk/SKPreferenceController.m Modified: trunk/Dutch.lproj/PreferenceWindow.nib/info.nib =================================================================== --- trunk/Dutch.lproj/PreferenceWindow.nib/info.nib 2007-04-25 10:21:32 UTC (rev 1903) +++ trunk/Dutch.lproj/PreferenceWindow.nib/info.nib 2007-04-25 12:33:46 UTC (rev 1904) @@ -8,10 +8,6 @@ <string>446.1</string> <key>IBLockedObjects</key> <array/> - <key>IBOpenObjects</key> - <array> - <integer>5</integer> - </array> <key>IBSystem Version</key> <string>8P135</string> </dict> Modified: trunk/Dutch.lproj/PreferenceWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/SKPreferenceController.h =================================================================== --- trunk/SKPreferenceController.h 2007-04-25 10:21:32 UTC (rev 1903) +++ trunk/SKPreferenceController.h 2007-04-25 12:33:46 UTC (rev 1904) @@ -46,10 +46,7 @@ IBOutlet NSPopUpButton *texEditorPopUpButton; IBOutlet NSButton *revertPDFSettingsButton; IBOutlet NSButton *revertFullScreenPDFSettingsButton; - NSMutableArray *fonts; - NSMutableArray *sizes; - NSMutableArray *texEditorCommands; - NSMutableArray *texEditorArguments; + NSArray *fonts; NSDictionary *resettableKeys; BOOL isCustomTeXEditor; } @@ -57,7 +54,8 @@ + (id)sharedPrefenceController; - (NSArray *)fonts; -- (NSArray *)sizes; +- (unsigned)countOfSizes; +- (id)objectInSizesAtIndex:(unsigned)index; - (BOOL)isCustomTeXEditor; - (void)setCustomTeXEditor:(BOOL)flag; Modified: trunk/SKPreferenceController.m =================================================================== --- trunk/SKPreferenceController.m 2007-04-25 10:21:32 UTC (rev 1903) +++ trunk/SKPreferenceController.m 2007-04-25 12:33:46 UTC (rev 1904) @@ -42,14 +42,10 @@ #import "SKApplicationController.h" #import <Sparkle/Sparkle.h> -#define TEXTMATE_CMD @"mate" -#define TEXTMATE_ARGS @"-l %line \"%file\"" -#define BBEDIT_CMD @"bbedit" -#define BBEDIT_ARGS @"+%line \"%file\"" -#define TEXTWRANGLER_CMD @"edit" -#define TEXTWRANGLER_ARGS @"+%line \"%file\"" -#define EMACS_CMD @"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" -#define EMACS_ARGS @"--no-wait +%line \"%file\"" +static float SKDefaultFontSizes[] = {8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 16.0, 18.0, 20.0, 24.0, 28.0, 32.0, 48.0, 64.0}; +static NSString *SKTeXEditors[] = {@"TextMate", @"BBEdit", @"TextWrangler", @"Emacs"}; +static NSString *SKTeXEditorCommands[] = {@"mate", @"bbedit", @"edit", @"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"}; +static NSString *SKTeXEditorArguments[] = {@"-l %line \"%file\"", @"+%line \"%file\"", @"+%line \"%file\"", @"--no-wait +%line \"%file\""}; @implementation SKPreferenceController @@ -65,29 +61,19 @@ NSString *userDefaultsValuesPath = [[NSBundle mainBundle] pathForResource:@"InitialUserDefaults" ofType:@"plist"]; resettableKeys = [[[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath] valueForKey:@"ResettableKeys"] retain]; + NSMutableArray *tmpFonts = [NSMutableArray array]; NSMutableArray *fontNames = [[[[NSFontManager sharedFontManager] availableFontFamilies] mutableCopy] autorelease]; NSEnumerator *fontEnum; NSString *fontName; [fontNames sortUsingSelector:@selector(caseInsensitiveCompare:)]; fontEnum = [fontNames objectEnumerator]; - fonts = [[NSMutableArray alloc] init]; while (fontName = [fontEnum nextObject]) { NSFont *font = [NSFont fontWithName:fontName size:0.0]; - [fonts addObject:[NSDictionary dictionaryWithObjectsAndKeys:[font fontName], @"fontName", [font displayName], @"displayName", nil]]; + [tmpFonts addObject:[NSDictionary dictionaryWithObjectsAndKeys:[font fontName], @"fontName", [font displayName], @"displayName", nil]]; } + fonts = [tmpFonts copy]; - sizes = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:8.0], [NSNumber numberWithFloat:9.0], [NSNumber numberWithFloat:10.0], - [NSNumber numberWithFloat:11.0], [NSNumber numberWithFloat:12.0], [NSNumber numberWithFloat:13.0], - [NSNumber numberWithFloat:14.0], [NSNumber numberWithFloat:16.0], [NSNumber numberWithFloat:18.0], - [NSNumber numberWithFloat:20.0], [NSNumber numberWithFloat:24.0], [NSNumber numberWithFloat:28.0], - [NSNumber numberWithFloat:32.0], [NSNumber numberWithFloat:48.0], [NSNumber numberWithFloat:64.0], nil]; - texEditorCommands = [[NSMutableArray alloc] initWithObjects:TEXTMATE_CMD, BBEDIT_CMD, TEXTWRANGLER_CMD, EMACS_CMD, nil]; - texEditorArguments = [[NSMutableArray alloc] initWithObjects:TEXTMATE_ARGS, BBEDIT_ARGS,TEXTWRANGLER_ARGS, EMACS_ARGS, nil]; - - isCustomTeXEditor = [texEditorCommands containsObject:[[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorCommandKey]] == NO || - [texEditorArguments containsObject:[[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorArgumentsKey]] == NO; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKey:SKDefaultPDFDisplaySettingsKey]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKey:SKDefaultFullScreenPDFDisplaySettingsKey]; } @@ -99,9 +85,6 @@ [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKey:SKDefaultFullScreenPDFDisplaySettingsKey]; [resettableKeys release]; [fonts release]; - [sizes release]; - [texEditorCommands release]; - [texEditorArguments release]; [super dealloc]; } @@ -117,22 +100,39 @@ } - (void)windowDidLoad { + NSString *editorCmd = [[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorCommandKey]; + NSString *editorArgs = [[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorArgumentsKey]; + int i = sizeof(SKTeXEditors) / sizeof(NSString *); + int index = -1; + + while (i--) { + [texEditorPopUpButton insertItemWithTitle:SKTeXEditors[i] atIndex:0]; + if ([SKTeXEditorCommands[i] isEqualToString:editorCmd] && [SKTeXEditorArguments[i] isEqualToString:editorArgs]) + index = i; + } + + [self setCustomTeXEditor:index == -1]; + + if (isCustomTeXEditor) + [texEditorPopUpButton selectItem:[texEditorPopUpButton lastItem]]; + else + [texEditorPopUpButton selectItemAtIndex:index]; + [self updateRevertButtons]; - if (isCustomTeXEditor) { - [texEditorPopUpButton selectItem:[texEditorPopUpButton lastItem]]; - } else { - [texEditorPopUpButton selectItemAtIndex:[texEditorCommands indexOfObject:[[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorCommandKey]]]; - } } - (NSArray *)fonts { return fonts; } -- (NSArray *)sizes { - return sizes; +- (unsigned)countOfSizes { + return sizeof(SKDefaultFontSizes) / sizeof(float); } +- (id)objectInSizesAtIndex:(unsigned)index { + return [NSNumber numberWithFloat:SKDefaultFontSizes[index]]; +} + - (BOOL)isCustomTeXEditor { return isCustomTeXEditor; } @@ -166,10 +166,10 @@ } - (IBAction)changeTeXEditorPreset:(id)sender { - unsigned int index = [sender indexOfSelectedItem]; - if (index < [texEditorCommands count]) { - [[NSUserDefaults standardUserDefaults] setObject:[texEditorCommands objectAtIndex:index] forKey:SKTeXEditorCommandKey]; - [[NSUserDefaults standardUserDefaults] setObject:[texEditorArguments objectAtIndex:index] forKey:SKTeXEditorArgumentsKey]; + int index = [sender indexOfSelectedItem]; + if (index < [sender numberOfItems] - 1) { + [[NSUserDefaults standardUserDefaults] setObject:SKTeXEditorCommands[index] forKey:SKTeXEditorCommandKey]; + [[NSUserDefaults standardUserDefaults] setObject:SKTeXEditorArguments[index] forKey:SKTeXEditorArgumentsKey]; [self setCustomTeXEditor:NO]; } else { [self setCustomTeXEditor:YES]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-25 10:21:37
|
Revision: 1903 http://skim-app.svn.sourceforge.net/skim-app/?rev=1903&view=rev Author: hofman Date: 2007-04-25 03:21:32 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Run sh command to open editor with editor command and arguments as a string arguments. This allows partial editor commands looked up using the PATH environment variable. Use short editor commands for presets when the editor allows a tool install. Modified Paths: -------------- trunk/SKPDFView.m trunk/SKPreferenceController.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-24 19:05:59 UTC (rev 1902) +++ trunk/SKPDFView.m 2007-04-25 10:21:32 UTC (rev 1903) @@ -2632,20 +2632,15 @@ if ([synchronizer getLine:&line file:&file forLocation:location inRect:rect atPageIndex:pageIndex] && [[NSFileManager defaultManager] fileExistsAtPath:file]) { - NSTask *task = [[[NSTask alloc] init] autorelease]; NSString *editorCmd = [[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorCommandKey]; - NSMutableString *argString = [[[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorArgumentsKey] mutableCopy]; - NSArray *arguments; + NSMutableString *cmdString = [[[[NSUserDefaults standardUserDefaults] objectForKey:SKTeXEditorArgumentsKey] mutableCopy] autorelease]; - [argString replaceOccurrencesOfString:@"%file" withString:file options:NSLiteralSearch range: NSMakeRange(0, [argString length] )]; - [argString replaceOccurrencesOfString:@"%line" withString:[NSString stringWithFormat:@"%d", line] options:NSLiteralSearch range:NSMakeRange(0, [argString length])]; - arguments = [argString shellScriptArgumentsArray]; - [argString release]; + [cmdString replaceOccurrencesOfString:@"%file" withString:file options:NSLiteralSearch range: NSMakeRange(0, [cmdString length] )]; + [cmdString replaceOccurrencesOfString:@"%line" withString:[NSString stringWithFormat:@"%d", line] options:NSLiteralSearch range:NSMakeRange(0, [cmdString length])]; + [cmdString insertString:@" " atIndex:0]; + [cmdString insertString:editorCmd atIndex:0]; - [task setCurrentDirectoryPath:[file stringByDeletingLastPathComponent]]; - [task setLaunchPath:editorCmd]; - [task setArguments:arguments]; - [task launch]; + [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", cmdString, nil]]; } else NSBeep(); } Modified: trunk/SKPreferenceController.m =================================================================== --- trunk/SKPreferenceController.m 2007-04-24 19:05:59 UTC (rev 1902) +++ trunk/SKPreferenceController.m 2007-04-25 10:21:32 UTC (rev 1903) @@ -42,6 +42,15 @@ #import "SKApplicationController.h" #import <Sparkle/Sparkle.h> +#define TEXTMATE_CMD @"mate" +#define TEXTMATE_ARGS @"-l %line \"%file\"" +#define BBEDIT_CMD @"bbedit" +#define BBEDIT_ARGS @"+%line \"%file\"" +#define TEXTWRANGLER_CMD @"edit" +#define TEXTWRANGLER_ARGS @"+%line \"%file\"" +#define EMACS_CMD @"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" +#define EMACS_ARGS @"--no-wait +%line \"%file\"" + @implementation SKPreferenceController + (id)sharedPrefenceController { @@ -73,8 +82,8 @@ [NSNumber numberWithFloat:14.0], [NSNumber numberWithFloat:16.0], [NSNumber numberWithFloat:18.0], [NSNumber numberWithFloat:20.0], [NSNumber numberWithFloat:24.0], [NSNumber numberWithFloat:28.0], [NSNumber numberWithFloat:32.0], [NSNumber numberWithFloat:48.0], [NSNumber numberWithFloat:64.0], nil]; - texEditorCommands = [[NSMutableArray alloc] initWithObjects:@"/Applications/TextMate.app/Contents/Resources/mate", @"/Applications/BBEdit.app/Contents/Resources/bbedit", @"/Applications/TextWrangler.app/Contents/Resources/edit", @"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient", nil]; - texEditorArguments = [[NSMutableArray alloc] initWithObjects:@"-l %line \"%file\"", @"+%line \"%file\"", @"+%line \"%file\"", @"--no-wait +%line \"%file\"", nil]; + texEditorCommands = [[NSMutableArray alloc] initWithObjects:TEXTMATE_CMD, BBEDIT_CMD, TEXTWRANGLER_CMD, EMACS_CMD, nil]; + texEditorArguments = [[NSMutableArray alloc] initWithObjects:TEXTMATE_ARGS, BBEDIT_ARGS,TEXTWRANGLER_ARGS, EMACS_ARGS, nil]; isCustomTeXEditor = [texEditorCommands containsObject:[[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorCommandKey]] == NO || [texEditorArguments containsObject:[[NSUserDefaults standardUserDefaults] stringForKey:SKTeXEditorArgumentsKey]] == NO; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-24 19:06:01
|
Revision: 1902 http://skim-app.svn.sourceforge.net/skim-app/?rev=1902&view=rev Author: hofman Date: 2007-04-24 12:05:59 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Move some objects and categories to their own files. Modified Paths: -------------- trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/PDFSelection_SKExtensions.h trunk/PDFSelection_SKExtensions.m trunk/SKMainWindow.h trunk/SKMainWindow.m trunk/SKToolbarItem.h trunk/SKToolbarItem.m Added: trunk/PDFSelection_SKExtensions.h =================================================================== --- trunk/PDFSelection_SKExtensions.h (rev 0) +++ trunk/PDFSelection_SKExtensions.h 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,48 @@ +// +// PDFSelection_SKExtensions.h +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + + +@interface PDFSelection (SKExtensions) + +// the search table columns bind to these methods for display +- (NSString *)firstPageLabel; +- (NSAttributedString *)contextString; + +@end Added: trunk/PDFSelection_SKExtensions.m =================================================================== --- trunk/PDFSelection_SKExtensions.m (rev 0) +++ trunk/PDFSelection_SKExtensions.m 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,98 @@ +// +// PDFSelection_SKExtensions.m +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "PDFSelection_SKExtensions.h" +#import "NSString_SKExtensions.h" + + +@implementation PDFSelection (SKExtensions) + +// returns the label of the first page (if the selection spans multiple pages) +- (NSString *)firstPageLabel { + NSArray *pages = [self pages]; + return [pages count] ? [[pages objectAtIndex:0] label] : nil; +} + +- (NSAttributedString *)contextString { + PDFSelection *extendedSelection = [self copy]; // see remark in -tableViewSelectionDidChange: + NSMutableAttributedString *attributedSample; + NSString *searchString = [[self string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; + NSString *sample; + NSMutableString *attributedString; + NSString *ellipse = [NSString stringWithFormat:@"%C", 0x2026]; + NSRange foundRange; + NSDictionary *attributes; + NSMutableParagraphStyle *paragraphStyle = nil; + + // Extend selection. + [extendedSelection extendSelectionAtStart:10]; + [extendedSelection extendSelectionAtEnd:20]; + + // get the cleaned string + sample = [[extendedSelection string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; + + // Finally, create attributed string. + attributedSample = [[NSMutableAttributedString alloc] initWithString:sample]; + attributedString = [attributedSample mutableString]; + [attributedString insertString:ellipse atIndex:0]; + [attributedString appendString:ellipse]; + + // Find instances of search string and "bold" them. + foundRange = [sample rangeOfString:searchString options:NSCaseInsensitiveSearch]; + if (foundRange.location != NSNotFound) { + // Bold the text range where the search term was found. + attributes = [[NSDictionary alloc] initWithObjectsAndKeys:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, nil]; + [attributedSample setAttributes:attributes range:NSMakeRange(foundRange.location + 1, foundRange.length)]; + [attributes release]; + } + + // Create paragraph style that indicates truncation style. + paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; + attributes = [[NSDictionary alloc] initWithObjectsAndKeys:paragraphStyle, NSParagraphStyleAttributeName, nil]; + // Add paragraph style. + [attributedSample addAttributes:attributes range:NSMakeRange(0, [attributedSample length])]; + // Clean. + [attributes release]; + [paragraphStyle release]; + [extendedSelection release]; + + return [attributedSample autorelease]; +} + +@end Added: trunk/SKMainWindow.h =================================================================== --- trunk/SKMainWindow.h (rev 0) +++ trunk/SKMainWindow.h 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,43 @@ +// +// SKMainWindow.h +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + + +@interface SKMainWindow : NSWindow +@end Added: trunk/SKMainWindow.m =================================================================== --- trunk/SKMainWindow.m (rev 0) +++ trunk/SKMainWindow.m 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,61 @@ +// +// SKMainWindow.m +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKMainWindow.h" +#import "SKPDFHoverWindow.h" + + +@implementation SKMainWindow + +- (void)sendEvent:(NSEvent *)theEvent { + if ([theEvent type] == NSLeftMouseDown || [theEvent type] == NSRightMouseDown) + [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [super sendEvent:theEvent]; +} + +- (void)resignMainWindow { + [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [super resignMainWindow]; +} + +- (void)resignKeyWindow { + [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; + [super resignKeyWindow]; +} + +@end Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2007-04-24 18:51:14 UTC (rev 1901) +++ trunk/SKMainWindowController.h 2007-04-24 19:05:59 UTC (rev 1902) @@ -334,13 +334,3 @@ - (void)setupToolbar; @end - - -@interface SKToolbarItem : NSToolbarItem { - id delegate; -} - -- (id)delegate; -- (void)setDelegate:(id)newDelegate; - -@end Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-04-24 18:51:14 UTC (rev 1901) +++ trunk/SKMainWindowController.m 2007-04-24 19:05:59 UTC (rev 1902) @@ -57,7 +57,6 @@ #import "BDSKEdgeView.h" #import "SKPDFAnnotationNote.h" #import "SKSplitView.h" -#import "NSString_SKExtensions.h" #import "NSScrollView_SKExtensions.h" #import "NSBezierPath_BDSKExtensions.h" #import "NSUserDefaultsController_SKExtensions.h" @@ -67,6 +66,8 @@ #import "BDSKImagePopUpButton.h" #import "NSWindowController_SKExtensions.h" #import "SKPDFHoverWindow.h" +#import "PDFSelection_SKExtensions.h" +#import "SKToolbarItem.h" #define SEGMENTED_CONTROL_HEIGHT 25.0 #define WINDOW_X_DELTA 0.0 @@ -3235,112 +3236,3 @@ } @end - -#pragma mark - - -// the search table columns use these methods for display -@interface PDFSelection (SKExtensions) -@end - -@implementation PDFSelection (SKExtensions) - -// returns the label of the first page (if the selection spans multiple pages) -- (NSString *)firstPageLabel { - NSArray *pages = [self pages]; - return [pages count] ? [[pages objectAtIndex:0] label] : nil; -} - -- (NSAttributedString *)contextString { - PDFSelection *extendedSelection = [self copy]; // see remark in -tableViewSelectionDidChange: - NSMutableAttributedString *attributedSample; - NSString *searchString = [[self string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; - NSString *sample; - NSMutableString *attributedString; - NSString *ellipse = [NSString stringWithFormat:@"%C", 0x2026]; - NSRange foundRange; - NSDictionary *attributes; - NSMutableParagraphStyle *paragraphStyle = nil; - - // Extend selection. - [extendedSelection extendSelectionAtStart:10]; - [extendedSelection extendSelectionAtEnd:20]; - - // get the cleaned string - sample = [[extendedSelection string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; - - // Finally, create attributed string. - attributedSample = [[NSMutableAttributedString alloc] initWithString:sample]; - attributedString = [attributedSample mutableString]; - [attributedString insertString:ellipse atIndex:0]; - [attributedString appendString:ellipse]; - - // Find instances of search string and "bold" them. - foundRange = [sample rangeOfString:searchString options:NSCaseInsensitiveSearch]; - if (foundRange.location != NSNotFound) { - // Bold the text range where the search term was found. - attributes = [[NSDictionary alloc] initWithObjectsAndKeys:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, nil]; - [attributedSample setAttributes:attributes range:NSMakeRange(foundRange.location + 1, foundRange.length)]; - [attributes release]; - } - - // Create paragraph style that indicates truncation style. - paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; - attributes = [[NSDictionary alloc] initWithObjectsAndKeys:paragraphStyle, NSParagraphStyleAttributeName, nil]; - // Add paragraph style. - [attributedSample addAttributes:attributes range:NSMakeRange(0, [attributedSample length])]; - // Clean. - [attributes release]; - [paragraphStyle release]; - [extendedSelection release]; - - return [attributedSample autorelease]; -} - -@end - - -@implementation SKToolbarItem - -- (id)delegate { - return delegate; -} - -- (void)setDelegate:(id)newDelegate { - delegate = newDelegate; -} - -- (void)validate { - if ([self view] && [delegate respondsToSelector:@selector(validateToolbarItem:)]) { - BOOL enabled = [[self delegate] validateToolbarItem:self]; - [self setEnabled:enabled]; - } else { - [super validate]; - } -} - -@end - - -@interface SKMainWindow : NSWindow -@end - -@implementation SKMainWindow - -- (void)sendEvent:(NSEvent *)theEvent { - if ([theEvent type] == NSLeftMouseDown || [theEvent type] == NSRightMouseDown) - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; - [super sendEvent:theEvent]; -} - -- (void)resignMainWindow { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; - [super resignMainWindow]; -} - -- (void)resignKeyWindow { - [[SKPDFHoverWindow sharedHoverWindow] orderOut:nil]; - [super resignKeyWindow]; -} - -@end Added: trunk/SKToolbarItem.h =================================================================== --- trunk/SKToolbarItem.h (rev 0) +++ trunk/SKToolbarItem.h 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,49 @@ +// +// SKToolbarItem.h +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + + +@interface SKToolbarItem : NSToolbarItem { + id delegate; +} + +- (id)delegate; +- (void)setDelegate:(id)newDelegate; + +@end Added: trunk/SKToolbarItem.m =================================================================== --- trunk/SKToolbarItem.m (rev 0) +++ trunk/SKToolbarItem.m 2007-04-24 19:05:59 UTC (rev 1902) @@ -0,0 +1,61 @@ +// +// SKToolbarItem.m +// Skim +// +// Created by Christiaan Hofman on 4/24/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKToolbarItem.h" + + +@implementation SKToolbarItem + +- (id)delegate { + return delegate; +} + +- (void)setDelegate:(id)newDelegate { + delegate = newDelegate; +} + +- (void)validate { + if ([self view] && [delegate respondsToSelector:@selector(validateToolbarItem:)]) { + BOOL enabled = [[self delegate] validateToolbarItem:self]; + [self setEnabled:enabled]; + } else { + [super validate]; + } +} + +@end Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-04-24 18:51:14 UTC (rev 1901) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-04-24 19:05:59 UTC (rev 1902) @@ -98,6 +98,9 @@ CE41A6CC0B975E5000ECF819 /* Skim.sdef in Resources */ = {isa = PBXBuildFile; fileRef = CE41A6CB0B975E5000ECF819 /* Skim.sdef */; }; CE4294A30BBD29120016FDC2 /* SKReadingBar.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4294A20BBD29120016FDC2 /* SKReadingBar.m */; }; CE4373B40BB5440E00A56987 /* PSDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = CE4373B30BB5440E00A56987 /* PSDocument.icns */; }; + CE4972510BDE898F00D7F1D2 /* SKMainWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE49724F0BDE898F00D7F1D2 /* SKMainWindow.m */; }; + CE49726D0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE49726B0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m */; }; + CE49728B0BDE8B2900D7F1D2 /* SKToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4972890BDE8B2900D7F1D2 /* SKToolbarItem.m */; }; CE4A659F0BAB1598004AD07D /* SKBookmarkController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4A659E0BAB1598004AD07D /* SKBookmarkController.m */; }; CE4A65CC0BAB1E2E004AD07D /* BookmarksWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE4A65CA0BAB1E2E004AD07D /* BookmarksWindow.nib */; }; CE4A8BA20BB15980004AD07D /* NSWindowController_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4A8BA10BB15980004AD07D /* NSWindowController_SKExtensions.m */; }; @@ -362,6 +365,12 @@ CE485B990BC442C000FA7109 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/Localizable.strings; sourceTree = "<group>"; }; CE485B9C0BC442CB00FA7109 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Dutch; path = Dutch.lproj/BookmarksWindow.nib; sourceTree = "<group>"; }; CE485BF00BC4443B00FA7109 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = Dutch; path = Dutch.lproj/Credits.rtf; sourceTree = "<group>"; }; + CE49724E0BDE898F00D7F1D2 /* SKMainWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKMainWindow.h; sourceTree = "<group>"; }; + CE49724F0BDE898F00D7F1D2 /* SKMainWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKMainWindow.m; sourceTree = "<group>"; }; + CE49726A0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFSelection_SKExtensions.h; sourceTree = "<group>"; }; + CE49726B0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFSelection_SKExtensions.m; sourceTree = "<group>"; }; + CE4972880BDE8B2900D7F1D2 /* SKToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKToolbarItem.h; sourceTree = "<group>"; }; + CE4972890BDE8B2900D7F1D2 /* SKToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKToolbarItem.m; sourceTree = "<group>"; }; CE4A659D0BAB1598004AD07D /* SKBookmarkController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKBookmarkController.h; sourceTree = "<group>"; }; CE4A659E0BAB1598004AD07D /* SKBookmarkController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKBookmarkController.m; sourceTree = "<group>"; }; CE4A65CB0BAB1E2E004AD07D /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/BookmarksWindow.nib; sourceTree = "<group>"; }; @@ -635,6 +644,8 @@ CE4A8BA10BB15980004AD07D /* NSWindowController_SKExtensions.m */, CE2DE50B0B85DC4000D0DA12 /* PDFPage_SKExtensions.h */, CE2DE50C0B85DC4000D0DA12 /* PDFPage_SKExtensions.m */, + CE49726A0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.h */, + CE49726B0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m */, ); name = Categories; sourceTree = "<group>"; @@ -692,6 +703,8 @@ CE2DE4D00B85D8C400D0DA12 /* Windows */ = { isa = PBXGroup; children = ( + CE49724E0BDE898F00D7F1D2 /* SKMainWindow.h */, + CE49724F0BDE898F00D7F1D2 /* SKMainWindow.m */, CE2DE49B0B85D4F400D0DA12 /* SKFullScreenWindow.h */, CE2DE49C0B85D4F400D0DA12 /* SKFullScreenWindow.m */, CE2DE4C40B85D78200D0DA12 /* SKMiniaturizeWindow.h */, @@ -739,6 +752,8 @@ F92DB5A90B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m */, F92DB5AA0B36FE1F002A26E9 /* BDSKZoomablePDFView.h */, F92DB5AB0B36FE1F002A26E9 /* BDSKZoomablePDFView.m */, + CE4972880BDE8B2900D7F1D2 /* SKToolbarItem.h */, + CE4972890BDE8B2900D7F1D2 /* SKToolbarItem.m */, ); name = Views; sourceTree = "<group>"; @@ -1143,6 +1158,9 @@ CE1E2E600BDB6C1F0011D9DD /* SKDisplayTeXLineCommand.m in Sources */, CE1E301D0BDB9D5C0011D9DD /* NSScanner_SKExtensions.m in Sources */, CE1E30290BDB9D8E0011D9DD /* NSCharacterSet_SKExtensions.m in Sources */, + CE4972510BDE898F00D7F1D2 /* SKMainWindow.m in Sources */, + CE49726D0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m in Sources */, + CE49728B0BDE8B2900D7F1D2 /* SKToolbarItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-04-24 18:51:19
|
Revision: 1901 http://skim-app.svn.sourceforge.net/skim-app/?rev=1901&view=rev Author: hofman Date: 2007-04-24 11:51:14 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Register mousedown in note annotation outside active area again, so we can do our own text selection. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-04-24 17:41:37 UTC (rev 1900) +++ trunk/SKPDFView.m 2007-04-24 18:51:14 UTC (rev 1901) @@ -1945,16 +1945,22 @@ i = [annotations count]; while (i-- > 0) { - PDFAnnotation *annotationHit = [annotations objectAtIndex:i]; + PDFAnnotation *annotation = [annotations objectAtIndex:i]; + NSRect bounds = [annotation bounds]; // Hit test annotation. - if ([annotationHit isNoteAnnotation] && [annotationHit hitTest:pagePoint]) { - mouseDownInAnnotation = YES; - newActiveAnnotation = annotationHit; - // Remember click point relative to annotation origin. - clickDelta.x = pagePoint.x - NSMinX([annotationHit bounds]); - clickDelta.y = pagePoint.y - NSMinY([annotationHit bounds]); - break; + if ([annotation isNoteAnnotation]) { + if ([annotation hitTest:pagePoint]) { + mouseDownInAnnotation = YES; + newActiveAnnotation = annotation; + // Remember click point relative to annotation origin. + clickDelta.x = pagePoint.x - NSMinX(bounds); + clickDelta.y = pagePoint.y - NSMinY(bounds); + break; + } else if (NSPointInRect(pagePoint, bounds)) { + // register this, so we can do our own selection later + mouseDownInAnnotation = YES; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |