[Skim-app-commit] SF.net SVN: skim-app: [2498] trunk/SKDocument.m
Revision: 2498 http://skim-app.svn.sourceforge.net/skim-app/?rev=2498&view=rev Author: hofman Date: 2007-07-13 12:15:55 -0700 (Fri, 13 Jul 2007) Log Message: --- Interchange replacing %line and replacing %file in pdfsync command. Modified Paths: -- trunk/SKDocument.m Modified: trunk/SKDocument.m === --- trunk/SKDocument.m 2007-07-13 18:28:07 UTC (rev 2497) +++ trunk/SKDocument.m 2007-07-13 19:15:55 UTC (rev 2498) @@ -880,25 +880,25 @@ NSRange range = NSMakeRange(0, 0); unichar prevChar, nextChar; while (NSMaxRange(range) < [cmdString length]) { -range = [cmdString rangeOfString:@"%file" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; +range = [cmdString rangeOfString:@"%line" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; if (range.location == NSNotFound) break; -prevChar = range.location > 0 ? [cmdString characterAtIndex:range.location - 1] : 0; nextChar = NSMaxRange(range) < [cmdString length] ? [cmdString characterAtIndex:NSMaxRange(range)] : 0; -if (prevChar == '\'' && nextChar == '\'') -[cmdString replaceCharactersInRange:range withString:file]; -else if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) -[cmdString replaceCharactersInRange:range withString:[file stringByEscapingShellChars]]; +if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) +[cmdString replaceCharactersInRange:range withString:[NSString stringWithFormat:@"%d", line]]; } range = NSMakeRange(0, 0); while (NSMaxRange(range) < [cmdString length]) { -range = [cmdString rangeOfString:@"%line" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; +range = [cmdString rangeOfString:@"%file" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; if (range.location == NSNotFound) break; +prevChar = range.location > 0 ? [cmdString characterAtIndex:range.location - 1] : 0; nextChar = NSMaxRange(range) < [cmdString length] ? [cmdString characterAtIndex:NSMaxRange(range)] : 0; -if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) -[cmdString replaceCharactersInRange:range withString:[NSString stringWithFormat:@"%d", line]]; +if (prevChar == '\'' && nextChar == '\'') +[cmdString replaceCharactersInRange:range withString:file]; +else if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) +[cmdString replaceCharactersInRange:range withString:[file stringByEscapingShellChars]]; } [cmdString insertString:@"\" " atIndex:0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit
[Skim-app-commit] SF.net SVN: skim-app: [2497] trunk/SKPDFView.m
Revision: 2497 http://skim-app.svn.sourceforge.net/skim-app/?rev=2497&view=rev Author: hofman Date: 2007-07-13 11:28:07 -0700 (Fri, 13 Jul 2007) Log Message: --- Use arrow cursor for most note tool modes, as links are disabled. Modified Paths: -- trunk/SKPDFView.m Modified: trunk/SKPDFView.m === --- trunk/SKPDFView.m 2007-07-13 18:20:19 UTC (rev 2496) +++ trunk/SKPDFView.m 2007-07-13 18:28:07 UTC (rev 2497) @@ -3366,6 +3366,8 @@ if ((readingBar && [[readingBar page] isEqual:page] && NSPointInRect(p, [readingBar currentBoundsForBox:[self displayBox]])) || (area == kPDFNoArea || (canSelectOrDrag && area == kPDFPageArea && [[page selectionForRect:NSMakeRect(p.x - 30.0, p.y - 40.0, 60.0, 80.0)] string] == nil))) cursor = [NSCursor openHandCursor]; +else if (toolMode == SKNoteToolMode && annotationMode != SKHighlightNote && annotationMode != SKUnderlineNote && annotationMode != SKStrikeOutNote) +cursor = [NSCursor arrowCursor]; break; } case SKMoveToolMode: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit
[Skim-app-commit] SF.net SVN: skim-app: [2496] trunk
Revision: 2496 http://skim-app.svn.sourceforge.net/skim-app/?rev=2496&view=rev Author: hofman Date: 2007-07-13 11:20:19 -0700 (Fri, 13 Jul 2007) Log Message: --- Escape special shell characters in file path passed to shell for pdfsync. Modified Paths: -- trunk/NSString_SKExtensions.h trunk/NSString_SKExtensions.m trunk/SKDocument.m Modified: trunk/NSString_SKExtensions.h === --- trunk/NSString_SKExtensions.h 2007-07-13 16:39:31 UTC (rev 2495) +++ trunk/NSString_SKExtensions.h 2007-07-13 18:20:19 UTC (rev 2496) @@ -47,6 +47,7 @@ - (NSString *)stringByReplacingPathExtension:(NSString *)ext; +- (NSString *)stringByEscapingShellChars; - (NSArray *)shellScriptArgumentsArray; - (NSRange)rangeOfLeadingEmptyLine; Modified: trunk/NSString_SKExtensions.m === --- trunk/NSString_SKExtensions.m 2007-07-13 16:39:31 UTC (rev 2495) +++ trunk/NSString_SKExtensions.m 2007-07-13 18:20:19 UTC (rev 2496) @@ -117,6 +117,25 @@ return [[self stringByDeletingPathExtension] stringByAppendingPathExtension:ext]; } +// Escape those characters that are special, to the shell, inside a "quoted" string +- (NSString *)stringByEscapingShellChars { +static NSCharacterSet *shellSpecialChars = nil; +if (shellSpecialChars == nil) +shellSpecialChars = [[NSCharacterSet characterSetWithCharactersInString:@"$\"`\\"] retain]; + +NSMutableString *result = [self mutableCopy]; +unsigned int i = 0; +while (i < [result length]) { +i = [result rangeOfCharacterFromSet:shellSpecialChars options:0 range:NSMakeRange(i, [result length] - i)].location; +if (i != NSNotFound) { +[result insertString:@"\\" atIndex: i]; +i += 2; +} +} + +return [result autorelease]; +} + // parses a space separated list of shell script argments // allows quoting parts of an argument and escaped characters outside quotes, according to shell rules - (NSArray *)shellScriptArgumentsArray; Modified: trunk/SKDocument.m === --- trunk/SKDocument.m 2007-07-13 16:39:31 UTC (rev 2495) +++ trunk/SKDocument.m 2007-07-13 18:20:19 UTC (rev 2496) @@ -877,8 +877,30 @@ } } -[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])]; +NSRange range = NSMakeRange(0, 0); +unichar prevChar, nextChar; +while (NSMaxRange(range) < [cmdString length]) { +range = [cmdString rangeOfString:@"%file" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; +if (range.location == NSNotFound) +break; +prevChar = range.location > 0 ? [cmdString characterAtIndex:range.location - 1] : 0; +nextChar = NSMaxRange(range) < [cmdString length] ? [cmdString characterAtIndex:NSMaxRange(range)] : 0; +if (prevChar == '\'' && nextChar == '\'') +[cmdString replaceCharactersInRange:range withString:file]; +else if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) +[cmdString replaceCharactersInRange:range withString:[file stringByEscapingShellChars]]; +} + +range = NSMakeRange(0, 0); +while (NSMaxRange(range) < [cmdString length]) { +range = [cmdString rangeOfString:@"%line" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [cmdString length] - NSMaxRange(range))]; +if (range.location == NSNotFound) +break; +nextChar = NSMaxRange(range) < [cmdString length] ? [cmdString characterAtIndex:NSMaxRange(range)] : 0; +if ([[NSCharacterSet letterCharacterSet] characterIsMember:nextChar] == NO) +[cmdString replaceCharactersInRange:range withString:[NSString stringWithFormat:@"%d", line]]; +} + [cmdString insertString:@"\" " atIndex:0]; [cmdString insertString:editorCmd atIndex:0]; [cmdString insertString:@"\"" atIndex:0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Skim-app-commit mailing lis
[Skim-app-commit] SF.net SVN: skim-app: [2495] trunk
Revision: 2495 http://skim-app.svn.sourceforge.net/skim-app/?rev=2495&view=rev Author: hofman Date: 2007-07-13 09:39:31 -0700 (Fri, 13 Jul 2007) Log Message: --- Implement spell checking. Modified Paths: -- trunk/SKPDFView.h trunk/SKPDFView.m Modified: trunk/SKPDFView.h === --- trunk/SKPDFView.h 2007-07-12 19:39:46 UTC (rev 2494) +++ trunk/SKPDFView.h 2007-07-13 16:39:31 UTC (rev 2495) @@ -111,6 +111,8 @@ int trackingRect; NSMutableArray *hoverRects; int hoverRect; + +int spellingTag; } - (SKToolMode)toolMode; Modified: trunk/SKPDFView.m === --- trunk/SKPDFView.m 2007-07-12 19:39:46 UTC (rev 2494) +++ trunk/SKPDFView.m 2007-07-13 16:39:31 UTC (rev 2495) @@ -150,6 +150,8 @@ toolMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastToolModeKey]; annotationMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastAnnotationModeKey]; +spellingTag = [NSSpellChecker uniqueSpellDocumentTag]; + hideNotes = NO; autohidesCursor = NO; @@ -205,6 +207,7 @@ } - (void)dealloc { +[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:spellingTag]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeys: [NSArray arrayWithObjects:SKReadingBarColorKey, SKReadingBarInvertKey, nil]]; [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -1232,6 +1235,60 @@ } } +- (void)checkSpellingStartingAtIndex:(int)index onPage:(PDFPage *)page { +unsigned int i, first = [[self document] indexForPage:page]; +unsigned int count = [[self document] pageCount]; +BOOL didWrap = NO; +i = first; +NSRange range = NSMakeRange(NSNotFound, 0); + +while (YES) { +range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:[page string] startingAt:index language:nil wrap:NO inSpellDocumentWithTag:spellingTag wordCount:NULL]; +if (range.location != NSNotFound) break; +if (++i >= count) { +i = 0; +didWrap = YES; +} +if (didWrap && i > first) break; +page = [[self document] pageAtIndex:i]; +index = 0; +} + +if (range.location != NSNotFound) { +PDFSelection *selection = [page selectionForRange:range]; +[self setCurrentSelection:selection]; +[self scrollRect:[selection boundsForPage:page] inPageToVisible:page]; +[[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:[selection string]]; +} else NSBeep(); +} + +- (void)checkSpelling:(id)sender { +PDFSelection *selection = [self currentSelection]; +PDFPage *page = [self currentPage]; +int index = 0; +if ([[selection pages] count]) { +page = [[selection pages] lastObject]; +index = NSMaxRange([selection safeRangeAtIndex:[selection safeNumberOfRangesOnPage:page] - 1 onPage:page]); +} +[self checkSpellingStartingAtIndex:index onPage:page]; +} + +- (void)showGuessPanel:(id)sender { +PDFSelection *selection = [self currentSelection]; +PDFPage *page = [self currentPage]; +int index = 0; +if ([[selection pages] count]) { +page = [[selection pages] objectAtIndex:0]; +index = [selection safeRangeAtIndex:0 onPage:page].location; +} +[self checkSpellingStartingAtIndex:index onPage:page]; +[[[NSSpellChecker sharedSpellChecker] spellingPanel] orderFront:self]; +} + +- (void)ignoreSpelling:(id)sender { +[[NSSpellChecker sharedSpellChecker] ignoreWord:[[sender selectedCell] stringValue] inSpellDocumentWithTag:spellingTag]; +} + #pragma mark Tracking mousemoved fix - (void)setFrame:(NSRect)frame { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit