forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindViewController.h
120 lines (95 loc) · 3.48 KB
/
FindViewController.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// -*- mode:objc -*-
/*
** FindViewController.h
**
** Copyright (c) 2011
**
** Author: George Nachman
**
** Project: iTerm2
**
** Description: View controller for find view. Controls the UI layer of
** searching a session.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import <Cocoa/Cocoa.h>
@protocol FindViewControllerDelegate
// Returns true if there is a text area to search.
- (BOOL)canSearch;
// Delegate should call resetFindCursor in textview.
- (void)resetFindCursor;
// Return [[[self currentSession] TEXTVIEW] findInProgress]
- (BOOL)findInProgress;
// Call [[[self currentSession] TEXTVIEW] continueFind];
- (BOOL)continueFind;
// Call [[self currentSession] TEXTVIEW] growSelectionLeft]
- (BOOL)growSelectionLeft;
// call [[[self currentSession] TEXTVIEW] growSelectionRight];
- (void)growSelectionRight;
// Return [[[self currentSession] TEXTVIEW] selectedText];
- (NSString*)selectedText;
// Return [textview selectedTextWithPad:NO]
- (NSString*)unpaddedSelectedText;
// call [[[self currentSession] TEXTVIEW] copy:self];
- (void)copySelection;
// call [[self currentSession] pasteString:text];
- (void)pasteString:(NSString*)string;
// call [[self window] makeFirstResponder:[[self currentSession] TEXTVIEW]];
- (void)takeFocus;
// Remove highlighted matches
- (void)clearHighlights;
// Preform a search
- (BOOL)findString:(NSString *)aString
forwardDirection:(BOOL)direction
ignoringCase:(BOOL)ignoreCase
regex:(BOOL)regex
withOffset:(int)offset;
@end
@interface FindViewController : NSViewController <NSTextFieldDelegate> {
IBOutlet NSSearchField* findBarTextField_;
IBOutlet NSProgressIndicator* findBarProgressIndicator_;
// These pointers are just "prototypes" and do not refer to any actual menu
// items.
IBOutlet NSMenuItem* ignoreCaseMenuItem_;
IBOutlet NSMenuItem* regexMenuItem_;
BOOL ignoreCase_;
BOOL regex_;
// Find happens incrementally. This remembers the string to search for.
NSMutableString* previousFindString_;
// Find runs out of a timer so that if you have a huge buffer then it
// doesn't lock up. This timer runs the show.
NSTimer* timer_;
id<FindViewControllerDelegate> delegate_;
NSRect fullFrame_;
NSSize textFieldSize_;
NSSize textFieldSmallSize_;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
- (void)dealloc;
- (void)close;
- (void)open;
- (void)toggleVisibility;
- (void)setFrameOrigin:(NSPoint)p;
- (IBAction)closeFindView:(id)sender;
- (IBAction)searchNextPrev:(id)sender;
- (IBAction)toggleIgnoreCase:(id)sender;
- (IBAction)toggleRegex:(id)sender;
- (void)searchNext;
- (void)searchPrevious;
- (void)findString:(NSString*)string;
- (void)setDelegate:(id<FindViewControllerDelegate>)delegate;
- (id<FindViewControllerDelegate>)delegate;
@end