Revision: 7230
http://skim-app.svn.sourceforge.net/skim-app/?rev=7230&view=rev
Author: hofman
Date: 2011-05-15 10:23:16 +0000 (Sun, 15 May 2011)
Log Message:
-----------
use arrows to go through multiple find results in table
Modified Paths:
--------------
trunk/SKFindTableView.h
trunk/SKFindTableView.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.h
trunk/SKMainWindowController_UI.m
Modified: trunk/SKFindTableView.h
===================================================================
--- trunk/SKFindTableView.h 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKFindTableView.h 2011-05-15 10:23:16 UTC (rev 7230)
@@ -39,6 +39,22 @@
#import <Cocoa/Cocoa.h>
#import "SKTableView.h"
+@protocol SKFindTableViewDelegate;
@interface SKFindTableView : SKTableView
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
+- (id <SKFindTableViewDelegate>)delegate;
+- (void)setDelegate:(id <SKFindTableViewDelegate>)newDelegate;
+#endif
+
@end
+
+
+@protocol SKFindTableViewDelegate <SKTableViewDelegate>
+@optional
+
+- (void)tableViewMoveLeft:(NSTableView *)aTableView;
+- (void)tableViewMoveRight:(NSTableView *)aTableView;
+
+@end
Modified: trunk/SKFindTableView.m
===================================================================
--- trunk/SKFindTableView.m 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKFindTableView.m 2011-05-15 10:23:16 UTC (rev 7230)
@@ -37,6 +37,7 @@
*/
#import "SKFindTableView.h"
+#import "NSEvent_SKExtensions.h"
#define PAGE_COLUMNID @"page"
@@ -46,4 +47,24 @@
[[[self tableColumnWithIdentifier:PAGE_COLUMNID] headerCell]
setTitle:NSLocalizedString(@"Page", @"Table header title")];
}
+- (void)keyDown:(NSEvent *)theEvent {
+ unichar eventChar = [theEvent firstCharacter];
+ NSUInteger modifierFlags = [theEvent standardModifierFlags];
+
+ if (eventChar == NSLeftArrowFunctionKey && modifierFlags == 0) {
+ if ([[self delegate] respondsToSelector:@selector(tableViewMoveLeft:)])
+ [[self delegate] tableViewMoveLeft:self];
+ } else if (eventChar == NSRightArrowFunctionKey && modifierFlags == 0) {
+ if ([[self delegate]
respondsToSelector:@selector(tableViewMoveRight:)])
+ [[self delegate] tableViewMoveRight:self];
+ } else {
+ [super keyDown:theEvent];
+ }
+}
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
+- (id <SKFindTableViewDelegate>)delegate { return
(<SKFindTableViewDelegate>)[super delegate]; }
+- (void)setDelegate:(id <SKFindTableViewDelegate>)newDelegate { [super
setDelegate:newDelegate]; }
+#endif
+
@end
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKMainWindowController.h 2011-05-15 10:23:16 UTC (rev 7230)
@@ -95,6 +95,7 @@
CGFloat roundedThumbnailSize;
NSMutableArray *searchResults;
+ NSInteger searchResultIndex;
NSMutableSet *temporaryAnnotations;
NSTimer *temporaryAnnotationTimer;
NSTimer *highlightTimer;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKMainWindowController.m 2011-05-15 10:23:16 UTC (rev 7230)
@@ -179,7 +179,7 @@
- (SKProgressController *)progressController;
- (void)goToSelectedFindResults:(id)sender;
-- (void)updateFindResultHighlights:(BOOL)scroll;
+- (void)updateFindResultHighlights:(BOOL)scroll direction:(NSInteger)direction;
- (void)selectSelectedNote:(id)sender;
- (void)goToSelectedOutlineItem:(id)sender;
@@ -224,6 +224,7 @@
if (self) {
interactionMode = SKNormalMode;
searchResults = [[NSMutableArray alloc] init];
+ searchResultIndex = 0;
mwcFlags.findPanelFind = 0;
mwcFlags.caseInsensitiveSearch = 1;
mwcFlags.wholeWordSearch = 0;
@@ -978,7 +979,7 @@
if ([leftSideController.findTableView window])
[self displayGroupedFindViewAnimating:NO];
}
- [self updateFindResultHighlights:YES];
+ [self updateFindResultHighlights:YES direction:0];
}
}
@@ -1790,7 +1791,7 @@
[pdfView setHighlightedSelections:nil];
}
-- (void)updateFindResultHighlights:(BOOL)scroll {
+- (void)updateFindResultHighlights:(BOOL)scroll direction:(NSInteger)direction
{
NSArray *findResults = nil;
if (mwcFlags.findPaneState == SKSingularFindPaneState &&
[leftSideController.findTableView window])
@@ -1798,21 +1799,31 @@
else if (mwcFlags.findPaneState == SKGroupedFindPaneState &&
[leftSideController.groupedFindTableView window])
findResults = [[leftSideController.groupedFindArrayController
selectedObjects] valueForKeyPath:@"@unionOfArrays.matches"];
+ if ([searchResults count] == 0 || direction == 0) {
+ searchResultIndex = 0;
+ } else if (direction == 1) {
+ if (++searchResultIndex >= (NSInteger)[findResults count])
+ searchResultIndex = [findResults count] - 1;
+ } else if (direction == -1) {
+ if (--searchResultIndex < 0)
+ searchResultIndex = 0;
+ }
+
+ PDFSelection *currentSel = [findResults count] > 0 ? [findResults
objectAtIndex:searchResultIndex] : nil;
+
+ // arm: PDFSelection is mutable, and using -addSelection on an object
from selectedObjects will actually mutate the object in searchResults, which
does bad things.
NSEnumerator *selE = [findResults objectEnumerator];
PDFSelection *sel;
+ PDFSelection *fullSel = [[[selE nextObject] copy] autorelease];
- // arm: PDFSelection is mutable, and using -addSelection on an object
from selectedObjects will actually mutate the object in searchResults, which
does bad things.
- PDFSelection *firstSel = [selE nextObject];
- PDFSelection *currentSel = [[firstSel copy] autorelease];
-
while (sel = [selE nextObject]) {
if ([sel hasCharacters])
- [currentSel addSelection:sel];
+ [fullSel addSelection:sel];
}
- if (scroll && [firstSel hasCharacters]) {
- PDFPage *page = [currentSel safeFirstPage];
- NSRect rect = NSIntersectionRect(NSInsetRect([currentSel
boundsForPage:page], -50.0, -50.0), [page boundsForBox:kPDFDisplayBoxCropBox]);
+ if (scroll && [currentSel hasCharacters]) {
+ PDFPage *page = [fullSel safeFirstPage];
+ NSRect rect = NSIntersectionRect(NSInsetRect([fullSel
boundsForPage:page], -50.0, -50.0), [page boundsForBox:kPDFDisplayBoxCropBox]);
[pdfView goToPage:page];
[pdfView goToRect:rect onPage:page];
}
@@ -1830,21 +1841,21 @@
if (highlightTimer)
[self removeHighlightedSelections:highlightTimer];
if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableAnimatedSearchHighlightKey] == NO && [findResults count] >
1) {
- PDFSelection *tmpSel = [[currentSel copy] autorelease];
+ PDFSelection *tmpSel = [[fullSel copy] autorelease];
[tmpSel setColor:[NSColor yellowColor]];
[pdfView setHighlightedSelections:[NSArray arrayWithObject:tmpSel]];
highlightTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0
target:self selector:@selector(removeHighlightedSelections:) userInfo:nil
repeats:NO] retain];
}
- if (scroll && [[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableAnimatedSearchHighlightKey] == NO && [firstSel
hasCharacters])
- [pdfView setCurrentSelection:firstSel animate:YES];
+ if (scroll && [[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableAnimatedSearchHighlightKey] == NO && [currentSel
hasCharacters])
+ [pdfView setCurrentSelection:currentSel animate:YES];
- if (scroll && currentSel)
- [pdfView setCurrentSelection:currentSel];
+ if (scroll && fullSel)
+ [pdfView setCurrentSelection:fullSel];
}
- (void)goToSelectedFindResults:(id)sender {
- [self updateFindResultHighlights:YES];
+ [self updateFindResultHighlights:YES direction:0];
}
- (IBAction)searchNotes:(id)sender {
@@ -2236,12 +2247,12 @@
[[leftSideController.searchField stringValue] length] &&
(([leftSideController.findTableView window] &&
[leftSideController.findTableView numberOfSelectedRows]) ||
([leftSideController.groupedFindTableView window] &&
[leftSideController.groupedFindTableView numberOfSelectedRows]))) {
// clear the selection
- [self updateFindResultHighlights:NO];
+ [self updateFindResultHighlights:NO direction:0];
}
} else if ([key isEqualToString:SKShouldHighlightSearchResultsKey]) {
if ([[leftSideController.searchField stringValue] length] &&
([leftSideController.findTableView numberOfSelectedRows] ||
[leftSideController.groupedFindTableView numberOfSelectedRows])) {
// clear the selection
- [self updateFindResultHighlights:NO];
+ [self updateFindResultHighlights:NO direction:0];
}
} else if ([key isEqualToString:SKThumbnailSizeKey]) {
[self resetThumbnailSizeIfNeeded];
Modified: trunk/SKMainWindowController_UI.h
===================================================================
--- trunk/SKMainWindowController_UI.h 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKMainWindowController_UI.h 2011-05-15 10:23:16 UTC (rev 7230)
@@ -39,12 +39,13 @@
#import <Cocoa/Cocoa.h>
#import "SKMainWindowController.h"
#import "SKThumbnailTableView.h"
+#import "SKFindTableView.h"
#import "SKTocOutlineView.h"
#import "SKNoteOutlineView.h"
#import "SKNoteTypeSheetController.h"
-@interface SKMainWindowController (UI) <NSWindowDelegate, NSDrawerDelegate,
SKThumbnailTableViewDelegate, NSTableViewDataSource, SKTocOutlineViewDelegate,
SKNoteOutlineViewDelegate, SKOutlineViewDataSource,
SKNoteTypeSheetControllerDelegate, NSMenuDelegate>
+@interface SKMainWindowController (UI) <NSWindowDelegate, NSDrawerDelegate,
SKThumbnailTableViewDelegate, SKFindTableViewDelegate, NSTableViewDataSource,
SKTocOutlineViewDelegate, SKNoteOutlineViewDelegate, SKOutlineViewDataSource,
SKNoteTypeSheetControllerDelegate, NSMenuDelegate>
- (void)registerForNotifications;
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2011-05-14 09:54:23 UTC (rev 7229)
+++ trunk/SKMainWindowController_UI.m 2011-05-15 10:23:16 UTC (rev 7230)
@@ -41,7 +41,6 @@
#import "SKLeftSideViewController.h"
#import "SKRightSideViewController.h"
#import "SKMainToolbarController.h"
-#import "SKFindTableView.h"
#import "SKPDFView.h"
#import "SKStatusBar.h"
#import "SKSnapshotWindowController.h"
@@ -99,7 +98,7 @@
- (void)updateNoteFilterPredicate;
-- (void)updateFindResultHighlights:(BOOL)scroll;
+- (void)updateFindResultHighlights:(BOOL)scroll direction:(NSInteger)direction;
- (void)observeUndoManagerCheckpoint:(NSNotification *)notification;
@@ -361,7 +360,7 @@
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
if ([[aNotification object] isEqual:leftSideController.findTableView] ||
[[aNotification object] isEqual:leftSideController.groupedFindTableView]) {
- [self updateFindResultHighlights:YES];
+ [self updateFindResultHighlights:YES direction:0];
if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults
standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
[self hideLeftSideWindow];
@@ -493,6 +492,19 @@
return nil;
}
+
+- (void)tableViewMoveLeft:(NSTableView *)tv {
+ if (([tv isEqual:leftSideController.findTableView] || [tv
isEqual:leftSideController.groupedFindTableView])) {
+ [self updateFindResultHighlights:YES direction:-1];
+ }
+}
+
+- (void)tableViewMoveRight:(NSTableView *)tv {
+ if (([tv isEqual:leftSideController.findTableView] || [tv
isEqual:leftSideController.groupedFindTableView])) {
+ [self updateFindResultHighlights:YES direction:1];
+ }
+}
+
- (BOOL)tableView:(NSTableView *)tv
hasImageContextForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row {
if (([tv isEqual:leftSideController.findTableView] || [tv
isEqual:leftSideController.groupedFindTableView]))
return [[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableTableToolTipsKey] == NO;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit