Skip to content

Commit

Permalink
Revert "Add a setting that hides extra keys with a HW keyboard"
Browse files Browse the repository at this point in the history
Broke various keyboard related behaviors (ish-app#753)

This reverts commit d7a915e.
  • Loading branch information
tbodt committed Jun 1, 2020
1 parent 66a2c58 commit 554f0c4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 84 deletions.
5 changes: 0 additions & 5 deletions app/AboutExternalKeyboardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ @interface AboutExternalKeyboardViewController ()

@property (weak, nonatomic) IBOutlet UISwitch *optionMetaSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *backtickEscapeSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *hideExtraKeysWithExternalKeyboardSwitch;

@end

Expand All @@ -39,7 +38,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
- (void)_update {
self.optionMetaSwitch.on = UserPreferences.shared.optionMapping == OptionMapEsc;
self.backtickEscapeSwitch.on = UserPreferences.shared.backtickMapEscape;
self.hideExtraKeysWithExternalKeyboardSwitch.on = UserPreferences.shared.hideExtraKeysWithExternalKeyboard;
}

- (IBAction)optionMetaToggle:(UISwitch *)sender {
Expand All @@ -48,9 +46,6 @@ - (IBAction)optionMetaToggle:(UISwitch *)sender {
- (IBAction)backtickEscapeToggle:(UISwitch *)sender {
UserPreferences.shared.backtickMapEscape = sender.on;
}
- (IBAction)hideExtraKeysToggle:(UISwitch *)sender {
UserPreferences.shared.hideExtraKeysWithExternalKeyboard = sender.on;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == kCapsLockMappingSection && cell.tag == UserPreferences.shared.capsLockMapping)
Expand Down
36 changes: 1 addition & 35 deletions app/Base.lproj/About.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="NQy-68-Suu" userLabel="Backtick to Escape">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="NQy-68-Suu" userLabel="Option to Meta">
<rect key="frame" x="0.0" y="267.5" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="NQy-68-Suu" id="9xb-BP-fQ4">
Expand Down Expand Up @@ -402,39 +402,6 @@
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Extra keys" footerTitle="When extra keys are hidden, Settings can be opened with the ⌘, shortcut" id="Kaj-9x-pfF">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="TM9-T2-EDa" userLabel="Backtick to Escape">
<rect key="frame" x="0.0" y="375" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="TM9-T2-EDa" id="K8q-us-D80">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Hide with external keyboard" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PWB-d9-Zhd">
<rect key="frame" x="16" y="11.5" width="213" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IcN-9M-x1K">
<rect key="frame" x="255" y="8.5" width="51" height="31"/>
<connections>
<action selector="backtickEscapeToggle:" destination="Zzy-IN-laJ" eventType="valueChanged" id="F0N-yF-KDZ"/>
<action selector="hideExtraKeysToggle:" destination="Zzy-IN-laJ" eventType="valueChanged" id="kQA-Pi-MZM"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstItem="PWB-d9-Zhd" firstAttribute="leading" secondItem="K8q-us-D80" secondAttribute="leadingMargin" id="FGk-hn-hnq"/>
<constraint firstItem="PWB-d9-Zhd" firstAttribute="centerY" secondItem="K8q-us-D80" secondAttribute="centerY" id="I9n-5H-Jr4"/>
<constraint firstAttribute="trailingMargin" secondItem="IcN-9M-x1K" secondAttribute="trailing" id="fig-KE-i9e"/>
<constraint firstItem="IcN-9M-x1K" firstAttribute="centerY" secondItem="K8q-us-D80" secondAttribute="centerY" id="wZF-ty-HqH"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="Zzy-IN-laJ" id="NPA-6F-jMj"/>
Expand All @@ -443,7 +410,6 @@
</tableView>
<connections>
<outlet property="backtickEscapeSwitch" destination="8xc-Rx-eue" id="jkl-oc-V9N"/>
<outlet property="hideExtraKeysWithExternalKeyboardSwitch" destination="IcN-9M-x1K" id="Lw3-4l-9R6"/>
<outlet property="optionMetaSwitch" destination="OEG-YY-LTw" id="b2K-Ug-Jij"/>
</connections>
</tableViewController>
Expand Down
5 changes: 3 additions & 2 deletions app/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -21,6 +21,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="controlKey" destination="W9v-cj-FWz" id="HgQ-u7-5IL"/>
<outlet property="inputAccessoryView" destination="GyN-ob-WFz" id="mVD-kz-BQc"/>
</connections>
</view>
</subviews>
Expand Down
46 changes: 13 additions & 33 deletions app/TerminalViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ @interface TerminalViewController () <UIGestureRecognizerDelegate>
@property (nonatomic) Terminal *sessionTerminal;
@property int sessionTerminalNumber;

@property BOOL ignoreKeyboardMotion;
@property (nonatomic) BOOL hasExternalKeyboard;

@end

@implementation TerminalViewController
Expand All @@ -73,10 +70,6 @@ - (void)viewDidLoad {
selector:@selector(keyboardDidSomething:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
[center addObserver:self
selector:@selector(keyboardDidSomething:)
name:UIKeyboardDidChangeFrameNotification
object:nil];

[self _updateStyleFromPreferences:NO];

Expand Down Expand Up @@ -112,7 +105,6 @@ - (void)awakeFromNib {
name:ProcessExitedNotification
object:nil];
[[UserPreferences shared] addObserver:self forKeyPath:@"theme" options:NSKeyValueObservingOptionNew context:nil];
[[UserPreferences shared] addObserver:self forKeyPath:@"hideExtraKeysWithExternalKeyboard" options:NSKeyValueObservingOptionNew context:nil];
}

- (void)startNewSession {
Expand Down Expand Up @@ -222,16 +214,6 @@ - (void)_updateStyleFromPreferences:(BOOL)animated {
control.tintColor = tintColor;
}
}];
if (UserPreferences.shared.hideExtraKeysWithExternalKeyboard && self.hasExternalKeyboard) {
self.termView.inputAccessoryView = nil;
} else {
self.termView.inputAccessoryView = self.barView;
}
if (self.termView.isFirstResponder) {
self.ignoreKeyboardMotion = YES; // avoid infinite recursion
[self.termView reloadInputViews];
self.ignoreKeyboardMotion = NO;
}
}

- (UIStatusBarStyle)preferredStatusBarStyle {
Expand All @@ -244,23 +226,26 @@ - (BOOL)prefersStatusBarHidden {
}

- (void)keyboardDidSomething:(NSNotification *)notification {
if (self.ignoreKeyboardMotion)
return;

// NSLog(@"%@", notification);
BOOL initialLayout = self.termView.needsUpdateConstraints;
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
if (CGRectEqualToRect(keyboardFrame, CGRectZero))
return;
NSLog(@"%@ %@", notification.name, [NSValue valueWithCGRect:keyboardFrame]);
self.hasExternalKeyboard = keyboardFrame.size.height < 100;
CGFloat pad = UIScreen.mainScreen.bounds.size.height - keyboardFrame.origin.y;
CGFloat pad;
if (keyboardFrame.origin.x == 0 &&
keyboardFrame.origin.y == 0 &&
keyboardFrame.size.height == 0 &&
keyboardFrame.size.width == 0) {
pad = 0;
} else {
pad = UIScreen.mainScreen.bounds.size.height - keyboardFrame.origin.y;
}
if (pad == 0) {
pad = self.view.safeAreaInsets.bottom;
}
// NSLog(@"pad %f", pad);
self.bottomConstraint.constant = -pad;

BOOL initialLayout = self.termView.needsUpdateConstraints;
[self.view setNeedsUpdateConstraints];

if (!initialLayout) {
// if initial layout hasn't happened yet, the terminal view is going to be at a really weird place, so animating it is going to look really bad
NSNumber *interval = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey];
Expand All @@ -275,11 +260,6 @@ - (void)keyboardDidSomething:(NSNotification *)notification {
}
}

- (void)setHasExternalKeyboard:(BOOL)hasExternalKeyboard {
_hasExternalKeyboard = hasExternalKeyboard;
[self _updateStyleFromPreferences:YES];
}

- (void)ishExited:(NSNotification *)notification {
[self performSelectorOnMainThread:@selector(displayExitThing) withObject:nil waitUntilDone:YES];
}
Expand Down
1 change: 0 additions & 1 deletion app/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ extern NSString *const kThemeBackgroundColor;
@property CapsLockMapping capsLockMapping;
@property OptionMapping optionMapping;
@property BOOL backtickMapEscape;
@property BOOL hideExtraKeysWithExternalKeyboard;
@property (nonatomic) Theme *theme;
@property BOOL shouldDisableDimming;
@property NSString *fontFamily;
Expand Down
8 changes: 0 additions & 8 deletions app/UserPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
static NSString *const kPreferenceCapsLockMappingKey = @"Caps Lock Mapping";
static NSString *const kPreferenceOptionMappingKey = @"Option Mapping";
static NSString *const kPreferenceBacktickEscapeKey = @"Backtick Mapping Escape";
static NSString *const kPreferenceHideExtraKeysWithExternalKeyboard = @"Hide Extra Keys With External Keyboard";
static NSString *const kPreferenceFontFamilyKey = @"Font Family";
static NSString *const kPreferenceFontSizeKey = @"Font Size";
static NSString *const kPreferenceThemeKey = @"Theme";
Expand Down Expand Up @@ -74,13 +73,6 @@ - (void)setBacktickMapEscape:(BOOL)backtickMapEscape {
[_defaults setBool:backtickMapEscape forKey:kPreferenceBacktickEscapeKey];
}

- (BOOL)hideExtraKeysWithExternalKeyboard {
return [_defaults boolForKey:kPreferenceHideExtraKeysWithExternalKeyboard];
}
- (void)setHideExtraKeysWithExternalKeyboard:(BOOL)hideExtraKeysWithExternalKeyboard {
[_defaults setBool:hideExtraKeysWithExternalKeyboard forKey:kPreferenceHideExtraKeysWithExternalKeyboard];
}

- (NSNumber *)fontSize {
return [_defaults objectForKey:kPreferenceFontSizeKey];
}
Expand Down

0 comments on commit 554f0c4

Please sign in to comment.