Skip to content

Commit 4f32bfd

Browse files
valsongclaude
andcommitted
Add inline find bar as an alternative to the floating find/replace panel
Previously, Cmd+F opened a floating NSPanel (MMFindReplaceController). This commit introduces an optional inline find bar (MMFindBarView) that appears as an overlay anchored to the top-right corner of the text area, similar to the find bar in VS Code and other modern editors. The inline mode is controlled by a new "Find bar: Inline" preference in the General pane (off by default, preserving existing behaviour). Changes: - Add MMFindBarView: a programmatic NSView overlay with find/replace fields, Ignore Case / Match Word checkboxes, Replace / Replace All / Previous / Next buttons, and an MMHoverButton close button styled to match the tab close button - The bar is freely draggable within the text-editing area and snaps to the top-right corner only on first show; subsequent Cmd+F presses preserve the user's dragged position - Window resize and tab-bar show/hide keep the bar in place via a delta-based repositioning algorithm - Add MMFindBarInlineKey user default and register it (default NO) - Add "Find bar" toggle to the General preferences pane - Route ShowFindReplaceDialogMsgID to the inline bar or the floating panel depending on the preference (MMVimController) - Add -sendFindBarAction:findString:replaceString:ignoreCase:matchWord: to MMWindowController to unify search message dispatch for both modes; fix IBAction tag-to-FRD-flags mapping (tag 2→flags 3, tag 3→flags 4) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b0e4e53 commit 4f32bfd

15 files changed

+610
-24
lines changed

src/MacVim/Base.lproj/Preferences.xib

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<objects>
99
<customObject id="-2" userLabel="File's Owner" customClass="MMPreferenceController">
1010
<connections>
11+
<outlet property="findBarInlineButton" destination="fBr-00-FB2" id="fBr-00-FB8"/>
1112
<outlet property="advancedPreferences" destination="620" id="632"/>
1213
<outlet property="allowForceClickLookUpButton" destination="rlt-zw-mfW" id="xCv-HS-zyJ"/>
1314
<outlet property="appearancePreferences" destination="hr4-G4-3ZG" id="G54-DD-ACh"/>
@@ -24,11 +25,11 @@
2425
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
2526
<userDefaultsController representsSharedInstance="YES" id="58" userLabel="Shared Defaults"/>
2627
<customView id="115" userLabel="General">
27-
<rect key="frame" x="0.0" y="0.0" width="483" height="382"/>
28+
<rect key="frame" x="0.0" y="0.0" width="483" height="407"/>
2829
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
2930
<subviews>
3031
<customView id="5x5-P0-afk" userLabel="Open untitled window">
31-
<rect key="frame" x="20" y="284" width="433" height="78"/>
32+
<rect key="frame" x="20" y="309" width="433" height="78"/>
3233
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
3334
<subviews>
3435
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="117">
@@ -77,7 +78,7 @@
7778
</subviews>
7879
</customView>
7980
<customView id="p6o-fo-STi" userLabel="Open files from applications">
80-
<rect key="frame" x="20" y="144" width="433" height="132"/>
81+
<rect key="frame" x="20" y="169" width="433" height="132"/>
8182
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
8283
<subviews>
8384
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="116">
@@ -156,7 +157,7 @@
156157
</subviews>
157158
</customView>
158159
<customView id="dlz-JQ-U4e" userLabel="After last window closes">
159-
<rect key="frame" x="20" y="114" width="381" height="22"/>
160+
<rect key="frame" x="20" y="139" width="381" height="22"/>
160161
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
161162
<subviews>
162163
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="126">
@@ -189,7 +190,7 @@
189190
</subviews>
190191
</customView>
191192
<customView id="6BL-o0-OrR" userLabel="Window Resizing">
192-
<rect key="frame" x="20" y="89" width="444" height="17"/>
193+
<rect key="frame" x="20" y="114" width="444" height="17"/>
193194
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
194195
<subviews>
195196
<button id="f9h-8n-asD" userLabel="allow smooth resizing">
@@ -216,6 +217,34 @@
216217
</textField>
217218
</subviews>
218219
</customView>
220+
<customView id="fBr-00-FB1" userLabel="Find Bar">
221+
<rect key="frame" x="20" y="89" width="444" height="17"/>
222+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
223+
<subviews>
224+
<button id="fBr-00-FB2" userLabel="findBarInlineButton">
225+
<rect key="frame" x="188" y="-1" width="285" height="18"/>
226+
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
227+
<string key="toolTip">Shows an inline find/replace bar anchored to the top-right corner of the editor, instead of a floating dialog box.</string>
228+
<buttonCell key="cell" type="check" title="Use inline find bar (top-right overlay)" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="fBr-00-FB3">
229+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
230+
<font key="font" metaFont="system"/>
231+
</buttonCell>
232+
<connections>
233+
<action selector="findBarModeChanged:" target="-2" id="fBr-00-FB4"/>
234+
<binding destination="58" name="value" keyPath="values.MMFindBarInline" id="fBr-00-FB5"/>
235+
</connections>
236+
</button>
237+
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="fBr-00-FB6" userLabel="Find bar">
238+
<rect key="frame" x="-2" y="0.0" width="187" height="17"/>
239+
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
240+
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Find bar:" id="fBr-00-FB7">
241+
<font key="font" metaFont="system"/>
242+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
243+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
244+
</textFieldCell>
245+
</textField>
246+
</subviews>
247+
</customView>
219248
<customView id="nRD-BI-GeM" userLabel="Launch behavior">
220249
<rect key="frame" x="20" y="64" width="444" height="17"/>
221250
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>

src/MacVim/MMAppController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ + (void)registerDefaults
233233
@"", MMLastUsedBundleVersionKey,
234234
[NSNumber numberWithBool:YES], MMShowWhatsNewOnStartupKey,
235235
[NSNumber numberWithBool:0], MMScrollOneDirectionOnlyKey,
236+
[NSNumber numberWithBool:NO], MMFindBarInlineKey,
236237
nil];
237238

238239
[ud registerDefaults:macvimDefaults];

src/MacVim/MMFindBarView.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* vi:set ts=8 sts=4 sw=4 ft=objc:
2+
*
3+
* VIM - Vi IMproved by Bram Moolenaar
4+
* MacVim GUI port by Bjorn Winckler
5+
*
6+
* Do ":help uganda" in Vim to read copying and usage conditions.
7+
* Do ":help credits" in Vim to see a list of people who contributed.
8+
* See README.txt for an overview of the Vim source code.
9+
*/
10+
11+
#import <Cocoa/Cocoa.h>
12+
13+
14+
@class MMFindBarView;
15+
16+
@protocol MMFindBarViewDelegate <NSObject>
17+
- (void)findBarView:(MMFindBarView *)view findNext:(BOOL)forward;
18+
- (void)findBarView:(MMFindBarView *)view replace:(BOOL)replaceAll;
19+
- (void)findBarViewDidClose:(MMFindBarView *)view;
20+
// Returns the rect (in MMFindBarView's superview coordinates) within which the
21+
// bar may be dragged. Typically this is the text-view frame, excluding the
22+
// tabline and scrollbars.
23+
- (NSRect)findBarViewDraggableBounds:(MMFindBarView *)view;
24+
@end
25+
26+
27+
@interface MMFindBarView : NSView <NSTextFieldDelegate>
28+
29+
@property (nonatomic, assign) id<MMFindBarViewDelegate> delegate;
30+
31+
- (void)showWithText:(NSString *)text flags:(int)flags;
32+
- (NSString *)findString;
33+
- (NSString *)replaceString;
34+
- (BOOL)ignoreCase;
35+
- (BOOL)matchWord;
36+
37+
@end

0 commit comments

Comments
 (0)