mirror of
https://github.com/TermiT/Flycut.git
synced 2025-10-09 13:27:20 +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;
|
-(void)hitMainHotKey:(SGHotKey *)hotKey;
|
||||||
|
|
||||||
// Bezel related
|
// Bezel related
|
||||||
|
-(void) updateBezel;
|
||||||
-(void) showBezel;
|
-(void) showBezel;
|
||||||
-(void) hideBezel;
|
-(void) hideBezel;
|
||||||
-(void) processBezelKeyDown:(NSEvent *)theEvent;
|
-(void) processBezelKeyDown:(NSEvent *)theEvent;
|
||||||
|
|
|
@ -348,35 +348,36 @@
|
||||||
case NSHomeFunctionKey:
|
case NSHomeFunctionKey:
|
||||||
if ( [clippingStore jcListCount] > 0 ) {
|
if ( [clippingStore jcListCount] > 0 ) {
|
||||||
stackPosition = 0;
|
stackPosition = 0;
|
||||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d",
|
[self updateBezel];
|
||||||
1, [clippingStore jcListCount]]];
|
|
||||||
|
|
||||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSEndFunctionKey:
|
case NSEndFunctionKey:
|
||||||
if ( [clippingStore jcListCount] > 0 ) {
|
if ( [clippingStore jcListCount] > 0 ) {
|
||||||
stackPosition = [clippingStore jcListCount] - 1;
|
stackPosition = [clippingStore jcListCount] - 1;
|
||||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
[self updateBezel];
|
||||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSPageUpFunctionKey:
|
case NSPageUpFunctionKey:
|
||||||
if ( [clippingStore jcListCount] > 0 ) {
|
if ( [clippingStore jcListCount] > 0 ) {
|
||||||
stackPosition = stackPosition - 10; if ( stackPosition < 0 ) stackPosition = 0;
|
stackPosition = stackPosition - 10; if ( stackPosition < 0 ) stackPosition = 0;
|
||||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
[self updateBezel];
|
||||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSPageDownFunctionKey:
|
case NSPageDownFunctionKey:
|
||||||
if ( [clippingStore jcListCount] > 0 ) {
|
if ( [clippingStore jcListCount] > 0 ) {
|
||||||
stackPosition = stackPosition + 10; if ( stackPosition >= [clippingStore jcListCount] ) stackPosition = [clippingStore jcListCount] - 1;
|
stackPosition = stackPosition + 10; if ( stackPosition >= [clippingStore jcListCount] ) stackPosition = [clippingStore jcListCount] - 1;
|
||||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
[self updateBezel];
|
||||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NSBackspaceCharacter: break;
|
case NSBackspaceCharacter:
|
||||||
case NSDeleteCharacter: break;
|
case NSDeleteCharacter:
|
||||||
|
if ([clippingStore jcListCount] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
[clippingStore clearItem:stackPosition];
|
||||||
|
[self updateBezel];
|
||||||
|
[self updateMenu];
|
||||||
|
break;
|
||||||
case NSDeleteFunctionKey: break;
|
case NSDeleteFunctionKey: break;
|
||||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // Numeral
|
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // Numeral
|
||||||
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
||||||
|
@ -403,14 +404,28 @@
|
||||||
[self toggleMainHotKey:[NSNull null]];
|
[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
|
- (void) showBezel
|
||||||
{
|
{
|
||||||
if ( [clippingStore jcListCount] > 0 && [clippingStore jcListCount] > stackPosition ) {
|
[self updateBezel];
|
||||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
if ([bezel respondsToSelector:@selector(setCollectionBehavior:)]) {
|
||||||
[bezel setText:[clippingStore clippingContentsAtPosition:stackPosition]];
|
[bezel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
|
||||||
}
|
[bezel makeKeyAndOrderFront:nil];
|
||||||
if ([bezel respondsToSelector:@selector(setCollectionBehavior:)])
|
}
|
||||||
[bezel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; [bezel makeKeyAndOrderFront:nil];
|
|
||||||
isBezelDisplayed = YES;
|
isBezelDisplayed = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type;
|
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type;
|
||||||
|
|
||||||
// Delete a clipping
|
// Delete a clipping
|
||||||
|
-(void) clearItem:(int)index;
|
||||||
|
|
||||||
// Delete all list clippings
|
// Delete all list clippings
|
||||||
-(void) clearList;
|
-(void) clearList;
|
||||||
|
|
|
@ -79,6 +79,10 @@
|
||||||
jcList = emptyJCList;
|
jcList = emptyJCList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) clearItem:(int)index
|
||||||
|
{
|
||||||
|
[jcList removeObjectAtIndex:index];
|
||||||
|
}
|
||||||
|
|
||||||
// Set various values
|
// Set various values
|
||||||
-(void) setRememberNum:(int)nowRemembering
|
-(void) setRememberNum:(int)nowRemembering
|
||||||
|
|
Loading…
Add table
Reference in a new issue