Skip to content

Commit dad428c

Browse files
committed
Add settings toggle for scroll-to-input
Adds a "Scroll to send input" preference under Settings → External Keyboard → Scrolling, defaulting to off. When disabled, touch scrolling uses the original scrollback-only behavior.
1 parent f566908 commit dad428c

5 files changed

Lines changed: 58 additions & 1 deletion

File tree

app/AboutExternalKeyboardViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ @interface AboutExternalKeyboardViewController ()
1717
@property (weak, nonatomic) IBOutlet UISwitch *backtickEscapeSwitch;
1818
@property (weak, nonatomic) IBOutlet UISwitch *overrideControlSpaceSwitch;
1919
@property (weak, nonatomic) IBOutlet UISwitch *hideExtraKeysWithExternalKeyboardSwitch;
20+
@property (weak, nonatomic) IBOutlet UISwitch *scrollToSendInputSwitch;
2021

2122
@end
2223

@@ -38,6 +39,7 @@ - (void)_update {
3839
self.backtickEscapeSwitch.on = UserPreferences.shared.backtickMapEscape;
3940
self.overrideControlSpaceSwitch.on = UserPreferences.shared.overrideControlSpace;
4041
self.hideExtraKeysWithExternalKeyboardSwitch.on = UserPreferences.shared.hideExtraKeysWithExternalKeyboard;
42+
self.scrollToSendInputSwitch.on = UserPreferences.shared.scrollToSendInput;
4143
}
4244

4345
- (IBAction)optionMetaToggle:(UISwitch *)sender {
@@ -52,6 +54,9 @@ - (IBAction)overrideControlSpaceToggle:(UISwitch *)sender {
5254
- (IBAction)hideExtraKeysToggle:(UISwitch *)sender {
5355
UserPreferences.shared.hideExtraKeysWithExternalKeyboard = sender.on;
5456
}
57+
- (IBAction)scrollToSendInputToggle:(UISwitch *)sender {
58+
UserPreferences.shared.scrollToSendInput = sender.on;
59+
}
5560

5661
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
5762
if (indexPath.section == kCapsLockMappingSection && cell.tag == UserPreferences.shared.capsLockMapping)

app/Base.lproj/About.storyboard

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,39 @@
600600
</tableViewCell>
601601
</cells>
602602
</tableViewSection>
603+
<tableViewSection headerTitle="Scrolling" footerTitle="Sends scroll gestures as input to programs like tmux, less, and vim instead of scrolling the terminal buffer." id="sSi-7k-RmQ">
604+
<cells>
605+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="qLs-3v-Kx9" userLabel="Scroll To Send Input">
606+
<rect key="frame" x="0.0" y="560" width="320" height="43.5"/>
607+
<autoresizingMask key="autoresizingMask"/>
608+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qLs-3v-Kx9" id="bNe-4h-Yw2">
609+
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
610+
<autoresizingMask key="autoresizingMask"/>
611+
<subviews>
612+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Scroll to send input" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pXw-5m-Rj3">
613+
<rect key="frame" x="16" y="11.5" width="160" height="21"/>
614+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
615+
<nil key="textColor"/>
616+
<nil key="highlightedColor"/>
617+
</label>
618+
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="mVt-8c-Zw1">
619+
<rect key="frame" x="255" y="6.5" width="51" height="31"/>
620+
<connections>
621+
<action selector="scrollToSendInputToggle:" destination="Zzy-IN-laJ" eventType="valueChanged" id="aKp-2n-Xf4"/>
622+
</connections>
623+
</switch>
624+
</subviews>
625+
<constraints>
626+
<constraint firstItem="pXw-5m-Rj3" firstAttribute="leading" secondItem="bNe-4h-Yw2" secondAttribute="leadingMargin" id="tRm-6k-Hq1"/>
627+
<constraint firstItem="pXw-5m-Rj3" firstAttribute="centerY" secondItem="bNe-4h-Yw2" secondAttribute="centerY" id="uKp-3m-Wn7"/>
628+
<constraint firstAttribute="trailingMargin" secondItem="mVt-8c-Zw1" secondAttribute="trailing" id="vQr-9p-Xs2"/>
629+
<constraint firstItem="mVt-8c-Zw1" firstAttribute="centerY" secondItem="bNe-4h-Yw2" secondAttribute="centerY" id="wLn-4q-Yt8"/>
630+
<constraint firstItem="mVt-8c-Zw1" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="pXw-5m-Rj3" secondAttribute="trailing" constant="8" symbolic="YES" id="xMo-5r-Zu3"/>
631+
</constraints>
632+
</tableViewCellContentView>
633+
</tableViewCell>
634+
</cells>
635+
</tableViewSection>
603636
</sections>
604637
<connections>
605638
<outlet property="dataSource" destination="Zzy-IN-laJ" id="NPA-6F-jMj"/>
@@ -612,6 +645,7 @@
612645
<outlet property="hideExtraKeysWithExternalKeyboardSwitch" destination="IcN-9M-x1K" id="Lw3-4l-9R6"/>
613646
<outlet property="optionMetaSwitch" destination="OEG-YY-LTw" id="b2K-Ug-Jij"/>
614647
<outlet property="overrideControlSpaceSwitch" destination="554-OF-h41" id="js8-8D-1Ua"/>
648+
<outlet property="scrollToSendInputSwitch" destination="mVt-8c-Zw1" id="rKs-6t-Bv5"/>
615649
</connections>
616650
</tableViewController>
617651
<placeholder placeholderIdentifier="IBFirstResponder" id="XlH-jX-0dL" userLabel="First Responder" sceneMemberID="firstResponder"/>

app/TerminalView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
275275

276276
CGFloat delta = newY - _prevScrollY;
277277
_prevScrollY = newY;
278-
if (delta != 0) {
278+
if (delta != 0 && UserPreferences.shared.scrollToSendInput) {
279279
[self.terminal.webView evaluateJavaScript:[NSString stringWithFormat:@"exports.handleScrollDelta(%f)", delta] completionHandler:nil];
280280
}
281281
}

app/UserPreferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern NSString *const kThemeBackgroundColor;
5252
@property BOOL hideExtraKeysWithExternalKeyboard;
5353
@property BOOL overrideControlSpace;
5454
@property BOOL hideStatusBar;
55+
@property BOOL scrollToSendInput;
5556
@property (nonatomic) Theme *theme;
5657
@property (nonatomic) Palette *palette;
5758
@property BOOL shouldDisableDimming;

app/UserPreferences.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
static NSString *const kPreferenceCursorStyleKey = @"Cursor Style";
2626
static NSString *const kPreferenceBlinkCursorKey = @"Blink Cursor";
2727
NSString *const kPreferenceHideStatusBarKey = @"Status Bar";
28+
static NSString *const kPreferenceScrollToSendInputKey = @"Scroll To Send Input";
2829
static NSString *const kPreferenceColorSchemeKey = @"Color Scheme";
2930
// This key has a different naming scheme because it's used in UI tests as a
3031
// CLI argument.
@@ -165,6 +166,7 @@ - (instancetype)init {
165166
kPreferenceBlinkCursorKey: @(NO),
166167
kPreferenceCursorStyleKey: @(CursorStyleBlock),
167168
kPreferenceHideStatusBarKey: @(NO),
169+
kPreferenceScrollToSendInputKey: @(NO),
168170
kPreferenceColorSchemeKey: @(ColorSchemeMatchSystem),
169171
kPreferenceThemeKey: @"Default",
170172
kHostnameOverrideKey: UIDevice.currentDevice.name,
@@ -202,6 +204,7 @@ - (instancetype)init {
202204
@"color_scheme": kPreferenceColorSchemeKey,
203205
@"theme": kPreferenceThemeKey,
204206
@"hostname_override": kHostnameOverrideKey,
207+
@"scroll_to_send_input": kPreferenceScrollToSendInputKey,
205208
};
206209
NSMutableDictionary <NSString *, NSString *> *reverseMapping = [NSMutableDictionary new];
207210
for (NSString *key in friendlyPreferenceMapping) {
@@ -225,6 +228,7 @@ - (instancetype)init {
225228
kPreferenceBlinkCursorKey: property(blinkCursor),
226229
kPreferenceHideStatusBarKey: property(hideStatusBar),
227230
kPreferenceColorSchemeKey: property(colorScheme),
231+
kPreferenceScrollToSendInputKey: property(scrollToSendInput),
228232
// This one is a little bit special, so it needs extra handling.
229233
// The backing property for this is intentionally underscored.
230234
kPreferenceThemeKey: @"userTheme",
@@ -525,6 +529,19 @@ - (BOOL)validateHideStatusBar:(id *)value error:(NSError **)error {
525529
return [*value isKindOfClass:NSNumber.class];
526530
}
527531

532+
// MARK: scrollToSendInput
533+
- (BOOL)scrollToSendInput {
534+
return [_defaults boolForKey:kPreferenceScrollToSendInputKey];
535+
}
536+
537+
- (void)setScrollToSendInput:(BOOL)scrollToSendInput {
538+
[_defaults setBool:scrollToSendInput forKey:kPreferenceScrollToSendInputKey];
539+
}
540+
541+
- (BOOL)validateScrollToSendInput:(id *)value error:(NSError **)error {
542+
return [*value isKindOfClass:NSNumber.class];
543+
}
544+
528545
// MARK: colorScheme
529546
- (ColorScheme)colorScheme {
530547
return [_defaults integerForKey:kPreferenceColorSchemeKey];

0 commit comments

Comments
 (0)