mirror of
https://github.com/lint/NewTermArrows
synced 2025-07-04 03:36:47 +00:00
Initial release
This commit is contained in:
12
Makefile
Normal file
12
Makefile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
ARCHS = arm64 arm64e
|
||||||
|
|
||||||
|
include $(THEOS)/makefiles/common.mk
|
||||||
|
|
||||||
|
TWEAK_NAME = NewTermArrows
|
||||||
|
NewTermArrows_FILES = Tweak.xm
|
||||||
|
NewTermArrows_CFLAGS += -fobjc-arc
|
||||||
|
|
||||||
|
include $(THEOS_MAKE_PATH)/tweak.mk
|
||||||
|
|
||||||
|
after-install::
|
||||||
|
install.exec "killall -9 NewTerm"
|
1
NewTermArrows.plist
Normal file
1
NewTermArrows.plist
Normal file
@ -0,0 +1 @@
|
|||||||
|
{ Filter = { Bundles = ( "ws.hbang.Terminal" ); }; }
|
70
Tweak.xm
Normal file
70
Tweak.xm
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
@interface TerminalKeyInput
|
||||||
|
-(void)upKeyPressed;
|
||||||
|
-(void)downKeyPressed;
|
||||||
|
-(void)leftKeyPressed;
|
||||||
|
-(void)rightKeyPressed;
|
||||||
|
|
||||||
|
@property(strong, nonatomic) NSTimer *haTimer;
|
||||||
|
-(void) haHandleLongPress:(UILongPressGestureRecognizer *) arg1;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
%hook TerminalKeyInput
|
||||||
|
%property(strong, nonatomic) NSTimer *haTimer;
|
||||||
|
|
||||||
|
-(id) initWithFrame:(CGRect) arg1 {
|
||||||
|
id orig = %orig;
|
||||||
|
|
||||||
|
UILongPressGestureRecognizer *upLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(haHandleLongPress:)];
|
||||||
|
UILongPressGestureRecognizer *downLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(haHandleLongPress:)];
|
||||||
|
UILongPressGestureRecognizer *leftLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(haHandleLongPress:)];
|
||||||
|
UILongPressGestureRecognizer *rightLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(haHandleLongPress:)];
|
||||||
|
|
||||||
|
id keyboardToolbar = MSHookIvar<id>(self, "toolbar");
|
||||||
|
|
||||||
|
[MSHookIvar<UIButton *>(keyboardToolbar, "upKey") addGestureRecognizer:upLongPress];
|
||||||
|
[MSHookIvar<UIButton *>(keyboardToolbar, "downKey") addGestureRecognizer:downLongPress];
|
||||||
|
[MSHookIvar<UIButton *>(keyboardToolbar, "leftKey") addGestureRecognizer:leftLongPress];
|
||||||
|
[MSHookIvar<UIButton *>(keyboardToolbar, "rightKey") addGestureRecognizer:rightLongPress];
|
||||||
|
|
||||||
|
return orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
-(void) haHandleLongPress:(UILongPressGestureRecognizer *) recognizer {
|
||||||
|
|
||||||
|
NSString *keyName = [[recognizer view] accessibilityLabel];
|
||||||
|
|
||||||
|
if (recognizer.state == UIGestureRecognizerStateBegan){
|
||||||
|
|
||||||
|
if (![self haTimer]){
|
||||||
|
if ([keyName isEqualToString:@"Up"]){
|
||||||
|
[self setHaTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(upKeyPressed) userInfo:nil repeats:YES]];
|
||||||
|
} else if ([keyName isEqualToString:@"Down"]){
|
||||||
|
[self setHaTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(downKeyPressed) userInfo:nil repeats:YES]];
|
||||||
|
} else if ([keyName isEqualToString:@"Left"]){
|
||||||
|
[self setHaTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(leftKeyPressed) userInfo:nil repeats:YES]];
|
||||||
|
} else if ([keyName isEqualToString:@"Right"]){
|
||||||
|
[self setHaTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(rightKeyPressed) userInfo:nil repeats:YES]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (recognizer.state == UIGestureRecognizerStateEnded){
|
||||||
|
|
||||||
|
if ([self haTimer]){
|
||||||
|
[[self haTimer] invalidate];
|
||||||
|
[self setHaTimer:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
|
|
||||||
|
%ctor {
|
||||||
|
|
||||||
|
%init(TerminalKeyInput = objc_getClass("NewTerm.TerminalKeyInput"));
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user