Skip to content

Commit

Permalink
adjust DTerm width to 70% of underlaying window width
Browse files Browse the repository at this point in the history
min 640, max 70% of screen size (up to 1680px)
  • Loading branch information
muhqu committed Apr 7, 2016
1 parent 4d0c8b3 commit 4e88dc3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Term Window/DTTermWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,23 @@ - (void)activateWithWorkingDirectory:(NSString*)wdPath
// Select all of the command field
[commandFieldEditor setSelectedRange:NSMakeRange(0, [[commandFieldEditor string] length])];
[window makeFirstResponder:commandField];

// If no parent window; use main screen

// desired width = 70% window width, with max window/screen width at 1680
// 1680 = 22" is a good cap, anything above looks redicoulous on larger screens like 2560 = 29"
NSScreen* mainScreen = [NSScreen mainScreen];
CGFloat screenWidth = mainScreen.visibleFrame.size.width;
CGFloat maxReasonableScreenWidth = 1680.0;
CGFloat minWidth = 640.0;
CGFloat maxWidth = fmin(maxReasonableScreenWidth,screenWidth)*0.7;
CGFloat desiredWidth = fmax(fmin(frame.size.width*0.7, maxWidth), minWidth);

// If no parent window; use main screen
if(NSEqualRects(frame, NSZeroRect)) {
NSScreen* mainScreen = [NSScreen mainScreen];
frame = [mainScreen visibleFrame];
frame = [mainScreen visibleFrame];
desiredWidth = fmax(maxWidth, minWidth);
}

// Set frame according to parent window location
CGFloat desiredWidth = fmin(frame.size.width - 20.0, 640.0);
NSRect newFrame = NSInsetRect(frame, (frame.size.width - desiredWidth) / 2.0, 0.0);
newFrame.size.height = [window frame].size.height + [resultsTextView desiredHeightChange];
newFrame.origin.y = frame.origin.y + frame.size.height - newFrame.size.height;
Expand Down

0 comments on commit 4e88dc3

Please sign in to comment.