Browse Source

Initial release

master
lint 4 years ago
parent
commit
6cc1b30a2c
4 changed files with 92 additions and 0 deletions
  1. +12
    -0
      Makefile
  2. +1
    -0
      NewTermArrows.plist
  3. +70
    -0
      Tweak.xm
  4. +9
    -0
      control

+ 12
- 0
Makefile View 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
- 0
NewTermArrows.plist View File

@@ -0,0 +1 @@
{ Filter = { Bundles = ( "ws.hbang.Terminal" ); }; }

+ 70
- 0
Tweak.xm View 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"));

}

+ 9
- 0
control View File

@@ -0,0 +1,9 @@
Package: com.lint.ntarrows
Name: NewTermArrows
Depends: mobilesubstrate
Version: 1.0.0
Architecture: iphoneos-arm
Description: Allows you to hold down the arrow keys to move the cursor in New Term.
Maintainer: lint
Author: lint
Section: Tweaks

Loading…
Cancel
Save