Permalink
Browse files

Move MARGIN/VMARGIN to iTermAdvancedSettingsModel

  • Loading branch information...
jcs committed Dec 4, 2016
1 parent 7d1cd8b commit 09e074628b1dfaa5994319fffe170bf160b1ac29
@@ -11,6 +11,7 @@
#import "VT100LineInfo.h"
#import "iTermApplication.h"
#import "iTermApplicationDelegate.h"
#import "iTermAdvancedSettingsModel.h"
#import "iTermPreferences.h"
#import "iTermSelectorSwizzler.h"
#import <objc/runtime.h>
@@ -606,8 +607,8 @@ - (PTYSession *)sessionWithProfileOverrides:(NSDictionary *)profileOverrides
[session setSize:size];
NSRect theFrame = NSMakeRect(0,
0,
size.width * session.textview.charWidth + MARGIN * 2,
size.height * session.textview.lineHeight + VMARGIN * 2);
size.width * session.textview.charWidth + [iTermAdvancedSettingsModel terminalMargin] * 2,
size.height * session.textview.lineHeight + [iTermAdvancedSettingsModel terminalVMargin] * 2);
session.view.frame = theFrame;
[session loadInitialColorTable];
[session setBookmarkName:profile[KEY_NAME]];
View
@@ -1074,7 +1074,7 @@ - (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent
NSSize aSize = [_view.scrollview contentSize];
_wrapper = [[TextViewWrapper alloc] initWithFrame:NSMakeRect(0, 0, aSize.width, aSize.height)];
_textview = [[PTYTextView alloc] initWithFrame: NSMakeRect(0, VMARGIN, aSize.width, aSize.height)
_textview = [[PTYTextView alloc] initWithFrame: NSMakeRect(0, [iTermAdvancedSettingsModel terminalVMargin], aSize.width, aSize.height)
colorMap:_colorMap];
_colorMap.dimOnlyText = [iTermPreferences boolForKey:kPreferenceKeyDimOnlyText];
[_textview setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
@@ -1089,7 +1089,7 @@ - (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent
[self setTransparencyAffectsOnlyDefaultBackgroundColor:[[_profile objectForKey:KEY_TRANSPARENCY_AFFECTS_ONLY_DEFAULT_BACKGROUND_COLOR] boolValue]];
[_wrapper addSubview:_textview];
[_textview setFrame:NSMakeRect(0, VMARGIN, aSize.width, aSize.height - VMARGIN)];
[_textview setFrame:NSMakeRect(0, [iTermAdvancedSettingsModel terminalVMargin], aSize.width, aSize.height - [iTermAdvancedSettingsModel terminalVMargin])];
[_textview release];
// assign terminal and task objects
@@ -1098,8 +1098,8 @@ - (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent
// initialize the screen
// TODO: Shouldn't this take the scrollbar into account?
int width = (aSize.width - MARGIN*2) / [_textview charWidth];
int height = (aSize.height - VMARGIN*2) / [_textview lineHeight];
int width = (aSize.width - [iTermAdvancedSettingsModel terminalMargin]*2) / [_textview charWidth];
int height = (aSize.height - [iTermAdvancedSettingsModel terminalVMargin]*2) / [_textview lineHeight];
// NB: In the bad old days, this returned whether setup succeeded because it would allocate an
// enormous amount of memory. That's no longer an issue.
[_screen destructivelySetScreenWidth:width height:height];
@@ -1221,7 +1221,7 @@ - (int)overUnder:(int)proposedSize inVerticalDimension:(BOOL)vertically
if ([_view showTitle]) {
x -= [SessionView titleHeight];
}
x -= VMARGIN * 2;
x -= [iTermAdvancedSettingsModel terminalVMargin] * 2;
int iLineHeight = [_textview lineHeight];
if (iLineHeight == 0) {
return 0;
@@ -1232,7 +1232,7 @@ - (int)overUnder:(int)proposedSize inVerticalDimension:(BOOL)vertically
}
return x;
} else {
x -= MARGIN * 2;
x -= [iTermAdvancedSettingsModel terminalMargin] * 2;
int iCharWidth = [_textview charWidth];
if (iCharWidth == 0) {
return 0;
@@ -2128,8 +2128,8 @@ - (void)replaceTerminatedShellWithNewInstance {
}
- (NSSize)idealScrollViewSizeWithStyle:(NSScrollerStyle)scrollerStyle {
NSSize innerSize = NSMakeSize([_screen width] * [_textview charWidth] + MARGIN * 2,
[_screen height] * [_textview lineHeight] + VMARGIN * 2);
NSSize innerSize = NSMakeSize([_screen width] * [_textview charWidth] + [iTermAdvancedSettingsModel terminalMargin] * 2,
[_screen height] * [_textview lineHeight] + [iTermAdvancedSettingsModel terminalVMargin] * 2);
BOOL hasScrollbar = [[_delegate realParentWindow] scrollbarShouldBeVisible];
NSSize outerSize =
[PTYScrollView frameSizeForContentSize:innerSize
@@ -5919,7 +5919,7 @@ - (void)textViewResizeFrameIfNeeded {
const CGFloat desiredHeight = _textview.desiredHeight;
if (fabs(desiredHeight - NSHeight(frame)) >= 0.5) {
// Update the wrapper's size, which in turn updates textview's size.
frame.size.height = desiredHeight + VMARGIN; // The wrapper is always larger by VMARGIN.
frame.size.height = desiredHeight + [iTermAdvancedSettingsModel terminalVMargin]; // The wrapper is always larger by VMARGIN.
_wrapper.frame = frame;
NSAccessibilityPostNotification(_textview,
@@ -7653,7 +7653,7 @@ - (void)sessionViewBeginDrag {
}
- (CGFloat)sessionViewDesiredHeightOfDocumentView {
return _textview.desiredHeight + VMARGIN;
return _textview.desiredHeight + [iTermAdvancedSettingsModel terminalVMargin];
}
- (BOOL)sessionViewShouldUpdateSubviewsFramesAutomatically {
View
@@ -1565,8 +1565,8 @@ + (NSSize)_sessionSizeWithCellSize:(NSSize)cellSize
NSSize size;
DLog(@" calculating session size based on %dx%d cells", columns, rows);
DLog(@" cell size is %@", NSStringFromSize(NSMakeSize(charWidth, lineHeight)));
size.width = columns * charWidth + MARGIN * 2;
size.height = rows * lineHeight + VMARGIN * 2;
size.width = columns * charWidth + [iTermAdvancedSettingsModel terminalMargin] * 2;
size.height = rows * lineHeight + [iTermAdvancedSettingsModel terminalVMargin] * 2;
DLog(@" size for content is %@", NSStringFromSize(size));
BOOL hasScrollbar = [term scrollbarShouldBeVisible];
NSSize outerSize =
@@ -1595,8 +1595,8 @@ - (NSSize)_sessionSize:(SessionView *)sessionView {
- (NSSize)_minSessionSize:(SessionView*)sessionView {
NSSize size;
PTYSession *session = [self sessionForSessionView:sessionView];
size.width = kVT100ScreenMinColumns * [[session textview] charWidth] + MARGIN * 2;
size.height = kVT100ScreenMinRows * [[session textview] lineHeight] + VMARGIN * 2;
size.width = kVT100ScreenMinColumns * [[session textview] charWidth] + [iTermAdvancedSettingsModel terminalMargin] * 2;
size.height = kVT100ScreenMinRows * [[session textview] lineHeight] + [iTermAdvancedSettingsModel terminalVMargin] * 2;
BOOL hasScrollbar = [parentWindow_ scrollbarShouldBeVisible];
NSSize scrollViewSize =
@@ -1990,8 +1990,8 @@ - (NSSize)sessionSizeForViewSize:(PTYSession *)aSession {
style:[parentWindow_ scrollerStyle]];
NSSize size = [[aSession view] maximumPossibleScrollViewContentSize];
DLog(@"Max size is %@", [NSValue valueWithSize:size]);
int width = (size.width - MARGIN * 2) / [[aSession textview] charWidth];
int height = (size.height - VMARGIN * 2) / [[aSession textview] lineHeight];
int width = (size.width - [iTermAdvancedSettingsModel terminalMargin] * 2) / [[aSession textview] charWidth];
int height = (size.height - [iTermAdvancedSettingsModel terminalVMargin] * 2) / [[aSession textview] lineHeight];
PtyLog(@"fitSessionToCurrentViewSize %@ gives %d rows", [NSValue valueWithSize:size], height);
if (width <= 0) {
ELog(@"WARNING: Session has %d width", width);
@@ -2970,8 +2970,8 @@ - (void)addSplitter:(NSSplitView *)splitter
controlSize:NSRegularControlSize
scrollerStyle:session.view.scrollview.scrollerStyle];
int chars = forHeight ? (contentSize.height - VMARGIN * 2) / cellSize.height :
(contentSize.width - MARGIN * 2) / cellSize.width;
int chars = forHeight ? (contentSize.height - [iTermAdvancedSettingsModel terminalVMargin] * 2) / cellSize.height :
(contentSize.width - [iTermAdvancedSettingsModel terminalMargin] * 2) / cellSize.width;
[intervalMap incrementNumbersBy:chars
inRange:[IntRange rangeWithMin:minPos size:size]];
}
Oops, something went wrong.

0 comments on commit 09e0746

Please sign in to comment.