mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Respond to next/previous tab actions in file/favorites chooser
This makes it possible to use ⌘{ and ⌘} to move between the source lists, which is consistent with other windows with multiple sources (like the Preferences and About windows).
Closes #1236.
This commit is contained in:
@@ -25,6 +25,7 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
|
||||
std::vector<std::pair<std::string, std::string>> favorites;
|
||||
}
|
||||
@property (nonatomic) NSInteger sourceIndex;
|
||||
@property (nonatomic) NSArray* sourceListLabels;
|
||||
@end
|
||||
|
||||
@implementation FavoriteChooser
|
||||
@@ -51,7 +52,8 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
|
||||
{
|
||||
if((self = [super init]))
|
||||
{
|
||||
_sourceIndex = NSNotFound;
|
||||
_sourceIndex = NSNotFound;
|
||||
_sourceListLabels = @[ @"Recent Projects", @"Favorites" ];
|
||||
|
||||
self.window.title = @"Open Favorite";
|
||||
self.window.frameAutosaveName = @"Open Favorite";
|
||||
@@ -62,7 +64,7 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
|
||||
[[self.tableView tableColumnWithIdentifier:@"name"] setDataCell:cell];
|
||||
|
||||
OakScopeBarView* scopeBar = [OakScopeBarView new];
|
||||
scopeBar.labels = @[ @"Recent Projects", @"Favorites" ];
|
||||
scopeBar.labels = self.sourceListLabels;
|
||||
|
||||
NSDictionary* views = @{
|
||||
@"searchField" : self.searchField,
|
||||
@@ -96,6 +98,9 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (IBAction)selectNextTab:(id)sender { self.sourceIndex = (self.sourceIndex + 1) % self.sourceListLabels.count; }
|
||||
- (IBAction)selectPreviousTab:(id)sender { self.sourceIndex = (self.sourceIndex + self.sourceListLabels.count - 1) % self.sourceListLabels.count; }
|
||||
|
||||
- (void)tableView:(NSTableView*)aTableView willDisplayCell:(OFBPathInfoCell*)cell forTableColumn:(NSTableColumn*)aTableColumn row:(NSInteger)rowIndex
|
||||
{
|
||||
if(![aTableColumn.identifier isEqualToString:@"name"])
|
||||
|
||||
@@ -201,6 +201,7 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
std::vector<document_record_t> _records;
|
||||
document::scanner_ptr _scanner;
|
||||
}
|
||||
@property (nonatomic) NSArray* sourceListLabels;
|
||||
@property (nonatomic) NSProgressIndicator* progressIndicator;
|
||||
|
||||
@property (nonatomic) BOOL polling;
|
||||
@@ -219,6 +220,8 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
{
|
||||
if((self = [super init]))
|
||||
{
|
||||
_sourceListLabels = @[ @"All", @"Open Documents", @"Uncommitted Documents" ];
|
||||
|
||||
[self.window setContentBorderThickness:57 forEdge:NSMaxYEdge];
|
||||
self.tableView.allowsMultipleSelection = YES;
|
||||
|
||||
@@ -227,7 +230,7 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
[[self.tableView tableColumnWithIdentifier:@"name"] setDataCell:cell];
|
||||
|
||||
OakScopeBarView* scopeBar = [OakScopeBarView new];
|
||||
scopeBar.labels = @[ @"All", @"Open Documents", @"Uncommitted Documents" ];
|
||||
scopeBar.labels = self.sourceListLabels;
|
||||
|
||||
_progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect];
|
||||
_progressIndicator.style = NSProgressIndicatorSpinningStyle;
|
||||
@@ -270,6 +273,9 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (IBAction)selectNextTab:(id)sender { self.sourceIndex = (self.sourceIndex + 1) % self.sourceListLabels.count; }
|
||||
- (IBAction)selectPreviousTab:(id)sender { self.sourceIndex = (self.sourceIndex + self.sourceListLabels.count - 1) % self.sourceListLabels.count; }
|
||||
|
||||
- (void)showWindow:(id)sender
|
||||
{
|
||||
if(_path && !_scmInfo)
|
||||
|
||||
Reference in New Issue
Block a user