Skip to content
Snippets Groups Projects
Commit 17319d9a authored by aljex's avatar aljex Committed by George Nachman
Browse files

Make the anti-idle interval a profile preference. By aljex@github.

parent 7cf98216
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 43 deletions
Loading
Loading
@@ -1638,6 +1638,7 @@ DQ
<outlet property="_changeLogDir" destination="5687" id="mMH-ci-Pff"/>
<outlet property="_closeSessionsOnEnd" destination="5681" id="7OH-SS-Zp9"/>
<outlet property="_idleCode" destination="5698" id="wWW-3F-nXP"/>
<outlet property="_idlePeriod" destination="Dvw-Ch-E3y" id="Ts1-PZ-huD"/>
<outlet property="_jobsTable" destination="5661" id="yIR-qA-xyG"/>
<outlet property="_logDir" destination="5686" id="9gN-0Q-j71"/>
<outlet property="_logDirWarning" destination="5688" id="LwF-JR-iDw"/>
Loading
Loading
@@ -3726,16 +3727,15 @@ DQ
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="Warning" id="5689"/>
</imageView>
<button toolTip="This is not recommended." id="5697">
<rect key="frame" x="15" y="38" width="200" height="18"/>
<rect key="frame" x="15" y="38" width="190" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<buttonCell key="cell" type="check" title="When idle, send ASCII code:" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="5701">
<buttonCell key="cell" type="check" title="When idle, send ASCII code" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="5701">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="settingChanged:" target="TG6-06-mq9" id="Oi1-J9-bAq"/>
<outlet property="nextKeyView" destination="5698" id="5702"/>
</connections>
</button>
<button toolTip="This is not recommended." id="Flt-We-Y3i">
Loading
Loading
@@ -3748,23 +3748,8 @@ DQ
</buttonCell>
<connections>
<action selector="settingChanged:" target="TG6-06-mq9" id="Z4O-Ko-FnF"/>
<outlet property="nextKeyView" destination="5698" id="RI3-Qt-Njb"/>
</connections>
</button>
<textField verticalHuggingPriority="750" id="5698">
<rect key="frame" x="214" y="37" width="45" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="5699">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="TG6-06-mq9" id="Vnh-fj-vwl"/>
<outlet property="nextKeyView" destination="2404" id="5703"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" id="5707">
<rect key="frame" x="14" y="400" width="55" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
Loading
Loading
@@ -3849,9 +3834,56 @@ DQ
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="5698">
<rect key="frame" x="204" y="37" width="81" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="ASCII Code" drawsBackground="YES" id="5699">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="TG6-06-mq9" id="Vnh-fj-vwl"/>
<outlet property="nextKeyView" destination="2404" id="5703"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="SKQ-AW-1wN">
<rect key="frame" x="284" y="38" width="42" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="every" id="e95-Tz-JKN">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="Dvw-Ch-E3y">
<rect key="frame" x="325" y="37" width="55" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="interval" drawsBackground="YES" id="Njg-LZ-sIb">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="TG6-06-mq9" id="0fm-Vp-V0B"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RGW-48-LkR">
<rect key="frame" x="379" y="38" width="55" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="seconds" id="VbV-8M-87X">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<animations/>
<point key="canvasLocation" x="835.5" y="337"/>
<point key="canvasLocation" x="1283.5" y="800"/>
</customView>
<customView id="M5G-Dw-0HO" userLabel="Prefs - Profiles - Keys" customClass="iTermSizeRememberingView">
<rect key="frame" x="0.0" y="0.0" width="657" height="428"/>
Loading
Loading
Loading
Loading
@@ -180,6 +180,7 @@
#define KEY_LOGDIR @"Log Directory"
#define KEY_SEND_CODE_WHEN_IDLE @"Send Code When Idle"
#define KEY_IDLE_CODE @"Idle Code"
#define KEY_IDLE_PERIOD @"Idle Period"
#define KEY_PROMPT_CLOSE_DEPRECATED @"Prompt Before Closing" // Deprecated due to bad migration in 8/28 build
#define KEY_PROMPT_CLOSE @"Prompt Before Closing 2"
#define KEY_JOBS @"Jobs to Ignore"
Loading
Loading
@@ -200,6 +201,9 @@
// Dynamic Profiles (not in prefs ui)
#define KEY_DYNAMIC_PROFILE_PARENT_NAME @"Dynamic Profile Parent Name"
 
// Minimum time between sending anti-idle codes. "1" otherwise results in a flood.
extern const NSTimeInterval kMinimumAntiIdlePeriod;
// The numerical values for each enum matter because they are used in
// the UI as "tag" values for each select list item. They are also
// stored in saved arrangements.
Loading
Loading
Loading
Loading
@@ -39,6 +39,8 @@
#import "NSFont+iTerm.h"
#include <arpa/inet.h>
 
const NSTimeInterval kMinimumAntiIdlePeriod = 1.0;
@implementation ITAddressBookMgr {
NSNetServiceBrowser *sshBonjourBrowser;
NSNetServiceBrowser *ftpBonjourBrowser;
Loading
Loading
Loading
Loading
@@ -165,6 +165,9 @@ typedef enum {
// The code to send in the anti idle timer.
@property(nonatomic, assign) char antiIdleCode;
 
// The interval between sending anti-idle codes.
@property(nonatomic, assign) NSTimeInterval antiIdlePeriod;
// If true, close the tab when the session ends.
@property(nonatomic, assign) BOOL autoClose;
 
Loading
Loading
Loading
Loading
@@ -158,6 +158,10 @@ static NSMutableDictionary *gRegisteredSessionContents;
// Rate limit for checking instant (partial-line) triggers, in seconds.
static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
 
// Grace period to avoid failing to write anti-idle code when timer runs just before when the code
// should be sent.
static const NSTimeInterval kAntiIdleGracePeriod = 0.1;
@interface PTYSession () <iTermPasteHelperDelegate>
@property(nonatomic, retain) Interval *currentMarkOrNotePosition;
@property(nonatomic, retain) TerminalFile *download;
Loading
Loading
@@ -220,9 +224,6 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
// Anti-idle timer that sends a character every so often to the host.
NSTimer *_antiIdleTimer;
 
// The code to send in the anti idle timer.
char _antiIdleCode;
// The bookmark the session was originally created with so those settings can be restored if
// needed.
Profile *_originalProfile;
Loading
Loading
@@ -2736,6 +2737,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[self setTermVariable:[iTermProfilePreferences stringForKey:KEY_TERMINAL_TYPE inProfile:aDict]];
[_terminal setAnswerBackString:[iTermProfilePreferences stringForKey:KEY_ANSWERBACK_STRING inProfile:aDict]];
[self setAntiIdleCode:[iTermProfilePreferences intForKey:KEY_IDLE_CODE inProfile:aDict]];
[self setAntiIdlePeriod:[iTermProfilePreferences doubleForKey:KEY_IDLE_PERIOD inProfile:aDict]];
[self setAntiIdle:[iTermProfilePreferences boolForKey:KEY_SEND_CODE_WHEN_IDLE inProfile:aDict]];
[self setAutoClose:[iTermProfilePreferences boolForKey:KEY_CLOSE_SESSIONS_ON_END inProfile:aDict]];
_screen.useHFSPlusMapping = [iTermProfilePreferences boolForKey:KEY_USE_HFS_PLUS_MAPPING
Loading
Loading
@@ -3089,29 +3091,23 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[_textview setBlend:blendVal];
}
 
- (BOOL)antiIdle
{
- (BOOL)antiIdle {
return _antiIdleTimer ? YES : NO;
}
 
- (void)setAntiIdle:(BOOL)set
{
if (set == [self antiIdle]) {
return;
}
- (void)setAntiIdle:(BOOL)set {
[_antiIdleTimer invalidate];
[_antiIdleTimer release];
_antiIdleTimer = nil;
_antiIdlePeriod = MAX(_antiIdlePeriod, kMinimumAntiIdlePeriod);
if (set) {
NSTimeInterval period = MIN(60, [iTermAdvancedSettingsModel antiIdleTimerPeriod]);
_antiIdleTimer = [[NSTimer scheduledTimerWithTimeInterval:period
_antiIdleTimer = [[NSTimer scheduledTimerWithTimeInterval:_antiIdlePeriod
target:self
selector:@selector(doAntiIdle)
userInfo:nil
repeats:YES] retain];
} else {
[_antiIdleTimer invalidate];
[_antiIdleTimer release];
_antiIdleTimer = nil;
repeats:YES] retain];
}
}
 
Loading
Loading
@@ -3521,7 +3517,8 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
 
- (void)doAntiIdle {
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
if (now >= _lastInput + 60) {
if (now >= _lastInput + _antiIdlePeriod - kAntiIdleGracePeriod) {
[_shell writeTask:[NSData dataWithBytes:&_antiIdleCode length:1]];
_lastInput = now;
}
Loading
Loading
@@ -4473,6 +4470,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
}
 
- (BOOL)textViewShouldAcceptKeyDownEvent:(NSEvent *)event {
_lastInput = [NSDate timeIntervalSinceReferenceDate];
if (_view.currentAnnouncement.dismissOnKeyDown) {
[_view.currentAnnouncement dismiss];
return NO;
Loading
Loading
@@ -4506,7 +4504,6 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
unicode = [keystr length] > 0 ? [keystr characterAtIndex:0] : 0;
unmodunicode = [unmodkeystr length] > 0 ? [unmodkeystr characterAtIndex:0] : 0;
DLog(@"PTYSession keyDown modflag=%d keystr=%@ unmodkeystr=%@ unicode=%d unmodunicode=%d", (int)modflag, keystr, unmodkeystr, (int)unicode, (int)unmodunicode);
_lastInput = [NSDate timeIntervalSinceReferenceDate];
[self resumeOutputIfNeeded];
if ([self textViewIsZoomedIn] && unicode == 27) {
// Escape exits zoom (pops out one level, since you can zoom repeatedly)
Loading
Loading
Loading
Loading
@@ -13,6 +13,7 @@ typedef NS_ENUM(NSInteger, PreferenceInfoType) {
kPreferenceInfoTypeInvertedCheckbox, // true=checked, false=unchecked. Handy when inverting a checkbox's text, but the user defaults key can't be changed.
kPreferenceInfoTypeIntegerTextField, // 32bit values only
kPreferenceInfoTypeUnsignedIntegerTextField,
kPreferenceInfoTypeDoubleTextField,
kPreferenceInfoTypeStringTextField,
kPreferenceInfoTypePopup,
kPreferenceInfoTypeUnsignedIntegerPopup,
Loading
Loading
Loading
Loading
@@ -24,6 +24,7 @@
IBOutlet NSTextField *_logDir;
IBOutlet NSButton *_sendCodeWhenIdle;
IBOutlet NSTextField *_idleCode;
IBOutlet NSTextField *_idlePeriod;
 
IBOutlet NSImageView *_logDirWarning;
IBOutlet NSButton *_changeLogDir;
Loading
Loading
@@ -104,6 +105,7 @@
};
info.observer = ^() {
_idleCode.enabled = [self boolForKey:KEY_SEND_CODE_WHEN_IDLE];
_idlePeriod.enabled = [self boolForKey:KEY_SEND_CODE_WHEN_IDLE];
};
 
info = [self defineControl:_idleCode
Loading
Loading
@@ -111,6 +113,10 @@
type:kPreferenceInfoTypeIntegerTextField];
info.range = NSMakeRange(0, 256);
 
[self defineControl:_idlePeriod
key:KEY_IDLE_PERIOD
type:kPreferenceInfoTypeDoubleTextField];
[self updateRemoveJobButtonEnabled];
 
[self defineControl:_reduceFlicker
Loading
Loading
@@ -119,6 +125,14 @@
 
}
 
// Ensure the anti-idle period's value is constrained to the legal range.
- (void)setDouble:(double)value forKey:(NSString *)key {
if ([key isEqualToString:KEY_IDLE_PERIOD]) {
value = MAX(kMinimumAntiIdlePeriod, value);
}
[super setDouble:value forKey:key];
}
- (void)layoutSubviewsForEditCurrentSessionMode {
NSArray *viewsToDisable = @[ _autoLog,
_logDir,
Loading
Loading
Loading
Loading
@@ -19,7 +19,6 @@
+ (double)hotkeyTermAnimationDuration;
+ (BOOL)hotkeyWindowFloatsAboveOtherWindows;
+ (NSString *)searchCommand;
+ (double)antiIdleTimerPeriod;
+ (BOOL)dockIconTogglesWindow;
+ (double)timeBetweenBlinks;
+ (BOOL)neverWarnAboutMeta;
Loading
Loading
Loading
Loading
@@ -65,7 +65,6 @@ DEFINE_BOOL(stealKeyFocus, NO, @"Mouse: When Focus Follows Mouse is enabled, ste
 
#pragma mark Terminal
DEFINE_BOOL(traditionalVisualBell, NO, @"Terminal: Visual bell flashes the whole screen, not just a bell icon.");
DEFINE_FLOAT(antiIdleTimerPeriod, 60, @"Terminal: Anti-idle interval in seconds.\nWill not go faster than 60 seconds.");
DEFINE_FLOAT(timeBetweenBlinks, 0.5, @"Terminal: Cursor blink speed (seconds).");
DEFINE_BOOL(doNotSetCtype, NO, @"Terminal: Never set the CTYPE environment variable.");
// For these, 1 is more aggressive and 0 turns the feature off:
Loading
Loading
Loading
Loading
@@ -159,6 +159,9 @@ extern NSString *const kPreferenceKeyShowFullscreenTabBar;
+ (double)floatForKey:(NSString *)key;
+ (void)setFloat:(double)value forKey:(NSString *)key;
 
+ (double)doubleForKey:(NSString *)key;
+ (void)setDouble:(double)value forKey:(NSString *)key;
+ (NSString *)stringForKey:(NSString *)key;
+ (void)setString:(NSString *)value forKey:(NSString *)key;
 
Loading
Loading
Loading
Loading
@@ -279,6 +279,7 @@ static NSMutableDictionary *gObservers;
id defaultValue = [self defaultValueMap][key];
switch (type) {
case kPreferenceInfoTypeIntegerTextField:
case kPreferenceInfoTypeDoubleTextField:
case kPreferenceInfoTypePopup:
return ([defaultValue isKindOfClass:[NSNumber class]] &&
[defaultValue doubleValue] == ceil([defaultValue doubleValue]));
Loading
Loading
@@ -410,6 +411,14 @@ static NSMutableDictionary *gObservers;
[self setObject:@(value) forKey:key];
}
 
+ (double)doubleForKey:(NSString *)key {
return [(NSNumber *)[self objectForKey:key] doubleValue];
}
+ (void)setDouble:(double)value forKey:(NSString *)key {
[self setObject:@(value) forKey:key];
}
+ (NSString *)stringForKey:(NSString *)key {
id object = [self objectForKey:key];
assert(!object || [object isKindOfClass:[NSString class]]);
Loading
Loading
Loading
Loading
@@ -71,6 +71,9 @@
- (double)floatForKey:(NSString *)key;
- (void)setFloat:(double)value forKey:(NSString *)key;
 
- (double)doubleForKey:(NSString *)key;
- (void)setDouble:(double)value forKey:(NSString *)key;
- (NSString *)stringForKey:(NSString *)key;
- (void)setString:(NSString *)value forKey:(NSString *)key;
 
Loading
Loading
Loading
Loading
@@ -22,6 +22,11 @@ static NSString *const kPreferenceDidChangeFromOtherPanel = @"kPreferenceDidChan
// key of changed preference.
static NSString *const kKey = @"key";
 
@interface iTermPreferencesBaseViewController()
// If set to YES, then controls won't be updated with values from backing store when it changes.
@property(nonatomic, assign) BOOL disableUpdates;
@end
@implementation iTermPreferencesBaseViewController {
// Maps NSControl* -> PreferenceInfo*.
NSMapTable *_keyMap;
Loading
Loading
@@ -95,6 +100,14 @@ static NSString *const kKey = @"key";
[iTermPreferences setFloat:value forKey:key];
}
 
- (double)doubleForKey:(NSString *)key {
return [iTermPreferences doubleForKey:key];
}
- (void)setDouble:(double)value forKey:(NSString *)key {
[iTermPreferences setDouble:value forKey:key];
}
- (NSString *)stringForKey:(NSString *)key {
return [iTermPreferences stringForKey:key];
}
Loading
Loading
@@ -150,6 +163,23 @@ static NSString *const kKey = @"key";
[self setInt:[sender separatorTolerantIntValue] forKey:info.key];
break;
 
case kPreferenceInfoTypeDoubleTextField: {
NSScanner *scanner = [NSScanner localizedScannerWithString:[sender stringValue]];
double value;
if ([scanner scanDouble:&value]) {
// A double value may take a legal but non-canonical form during editing. For
// example, "1." is a valid way of specifying 1.0. But we don't want to replace
// the control's value with "1", or there's no way of entering "1.2", for
// example. We turn on disableUpdates so -setDouble:forKey: doesn't have the
// side-effect of updating the control with its canonical value.
BOOL savedValue = self.disableUpdates;
self.disableUpdates = YES;
[self setDouble:value forKey:info.key];
self.disableUpdates = savedValue;
}
break;
}
case kPreferenceInfoTypeUnsignedIntegerTextField:
[self applyUnsignedIntegerConstraints:info];
[self setUnsignedInteger:[sender separatorTolerantUnsignedIntegerValue] forKey:info.key];
Loading
Loading
@@ -238,6 +268,9 @@ static NSString *const kKey = @"key";
}
 
- (void)updateValueForInfo:(PreferenceInfo *)info {
if (_disableUpdates) {
return;
}
if (info.onUpdate) {
if (info.onUpdate()) {
return;
Loading
Loading
@@ -271,6 +304,13 @@ static NSString *const kKey = @"key";
field.stringValue = [NSString stringWithFormat:@"%lu", [self unsignedIntegerForKey:info.key]];
}
 
case kPreferenceInfoTypeDoubleTextField: {
assert([info.control isKindOfClass:[NSTextField class]]);
NSTextField *field = (NSTextField *)info.control;
field.doubleValue = [self doubleForKey:info.key];
break;
}
case kPreferenceInfoTypeStringTextField: {
assert([info.control isKindOfClass:[NSTextField class]]);
NSTextField *field = (NSTextField *)info.control;
Loading
Loading
@@ -437,6 +477,28 @@ static NSString *const kKey = @"key";
PreferenceInfo *info = [_keyMap objectForKey:control];
if (info.controlTextDidEndEditing) {
info.controlTextDidEndEditing(aNotification);
} else {
switch (info.type) {
case kPreferenceInfoTypeCheckbox:
case kPreferenceInfoTypeColorWell:
case kPreferenceInfoTypeInvertedCheckbox:
case kPreferenceInfoTypeMatrix:
case kPreferenceInfoTypePopup:
case kPreferenceInfoTypeSlider:
case kPreferenceInfoTypeStringTextField:
case kPreferenceInfoTypeTokenField:
case kPreferenceInfoTypeIntegerTextField:
case kPreferenceInfoTypeUnsignedIntegerPopup:
case kPreferenceInfoTypeUnsignedIntegerTextField:
break;
case kPreferenceInfoTypeDoubleTextField:
// Replace the control with its canonical value. Only floating point text fields can
// temporarily take illegal values, which are tolerated until editing ends.
// See the comments in -settingChanged: for more details on why doubles are special.
[control setDoubleValue:[self doubleForKey:info.key]];
break;
}
}
}
 
Loading
Loading
Loading
Loading
@@ -46,6 +46,12 @@ extern NSString *const kProfilePreferenceInitialDirectoryAdvancedValue;
inProfile:(Profile *)profile
model:(ProfileModel *)model;
 
+ (double)doubleForKey:(NSString *)key inProfile:(Profile *)profile;
+ (void)setDouble:(double)value
forKey:(NSString *)key
inProfile:(Profile *)profile
model:(ProfileModel *)model;
+ (NSString *)stringForKey:(NSString *)key inProfile:(Profile *)profile;
+ (void)setString:(NSString *)value
forKey:(NSString *)key
Loading
Loading
Loading
Loading
@@ -12,6 +12,8 @@
#import "NSColor+iTerm.h"
#import "PreferencePanel.h"
 
#define PROFILE_BLOCK(x) [[^id(Profile *profile) { return [self x:profile]; } copy] autorelease]
NSString *const kProfilePreferenceCommandTypeCustomValue = @"Yes";
NSString *const kProfilePreferenceCommandTypeLoginShellValue = @"No";
 
Loading
Loading
@@ -68,6 +70,17 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
[self setObject:@(value) forKey:key inProfile:profile model:model];
}
 
+ (double)doubleForKey:(NSString *)key inProfile:(Profile *)profile {
return [[self objectForKey:key inProfile:profile] doubleValue];
}
+ (void)setDouble:(double)value
forKey:(NSString *)key
inProfile:(Profile *)profile
model:(ProfileModel *)model {
[self setObject:@(value) forKey:key inProfile:profile model:model];
}
+ (NSString *)stringForKey:(NSString *)key inProfile:(Profile *)profile {
return [self objectForKey:key inProfile:profile];
}
Loading
Loading
@@ -88,6 +101,7 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
id defaultValue = [self defaultValueMap][key];
switch (type) {
case kPreferenceInfoTypeIntegerTextField:
case kPreferenceInfoTypeDoubleTextField:
case kPreferenceInfoTypePopup:
return ([defaultValue isKindOfClass:[NSNumber class]] &&
[defaultValue doubleValue] == ceil([defaultValue doubleValue]));
Loading
Loading
@@ -223,6 +237,7 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
KEY_LOGDIR: @"",
KEY_SEND_CODE_WHEN_IDLE: @NO,
KEY_IDLE_CODE: @0,
KEY_IDLE_PERIOD: @60,
KEY_OPTION_KEY_SENDS: @(OPT_NORMAL),
KEY_RIGHT_OPTION_KEY_SENDS: @(OPT_NORMAL),
KEY_APPLICATION_KEYPAD_ALLOWED: @NO,
Loading
Loading
@@ -270,7 +285,7 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
+ (NSDictionary *)computedObjectDictionary {
static NSDictionary *dict;
if (!dict) {
dict = @{ };
dict = @{ KEY_IDLE_PERIOD: PROFILE_BLOCK(antiIdlePeriodWithLegacyDefaultInProfile) };
[dict retain];
}
return dict;
Loading
Loading
@@ -293,4 +308,23 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
return object;
}
 
+ (id)antiIdlePeriodWithLegacyDefaultInProfile:(Profile *)profile {
NSString *const key = KEY_IDLE_PERIOD;
// If the profile has a value.
NSNumber *value = profile[key];
if (value) {
return value;
}
// If the user set a preference with the now-removed advanced setting, use it.
NSNumber *legacyDefault = [[NSUserDefaults standardUserDefaults] objectForKey:@"AntiIdleTimerPeriod"];
if (legacyDefault) {
return legacyDefault;
}
// Fall back to the default from the dictionary.
return [self defaultObjectForKey:key];
}
@end
Loading
Loading
@@ -66,6 +66,17 @@
[iTermProfilePreferences setFloat:value forKey:key inProfile:profile model:model];
}
 
- (double)doubleForKey:(NSString *)key {
Profile *profile = [_delegate profilePreferencesCurrentProfile];
return [iTermProfilePreferences doubleForKey:key inProfile:profile];
}
- (void)setDouble:(double)value forKey:(NSString *)key {
Profile *profile = [_delegate profilePreferencesCurrentProfile];
ProfileModel *model = [_delegate profilePreferencesCurrentModel];
[iTermProfilePreferences setDouble:value forKey:key inProfile:profile model:model];
}
- (NSString *)stringForKey:(NSString *)key {
Profile *profile = [_delegate profilePreferencesCurrentProfile];
return [iTermProfilePreferences stringForKey:key inProfile:profile];
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment