diff --git a/macosx/English.lproj/PrefsWindow.nib/info.nib b/macosx/English.lproj/PrefsWindow.nib/info.nib index f28b7714d..71bcdfda3 100644 --- a/macosx/English.lproj/PrefsWindow.nib/info.nib +++ b/macosx/English.lproj/PrefsWindow.nib/info.nib @@ -7,19 +7,19 @@ <key>IBEditorPositions</key> <dict> <key>153</key> - <string>299 469 554 217 0 0 1152 842 </string> + <string>155 441 554 217 0 0 1152 842 </string> <key>28</key> - <string>124 423 554 295 0 0 1152 842 </string> + <string>229 409 554 290 0 0 1152 842 </string> <key>41</key> - <string>299 417 554 321 0 0 1152 842 </string> + <string>125 133 554 321 0 0 1152 842 </string> <key>66</key> - <string>299 526 554 104 0 0 1152 842 </string> + <string>212 526 554 104 0 0 1152 842 </string> </dict> <key>IBFramework Version</key> <string>446.1</string> <key>IBOpenObjects</key> <array> - <integer>28</integer> + <integer>66</integer> </array> <key>IBSystem Version</key> <string>8J135</string> diff --git a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib index c5563bf33..aac017554 100644 Binary files a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib and b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib differ diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 44dc59fdf..8a688336e 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -41,6 +41,8 @@ IBOutlet NSMenu * fContextRow, * fContextNoRow; NSImage * fResumeOnIcon, * fResumeOffIcon, * fPauseOnIcon, * fPauseOffIcon, * fRevealOnIcon, * fRevealOffIcon; + + NSMutableArray * fKeyStrokes; } - (void) setTorrents: (NSArray *) torrents; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 5f2ea752f..d94871ff2 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -59,6 +59,8 @@ fClickPoint = NSZeroPoint; + fKeyStrokes = [[NSMutableArray alloc] init]; + fDefaults = [NSUserDefaults standardUserDefaults]; } @@ -71,6 +73,12 @@ [fContextNoRow setTitle: @"Context"]; } +- (void) dealloc +{ + [fKeyStrokes release]; + [super dealloc]; +} + - (void) setTorrents: (NSArray *) torrents { fTorrents = torrents; @@ -143,6 +151,54 @@ } } +- (void) keyDown: (NSEvent *) event +{ + unichar newChar = [[event characters] characterAtIndex: 0]; + if (newChar == ' ' || [[NSCharacterSet alphanumericCharacterSet] characterIsMember: newChar]) + { + if ([fKeyStrokes count] > 0 && [event timestamp] - [[fKeyStrokes lastObject] timestamp] > 1.0) + [fKeyStrokes removeAllObjects]; + [fKeyStrokes addObject: event]; + + [self interpretKeyEvents: fKeyStrokes]; + } + else + { + if ([fKeyStrokes count] > 0) + [fKeyStrokes removeAllObjects]; + + [super keyDown: event]; + } +} + +- (void) insertText: (NSString *) text +{ + NSLog(text); + + //sort torrents by name before finding closest match + NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES] autorelease]; + NSArray * descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, nil]; + + NSArray * tempTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors]; + [descriptors release]; + + //select torrent closest to text that isn't before text alphabetically + NSEnumerator * enumerator = [tempTorrents objectEnumerator]; + Torrent * torrent; + while ((torrent = [enumerator nextObject])) + { + if ([[torrent name] caseInsensitiveCompare: text] != NSOrderedAscending) + { + [self selectRow: [fTorrents indexOfObject: torrent] byExtendingSelection: NO]; + break; + } + } + + //select last torrent alphabetically if no match found + if (!torrent) + [self selectRow: [fTorrents indexOfObject: [tempTorrents lastObject]] byExtendingSelection: NO]; +} + - (void) drawRect: (NSRect) r { NSRect rect;