diff --git a/GLFileView.m b/GLFileView.m index 7087130..512bfa3 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -639,14 +639,7 @@ -(IBAction)updateSearch:(NSSearchField *)sender { - NSString *searchString = [sender stringValue]; - DLog(@"searchString:%@",searchString); - - if([searchString length]>0){ - [view highlightAllOccurencesOfString:searchString]; - }else{ - [view removeAllHighlights]; - } + [view updateSearch:sender]; } #pragma mark - diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 30ae89a..5f632e9 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -138,6 +138,7 @@ 292 {{267, 3}, {71, 25}} + YES @@ -181,6 +182,7 @@ 268 {{206, 3}, {37, 25}} + YES @@ -206,6 +208,7 @@ 268 {{161, 3}, {37, 25}} + YES @@ -231,6 +234,7 @@ 268 {{116, 3}, {37, 25}} + YES @@ -256,6 +260,7 @@ 268 {{55, 3}, {37, 25}} + YES @@ -281,6 +286,7 @@ 268 {{10, 3}, {37, 25}} + YES @@ -306,6 +312,7 @@ 10 {{0, -2}, {955, 5}} + {0, 0} @@ -335,6 +342,7 @@ {{0, 404}, {955, 30}} + PBGitGradientBarView @@ -351,8 +359,9 @@ 10 - {{0, 144}, {955, 5}} + {{0, 140}, {955, 5}} + {0, 0} @@ -384,15 +393,17 @@ 4352 - {955, 130} + {955, 126} - + + YES 256 {955, 17} + @@ -401,6 +412,7 @@ -2147483392 {{-26, 0}, {16, 17}} + @@ -655,8 +667,9 @@ 0 - {{0, 17}, {955, 130}} + {{0, 17}, {955, 126}} + @@ -667,6 +680,7 @@ -2147483392 {{837, 17}, {15, 179}} + _doScroller: @@ -677,6 +691,7 @@ -2147483392 {{0, 123}, {852, 15}} + 1 @@ -693,6 +708,7 @@ {955, 17} + @@ -700,9 +716,10 @@ - {955, 147} + {955, 143} - + + 560 @@ -722,6 +739,7 @@ {{740, 3}, {16, 16}} + 20746 100 @@ -731,6 +749,7 @@ 265 {{765, 2}, {180, 19}} + YES @@ -793,6 +812,7 @@ 265 {{714, 3}, {43, 18}} + YES @@ -830,6 +850,7 @@ 265 {{630, 5}, {80, 14}} + YES @@ -852,6 +873,7 @@ 268 {{49, 2}, {57, 17}} + 1 YES @@ -878,6 +900,7 @@ 268 {{114, 2}, {103, 17}} + 2 YES @@ -900,6 +923,7 @@ 268 {{11, 2}, {30, 17}} + YES @@ -917,14 +941,16 @@ - {{0, 147}, {955, 24}} + {{0, 143}, {955, 24}} + PBGitGradientBarView - {955, 171} + {955, 167} + NSView @@ -936,8 +962,9 @@ 18 - {955, 233} + {955, 228} + YES @@ -1026,8 +1053,9 @@ 266 - {{5, 212.5}, {196, 19}} + {{5, 207}, {196, 19}} + YES @@ -1102,9 +1130,10 @@ 4368 - {190, 208} + {190, 203} - + + YES @@ -1157,8 +1186,9 @@ 0 - {{1, 1}, {190, 208}} + {{1, 1}, {190, 203}} + @@ -1167,8 +1197,9 @@ 256 - {{191, 1}, {15, 208}} + {{191, 1}, {15, 203}} + _doScroller: @@ -1179,6 +1210,7 @@ -2147483392 {{-100, -100}, {502, 15}} + 1 @@ -1187,9 +1219,10 @@ 0.99801188707351685 - {{0, 0.5}, {207, 210}} + {207, 205} - + + 18 @@ -1197,8 +1230,9 @@ QSAAAEEgAABBmAAAQZgAAA - {207, 235} + {207, 230} + NSView @@ -1222,6 +1256,7 @@ 268 {{50, 2}, {158, 19}} + YES @@ -1284,6 +1319,7 @@ 289 {{216, 1}, {29, 19}} + YES @@ -1311,12 +1347,14 @@ {{490, 0}, {259, 24}} - + + NSView - {{0, 211}, {749, 24}} + {{0, 206}, {749, 24}} + MGScopeBar @@ -1344,8 +1382,9 @@ public.url-name - {749, 210} + {749, 205} + @@ -1354,21 +1393,24 @@ YES - {{208, 0}, {749, 235}} + {{208, 0}, {749, 230}} + NSView - {{-1, -1}, {957, 235}} + {{-1, -1}, {957, 230}} + YES 2 - {955, 233} + {955, 228} + Tree @@ -1387,20 +1429,23 @@ - {{0, 172}, {955, 233}} + {{0, 177}, {955, 228}} + NSView {955, 405} + - 2 + 3 {955, 434} + NSView @@ -2907,7 +2952,6 @@ 18.IBPluginDependency 19.CustomClassName 19.IBPluginDependency - 2.CustomClassName 2.IBEditorWindowLastContentRect 2.IBPluginDependency 2.ImportedFromIB2 @@ -3030,7 +3074,6 @@ com.apple.InterfaceBuilder.CocoaPlugin PBIconAndTextCell com.apple.InterfaceBuilder.CocoaPlugin - PBCollapsibleSplitView {{312, 577}, {852, 384}} com.apple.InterfaceBuilder.CocoaPlugin @@ -3230,7 +3273,845 @@ 508 - + + + YES + + GLFileView + PBWebController + + updateSearch: + NSSearchField + + + updateSearch: + + updateSearch: + NSSearchField + + + + YES + + YES + accessoryView + fileListSplitView + historyController + searchField + typeBar + + + YES + NSView + NSSplitView + PBGitHistoryController + NSSearchField + MGScopeBar + + + + YES + + YES + accessoryView + fileListSplitView + historyController + searchField + typeBar + + + YES + + accessoryView + NSView + + + fileListSplitView + NSSplitView + + + historyController + PBGitHistoryController + + + searchField + NSSearchField + + + typeBar + MGScopeBar + + + + + IBProjectSource + ./Classes/GLFileView.h + + + + GitXRelativeDateFormatter + NSFormatter + + IBProjectSource + ./Classes/GitXRelativeDateFormatter.h + + + + GitXTextFieldCell + NSTextFieldCell + + contextMenuDelegate + id + + + contextMenuDelegate + + contextMenuDelegate + id + + + + IBProjectSource + ./Classes/GitXTextFieldCell.h + + + + MGScopeBar + NSView + + delegate + id + + + delegate + + delegate + id + + + + IBProjectSource + ./Classes/MGScopeBar.h + + + + PBCollapsibleSplitView + NSSplitView + + IBProjectSource + ./Classes/PBCollapsibleSplitView.h + + + + PBCommitList + NSTableView + + YES + + YES + controller + searchController + webController + webView + + + YES + PBGitHistoryController + PBHistorySearchController + PBWebHistoryController + WebView + + + + YES + + YES + controller + searchController + webController + webView + + + YES + + controller + PBGitHistoryController + + + searchController + PBHistorySearchController + + + webController + PBWebHistoryController + + + webView + WebView + + + + + IBProjectSource + ./Classes/PBCommitList.h + + + + PBGitGradientBarView + NSView + + IBProjectSource + ./Classes/PBGitGradientBarView.h + + + + PBGitHistoryController + PBViewController + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + toggleQLPreviewPanel: + updateSearch: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + toggleQLPreviewPanel: + updateSearch: + + + YES + + cherryPick: + id + + + createBranch: + id + + + createTag: + id + + + merge: + id + + + openSelectedFile: + id + + + rebase: + id + + + refresh: + id + + + selectNext: + id + + + selectPrevious: + id + + + setBranchFilter: + id + + + setDetailedView: + id + + + setTreeView: + id + + + showAddRemoteSheet: + id + + + toggleQLPreviewPanel: + id + + + updateSearch: + id + + + + + YES + + YES + allBranchesFilterItem + cherryPickButton + commitController + commitList + fileBrowser + fileView + filesSearchField + historySplitView + localRemoteBranchesFilterItem + mergeButton + rebaseButton + refController + scopeBarView + searchController + searchField + selectedBranchFilterItem + treeController + upperToolbarView + webHistoryController + webView + + + YES + NSButton + NSButton + NSArrayController + PBCommitList + NSOutlineView + GLFileView + NSSearchField + PBCollapsibleSplitView + NSButton + NSButton + NSButton + PBRefController + PBGitGradientBarView + PBHistorySearchController + NSSearchField + NSButton + NSTreeController + PBGitGradientBarView + PBWebHistoryController + id + + + + YES + + YES + allBranchesFilterItem + cherryPickButton + commitController + commitList + fileBrowser + fileView + filesSearchField + historySplitView + localRemoteBranchesFilterItem + mergeButton + rebaseButton + refController + scopeBarView + searchController + searchField + selectedBranchFilterItem + treeController + upperToolbarView + webHistoryController + webView + + + YES + + allBranchesFilterItem + NSButton + + + cherryPickButton + NSButton + + + commitController + NSArrayController + + + commitList + PBCommitList + + + fileBrowser + NSOutlineView + + + fileView + GLFileView + + + filesSearchField + NSSearchField + + + historySplitView + PBCollapsibleSplitView + + + localRemoteBranchesFilterItem + NSButton + + + mergeButton + NSButton + + + rebaseButton + NSButton + + + refController + PBRefController + + + scopeBarView + PBGitGradientBarView + + + searchController + PBHistorySearchController + + + searchField + NSSearchField + + + selectedBranchFilterItem + NSButton + + + treeController + NSTreeController + + + upperToolbarView + PBGitGradientBarView + + + webHistoryController + PBWebHistoryController + + + webView + id + + + + + IBProjectSource + ./Classes/PBGitHistoryController.h + + + + PBGitRevisionCell + NSActionCell + + YES + + YES + contextMenuDelegate + controller + + + YES + id + PBGitHistoryController + + + + YES + + YES + contextMenuDelegate + controller + + + YES + + contextMenuDelegate + id + + + controller + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBGitRevisionCell.h + + + + PBHistorySearchController + NSObject + + YES + + YES + stepperPressed: + updateSearch: + + + YES + id + id + + + + YES + + YES + stepperPressed: + updateSearch: + + + YES + + stepperPressed: + id + + + updateSearch: + id + + + + + YES + + YES + commitController + historyController + numberOfMatchesField + progressIndicator + searchField + stepper + + + YES + NSArrayController + PBGitHistoryController + NSTextField + NSProgressIndicator + NSSearchField + NSSegmentedControl + + + + YES + + YES + commitController + historyController + numberOfMatchesField + progressIndicator + searchField + stepper + + + YES + + commitController + NSArrayController + + + historyController + PBGitHistoryController + + + numberOfMatchesField + NSTextField + + + progressIndicator + NSProgressIndicator + + + searchField + NSSearchField + + + stepper + NSSegmentedControl + + + + + IBProjectSource + ./Classes/PBHistorySearchController.h + + + + PBIconAndTextCell + NSTextFieldCell + + IBProjectSource + ./Classes/PBIconAndTextCell.h + + + + PBQLOutlineView + NSOutlineView + + controller + PBGitHistoryController + + + controller + + controller + PBGitHistoryController + + + + IBProjectSource + ./Classes/PBQLOutlineView.h + + + + PBRefController + NSObject + + YES + + YES + branchPopUp + commitController + commitList + historyController + + + YES + NSPopUpButton + NSArrayController + PBCommitList + PBGitHistoryController + + + + YES + + YES + branchPopUp + commitController + commitList + historyController + + + YES + + branchPopUp + NSPopUpButton + + + commitController + NSArrayController + + + commitList + PBCommitList + + + historyController + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBRefController.h + + + + PBUnsortableTableHeader + NSTableHeaderView + + controller + NSArrayController + + + controller + + controller + NSArrayController + + + + IBProjectSource + ./Classes/PBUnsortableTableHeader.h + + + + PBViewController + NSViewController + + refresh: + id + + + refresh: + + refresh: + id + + + + IBProjectSource + ./Classes/PBViewController.h + + + + PBWebController + NSObject + + YES + + YES + repository + view + + + YES + id + WebView + + + + YES + + YES + repository + view + + + YES + + repository + id + + + view + WebView + + + + + IBProjectSource + ./Classes/PBWebController.h + + + + PBWebHistoryController + PBWebController + + YES + + YES + contextMenuDelegate + historyController + + + YES + id + PBGitHistoryController + + + + YES + + YES + contextMenuDelegate + historyController + + + YES + + contextMenuDelegate + id + + + historyController + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBWebHistoryController.h + + + + WebView + + reloadFromOrigin: + id + + + reloadFromOrigin: + + reloadFromOrigin: + id + + + + IBProjectSource + ./Classes/WebView.h + + + + 0 IBCocoaFramework diff --git a/SearchWebView.h b/SearchWebView.h index 1f90e46..6438df3 100644 --- a/SearchWebView.h +++ b/SearchWebView.h @@ -11,8 +11,9 @@ @interface WebView (SearchWebView) -- (NSInteger)highlightAllOccurencesOfString:(NSString*)str; +- (DOMRange *)highlightAllOccurencesOfString:(NSString*)str; - (NSInteger)highlightAllOccurencesOfString:(NSString*)str inNode:(DOMNode *)node; - (void)removeAllHighlights; +- (void)updateSearch:(NSSearchField *)sender; @end diff --git a/SearchWebView.m b/SearchWebView.m index 5a21e40..7daa148 100644 --- a/SearchWebView.m +++ b/SearchWebView.m @@ -50,19 +50,43 @@ return count; } -- (NSInteger)highlightAllOccurencesOfString:(NSString*)str +- (DOMRange *)highlightAllOccurencesOfString:(NSString*)str { NSInteger count=0; + DOMRange *res=nil; if([[[[self mainFrame] DOMDocument] documentElement] isKindOfClass:[DOMHTMLElement class]]){ DOMHTMLElement *dom=(DOMHTMLElement *)[[[self mainFrame] DOMDocument] documentElement]; if(![str isEqualToString:[dom getAttribute:@"searchStr"]]){ [self removeAllHighlights]; count=[self highlightAllOccurencesOfString:str inNode:dom]; + if(count>0){ + [dom setAttribute:@"searchStr" value:str]; + } + } + if([self searchFor:str direction:YES caseSensitive:NO wrap:YES]){ + res=[self selectedDOMRange]; } } - return count; + return res; +} + +- (void)updateSearch:(NSSearchField *)sender +{ + NSString *searchString = [sender stringValue]; + DLog(@"searchString:%@",searchString); + + DOMRange *selection; + + if([searchString length]>0){ + selection=[self highlightAllOccurencesOfString:searchString]; + [[sender window] makeFirstResponder:sender]; + if(selection!=nil) + [self setSelectedDOMRange:selection affinity:NSSelectionAffinityDownstream]; + }else{ + [self removeAllHighlights]; + } } - (void)removeAllHighlights:(DOMNode *)_node