Skip to content

Allow pinning the cmdline to be aligned to the bottom of window #1280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions runtime/doc/gui_mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,21 @@ Here is a list of relevant dictionary entries:

KEY VALUE ~
*MMCellWidthMultiplier* width of a normal glyph in em units [float]
*MMCmdLineAlignBottom* Pin command-line to bottom of MacVim [bool]
*MMDialogsTrackPwd* open/save dialogs track the Vim pwd [bool]
*MMDisableLaunchAnimation* disable launch animation when opening a new
MacVim window [bool]
*MMFullScreenFadeTime* fade delay for non-native fullscreen [float]
*MMFontPreserveLineSpacing* use the line-spacing as specified by font [bool]
*MMLoginShellArgument* login shell parameter [string]
*MMLoginShellCommand* which shell to use to launch Vim [string]
*MMFullScreenFadeTime* fade delay for non-native fullscreen [float]
*MMNativeFullScreen* use native full screen mode [bool]
*MMNonNativeFullScreenShowMenu* show menus when in non-native full screen [bool]
*MMNonNativeFullScreenSafeAreaBehavior*
behavior for non-native full sreen regarding
the safe area (aka the "notch") [int]
*MMNoFontSubstitution* disable automatic font substitution [bool]
(Deprecated: Non-CoreText renderer only)
*MMFontPreserveLineSpacing* use the line-spacing as specified by font [bool]
*MMNoTitleBarWindow* hide title bar [bool]
*MMTitlebarAppearsTransparent* enable a transparent titlebar [bool]
*MMAppearanceModeSelection* dark mode selection (|macvim-dark-mode|)[bool]
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -5405,6 +5405,7 @@ M motion.txt /*M*
MDI starting.txt /*MDI*
MMAppearanceModeSelection gui_mac.txt /*MMAppearanceModeSelection*
MMCellWidthMultiplier gui_mac.txt /*MMCellWidthMultiplier*
MMCmdLineAlignBottom gui_mac.txt /*MMCmdLineAlignBottom*
MMDialogsTrackPwd gui_mac.txt /*MMDialogsTrackPwd*
MMDisableLaunchAnimation gui_mac.txt /*MMDisableLaunchAnimation*
MMFontPreserveLineSpacing gui_mac.txt /*MMFontPreserveLineSpacing*
Expand Down
42 changes: 35 additions & 7 deletions src/MacVim/Base.lproj/Preferences.xib
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@
<point key="canvasLocation" x="137.5" y="21.5"/>
</customView>
<customView id="hr4-G4-3ZG" userLabel="Appearance">
<rect key="frame" x="0.0" y="0.0" width="483" height="315"/>
<rect key="frame" x="0.0" y="0.0" width="483" height="341"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView id="fw0-VK-Nbz" userLabel="Dark mode selection">
<rect key="frame" x="19" y="137" width="433" height="156"/>
<rect key="frame" x="19" y="163" width="433" height="156"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="T40-Os-PUf" userLabel="Dark mode selection">
Expand Down Expand Up @@ -322,7 +322,7 @@
</subviews>
</customView>
<customView id="7af-iK-4r7" userLabel="Titlebar appearance">
<rect key="frame" x="19" y="91" width="433" height="38"/>
<rect key="frame" x="19" y="117" width="433" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button id="7ie-0J-0Zr">
Expand Down Expand Up @@ -361,7 +361,7 @@
</subviews>
</customView>
<customView id="BpJ-rH-ona" userLabel="Full Screen">
<rect key="frame" x="19" y="45" width="433" height="38"/>
<rect key="frame" x="19" y="71" width="433" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button toolTip="Use macOS's native full screen mode, which integrates with Mission Control and creates a new Space for the window." id="YKV-u2-Egc" userLabel="Use native full screen">
Expand Down Expand Up @@ -405,7 +405,7 @@
</subviews>
</customView>
<customView id="a3v-cB-TFa" userLabel="Font">
<rect key="frame" x="19" y="20" width="433" height="18"/>
<rect key="frame" x="19" y="46" width="433" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button id="A48-s0-kdR" userLabel="Preserve Line Spacing">
Expand All @@ -432,8 +432,36 @@
</textField>
</subviews>
</customView>
<customView id="Dey-Wx-2gx" userLabel="Cmdline">
<rect key="frame" x="20" y="20" width="433" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button id="qMh-iV-0iD">
<rect key="frame" x="189" y="-1" width="244" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<string key="toolTip">When using smooth resizing, guioption+=k, or full screen; MacVim's window size can sometimes be slightly larger than Vim's content size, causing the command-line to not be aligned to the bottom. This option will make sure the command-line is always pinned to the bottom.</string>
<buttonCell key="cell" type="check" title="Pin to the bottom of the window" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="uZL-IX-Dv8">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="cmdlineAlignBottomChanged:" target="-2" id="LgN-MI-0Nt"/>
<binding destination="58" name="value" keyPath="values.MMCmdLineAlignBottom" id="pIr-52-5vV"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="Lzq-i0-zWi" userLabel="Cmdline">
<rect key="frame" x="-2" y="0.0" width="187" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Command-line:" id="2Lp-vX-AcA">
<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>
</customView>
</subviews>
<point key="canvasLocation" x="137.5" y="412.5"/>
<point key="canvasLocation" x="137.5" y="425.5"/>
</customView>
<customView id="620" userLabel="Advanced">
<rect key="frame" x="0.0" y="0.0" width="483" height="264"/>
Expand Down Expand Up @@ -504,7 +532,7 @@
</connections>
</button>
</subviews>
<point key="canvasLocation" x="137.5" y="743"/>
<point key="canvasLocation" x="144" y="911"/>
</customView>
</objects>
</document>
1 change: 1 addition & 0 deletions src/MacVim/MMAppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
- (void)refreshAllAppearances;
- (void)refreshAllFonts;
- (void)refreshAllResizeConstraints;
- (void)refreshAllTextViews;

- (IBAction)newWindow:(id)sender;
- (IBAction)newWindowAndActivate:(id)sender;
Expand Down
17 changes: 17 additions & 0 deletions src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#import "MMAppController.h"
#import "MMPreferenceController.h"
#import "MMVimController.h"
#import "MMVimView.h"
#import "MMWindowController.h"
#import "MMTextView.h"
#import "Miscellaneous.h"
Expand Down Expand Up @@ -253,6 +254,7 @@ + (void)initialize
[NSNumber numberWithInt:0], MMNonNativeFullScreenSafeAreaBehaviorKey,
[NSNumber numberWithBool:YES], MMShareFindPboardKey,
[NSNumber numberWithBool:NO], MMSmoothResizeKey,
[NSNumber numberWithBool:NO], MMCmdLineAlignBottomKey,
nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
Expand Down Expand Up @@ -1124,6 +1126,7 @@ - (void)refreshAllAppearances
}
}

/// Refresh all Vim text views' fonts.
- (void)refreshAllFonts
{
unsigned count = [vimControllers count];
Expand All @@ -1133,6 +1136,8 @@ - (void)refreshAllFonts
}
}

/// Refresh all resize constraints based on smooth resize configurations
/// and resize the windows to match the constraints.
- (void)refreshAllResizeConstraints
{
const unsigned count = [vimControllers count];
Expand All @@ -1142,6 +1147,18 @@ - (void)refreshAllResizeConstraints
}
}

/// Refresh all text views and re-render them, as well as updating their
/// cmdline alignment properties to make sure they are pinned properly.
- (void)refreshAllTextViews
{
unsigned count = [vimControllers count];
for (unsigned i = 0; i < count; ++i) {
MMVimController *vc = [vimControllers objectAtIndex:i];
[vc.windowController.vimView.textView updateCmdlineRow];
vc.windowController.vimView.textView.needsDisplay = YES;
}
}

- (IBAction)newWindow:(id)sender
{
ASLogDebug(@"Open new window");
Expand Down
20 changes: 20 additions & 0 deletions src/MacVim/MMBackend.m
Original file line number Diff line number Diff line change
Expand Up @@ -1816,13 +1816,33 @@ - (void)insertVimStateMessage
if (numTabs < 0)
numTabs = 0;

// Custom hacks to deal with cmdline_row not being perfect for our use cases.
int cmdline_row_adjusted = cmdline_row;
if (State == MODE_HITRETURN) {
// When we are in hit-return mode, Vim does a weird thing and sets
// cmdline_row to be the 2nd-to-last row, which would make pinning
// cmdline to bottom look weird. This is done in msg_start() and
// wait_return().
// Instead of modifying Vim, we just hack around this by manually
// increasing the row by one. This would make the pin happen right at
// the "Hit Enter..." prompt.
cmdline_row_adjusted++;
} else if (State == MODE_ASKMORE) {
// In "more" mode, Vim sometimes set cmdline_row, sometimes it doesn't.
// Silver lining is that it always only takes one row and doesn't wrap
// like hit-enter, so we know we can always just pin it to the last row
// and be done with the hack.
cmdline_row_adjusted = Rows - 1;
}

NSDictionary *vimState = [NSDictionary dictionaryWithObjectsAndKeys:
[[NSFileManager defaultManager] currentDirectoryPath], @"pwd",
[NSNumber numberWithInt:p_mh], @"p_mh",
[NSNumber numberWithBool:mmta], @"p_mmta",
[NSNumber numberWithInt:numTabs], @"numTabs",
[NSNumber numberWithInt:fuoptions_flags], @"fullScreenOptions",
[NSNumber numberWithLong:p_mouset], @"p_mouset",
[NSNumber numberWithInt:cmdline_row_adjusted], @"cmdline_row", // Used for pinning cmdline to bottom of window
nil];

// Put the state before all other messages.
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MMCoreTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column;
- (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr
numColumns:(int)nc;
- (void)updateCmdlineRow;

//
// NSTextView methods
Expand Down
Loading