mirror of
https://github.com/TermiT/Flycut.git
synced 2025-09-27 23:45:48 +08:00
New: Ability to delete clippings from the bezel with the delete key. Improved: Consolidated the logic for updating the bezel's content.
This commit is contained in:
parent
c268fa20ab
commit
6306e6a6d0
4 changed files with 40 additions and 19 deletions
|
@ -75,6 +75,7 @@
|
|||
-(void)hitMainHotKey:(SGHotKey *)hotKey;
|
||||
|
||||
// Bezel related
|
||||
-(void) updateBezel;
|
||||
-(void) showBezel;
|
||||
-(void) hideBezel;
|
||||
-(void) processBezelKeyDown:(NSEvent *)theEvent;
|
||||
|
|
|
@ -348,35 +348,36 @@
|
|||
case NSHomeFunctionKey:
|
||||
if ( [clippingStore jcListCount] > 0 ) {
|
||||
stackPosition = 0;
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d",
|
||||
1, [clippingStore jcListCount]]];
|
||||
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
[self updateBezel];
|
||||
}
|
||||
break;
|
||||
case NSEndFunctionKey:
|
||||
if ( [clippingStore jcListCount] > 0 ) {
|
||||
stackPosition = [clippingStore jcListCount] - 1;
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
[self updateBezel];
|
||||
}
|
||||
break;
|
||||
case NSPageUpFunctionKey:
|
||||
if ( [clippingStore jcListCount] > 0 ) {
|
||||
stackPosition = stackPosition - 10; if ( stackPosition < 0 ) stackPosition = 0;
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
[self updateBezel];
|
||||
}
|
||||
break;
|
||||
case NSPageDownFunctionKey:
|
||||
if ( [clippingStore jcListCount] > 0 ) {
|
||||
stackPosition = stackPosition + 10; if ( stackPosition >= [clippingStore jcListCount] ) stackPosition = [clippingStore jcListCount] - 1;
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
}
|
||||
[self updateBezel];
|
||||
}
|
||||
break;
|
||||
case NSBackspaceCharacter: break;
|
||||
case NSDeleteCharacter: break;
|
||||
case NSBackspaceCharacter:
|
||||
case NSDeleteCharacter:
|
||||
if ([clippingStore jcListCount] == 0)
|
||||
return;
|
||||
|
||||
[clippingStore clearItem:stackPosition];
|
||||
[self updateBezel];
|
||||
[self updateMenu];
|
||||
break;
|
||||
case NSDeleteFunctionKey: break;
|
||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // Numeral
|
||||
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
||||
|
@ -403,14 +404,28 @@
|
|||
[self toggleMainHotKey:[NSNull null]];
|
||||
}
|
||||
|
||||
- (void) updateBezel
|
||||
{
|
||||
if (stackPosition >= [clippingStore jcListCount] && stackPosition != 0) { // deleted last item
|
||||
stackPosition = [clippingStore jcListCount] - 1;
|
||||
}
|
||||
if (stackPosition == 0 && [clippingStore jcListCount] == 0) { // empty
|
||||
[bezel setText:@""];
|
||||
[bezel setCharString:@"Empty"];
|
||||
}
|
||||
else { // normal
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) showBezel
|
||||
{
|
||||
if ( [clippingStore jcListCount] > 0 && [clippingStore jcListCount] > stackPosition ) {
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
||||
}
|
||||
if ([bezel respondsToSelector:@selector(setCollectionBehavior:)])
|
||||
[bezel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; [bezel makeKeyAndOrderFront:nil];
|
||||
[self updateBezel];
|
||||
if ([bezel respondsToSelector:@selector(setCollectionBehavior:)]) {
|
||||
[bezel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
|
||||
[bezel makeKeyAndOrderFront:nil];
|
||||
}
|
||||
isBezelDisplayed = YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type;
|
||||
|
||||
// Delete a clipping
|
||||
-(void) clearItem:(int)index;
|
||||
|
||||
// Delete all list clippings
|
||||
-(void) clearList;
|
||||
|
|
|
@ -79,6 +79,10 @@
|
|||
jcList = emptyJCList;
|
||||
}
|
||||
|
||||
-(void) clearItem:(int)index
|
||||
{
|
||||
[jcList removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
// Set various values
|
||||
-(void) setRememberNum:(int)nowRemembering
|
||||
|
|
Loading…
Add table
Reference in a new issue