Skip to content

Commit

Permalink
• more refactoring
Browse files Browse the repository at this point in the history
Except for moving out the use of CLIProxy (and then move to the new argument interface) I think I am done with this stuff… oh, except for renaming the file(s).


git-svn-id: http://svn.textmate.org/branches/WIP/Tools/Dialog2@10598 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
duff committed Sep 18, 2008
1 parent f9f6b6d commit bc23ba3
Showing 1 changed file with 35 additions and 78 deletions.
113 changes: 35 additions & 78 deletions Commands/ExtendedPopUp/TMDIncrementalPopUpMenu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ - (NSRect)rectOfMainScreen;
- (NSString*)filterString;
- (void)setupInterface;
- (void)filter;
- (void)keyDown:(NSEvent*)anEvent;
- (void)tab;
- (void)completeAndInsertSnippet:(id)nothing;
- (void)insertCommonPrefix;
- (void)completeAndInsertSnippet;
@end

@implementation TMDIncrementalPopUpMenu
Expand Down Expand Up @@ -184,7 +183,7 @@ - (void)setupInterface
}

// ========================
// = TableView Datasource =
// = TableView DataSource =
// ========================

- (int)numberOfRowsInTableView:(NSTableView *)aTableView
Expand Down Expand Up @@ -317,63 +316,52 @@ - (void)watchUserEvents
}
else if(t == NSKeyDown)
{
NSString* aString = [event characters];
unsigned int flags = [event modifierFlags];
unichar key = 0;
unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0;
if((flags & NSControlKeyMask) || (flags & NSAlternateKeyMask) || (flags & NSCommandKeyMask))
{
[NSApp sendEvent:event];
break;
}
else if([aString length] == 1)
else if([event keyCode] == 53) // escape
{
key = [aString characterAtIndex:0];
if(key == NSCarriageReturnCharacter)
{
[self keyDown:event];
break;
}
else if(key == NSCarriageReturnCharacter)
{
[self completeAndInsertSnippet];
}
else if(key == NSBackspaceCharacter || key == NSDeleteCharacter)
{
[NSApp sendEvent:event];
if([mutablePrefix length] == 0)
break;
}
else if(key == NSBackspaceCharacter || key == NSDeleteCharacter)

[mutablePrefix deleteCharactersInRange:NSMakeRange([mutablePrefix length]-1, 1)];
[self filter];
}
else if(key == NSTabCharacter)
{
if([filtered count] == 0)
{
[NSApp sendEvent:event];
if([mutablePrefix length] > 0)
{
[self keyDown:event];
}
else
{
break;
}
}
else if ([event keyCode] == 53) // escape
{
break;
}
else if(key == NSTabCharacter)
else if([filtered count] == 1)
{
if([filtered count] == 0)
{
[NSApp sendEvent:event];
break;
}
if([filtered count] == 1)
{
[self keyDown:event];
break;
}
[self keyDown:event];
}
else if([textualInputCharacters characterIsMember:key])
{
[NSApp sendEvent:event];
[self keyDown:event];
[self completeAndInsertSnippet];
}
else
{
[NSApp sendEvent:event];
break;
[self insertCommonPrefix];
}
}
else if([textualInputCharacters characterIsMember:key])
{
[NSApp sendEvent:event];
[mutablePrefix appendString:[event characters]];
[self filter];
}
else
{
[NSApp sendEvent:event];
Expand All @@ -383,11 +371,11 @@ - (void)watchUserEvents
else if(t == NSRightMouseDown || t == NSLeftMouseDown)
{
[NSApp sendEvent:event];
if(! NSPointInRect([NSEvent mouseLocation], [self frame]))
if(!NSPointInRect([NSEvent mouseLocation], [self frame]))
break;
}
else
{
{
[NSApp sendEvent:event];
}
}
Expand All @@ -398,38 +386,7 @@ - (void)watchUserEvents
// = Action methods =
// ==================

- (void)keyDown:(NSEvent*)anEvent
{
NSString* aString = [anEvent characters];
unichar key = 0;
if([aString length] == 1)
{
key = [aString characterAtIndex:0];
if(key == NSBackspaceCharacter || key == NSDeleteCharacter)
{
[mutablePrefix deleteCharactersInRange:NSMakeRange([mutablePrefix length]-1,1)];
[self filter];
}
else if(key == NSCarriageReturnCharacter)
{
[self completeAndInsertSnippet:nil];
}
else if([aString isEqualToString:@"\t"])
{
if([filtered count] == 1)
[self completeAndInsertSnippet:nil];
else
[self tab];
}
else
{
[mutablePrefix appendString:aString];
[self filter];
}
}
}

- (void)tab
- (void)insertCommonPrefix
{
int row = [theTableView selectedRow];
if(row == -1 || row == [filtered count]-1)
Expand All @@ -452,7 +409,7 @@ - (void)tab
}
}

- (void)completeAndInsertSnippet:(id)nothing
- (void)completeAndInsertSnippet
{
if([theTableView selectedRow] == -1)
return;
Expand Down

0 comments on commit bc23ba3

Please sign in to comment.