-
-
Notifications
You must be signed in to change notification settings - Fork 690
Expand file tree
/
Copy pathMMFindReplaceController.m
More file actions
72 lines (57 loc) · 1.93 KB
/
MMFindReplaceController.m
File metadata and controls
72 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* vi:set ts=8 sts=4 sw=4 ft=objc:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
#import "MacVim.h"
#import "MMFindReplaceController.h"
@implementation MMFindReplaceController
+ (MMFindReplaceController *)sharedInstance
{
static MMFindReplaceController *singleton = nil;
if (!singleton) {
singleton = [[MMFindReplaceController alloc]
initWithWindowNibName:@"FindAndReplace"];
[singleton setWindowFrameAutosaveName:@"FindAndReplace"];
}
return singleton;
}
- (void)showWithText:(NSString *)text flags:(int)flags
{
// Ensure that the window has been loaded by calling this first.
NSWindow *window = [self window];
// Set collection behavior to ensure the dialog appears in the current
// space rather than jumping to another space.
if (AVAILABLE_MAC_OS(10, 7)) {
NSWindowCollectionBehavior wcb = window.collectionBehavior;
wcb |= NSWindowCollectionBehaviorMoveToActiveSpace;
[window setCollectionBehavior:wcb];
}
if (text && [text length] > 0)
[findBox setStringValue:text];
// NOTE: The 'flags' values must match the FRD_ defines in gui.h.
[matchWordButton setState:(flags & 0x08 ? NSControlStateValueOn : NSControlStateValueOff)];
[ignoreCaseButton setState:(flags & 0x10 ? NSControlStateValueOff : NSControlStateValueOn)];
[window makeKeyAndOrderFront:self];
}
- (NSString *)findString
{
return [findBox stringValue];
}
- (NSString *)replaceString
{
return [replaceBox stringValue];
}
- (BOOL)ignoreCase
{
return [ignoreCaseButton state] == NSControlStateValueOn;
}
- (BOOL)matchWord
{
return [matchWordButton state] == NSControlStateValueOn;
}
@end // MMFindReplaceController