2 Reusable find panel functionality (find, replace).
3 Need one shared instance of TextFinder to which the menu items and widgets in the find panel are connected.
5 Works on first responder, assumed to be an NSTextView.
8 #import <Cocoa/Cocoa.h>
13 @interface TextFinder
: NSObject
{
15 NSString
*replaceString
;
20 id replaceAllScopeMatrix
;
22 BOOL lastFindWasSuccessful
;
25 /* Common way to get a text finder. One instance of TextFinder per app is good enough. */
28 /* Main method for external users; does a find in the first responder. Selects found range or beeps. */
29 - (BOOL
)find
:(BOOL
)direction
;
32 - (NSPanel
*)findPanel
;
34 /* Gets the first responder and returns it if it's an NSTextView */
35 - (NSTextView
*)textObjectToSearchIn
;
37 /* Get/set the current find string. Will update UI if UI is loaded */
38 - (NSString
*)findString
;
39 - (void)setFindString
:(NSString
*)string
;
40 - (void)setFindString
:(NSString
*)string writeToPasteboard
:(BOOL
)flag
;
42 /* Get/set the current replace string. Will update UI if UI is loaded */
43 - (NSString
*)replaceString
;
44 - (void)setReplaceString
:(NSString
*)string
;
46 /* Misc internal methods */
47 - (void)appDidActivate
:(NSNotification
*)notification
;
48 - (void)loadFindStringFromPasteboard
;
49 - (void)loadStringToPasteboard
:(NSString
*)string
;
51 /* Action methods, sent from the find panel UI; can also be connected to menu items */
52 - (void)findNext
:(id
)sender
;
53 - (void)findPrevious
:(id
)sender
;
54 - (void)findNextAndOrderFindPanelOut
:(id
)sender
;
55 - (void)replace
:(id
)sender
;
56 - (void)replaceAndFind
:(id
)sender
;
57 - (void)replaceAll
:(id
)sender
;
58 - (void)orderFrontFindPanel
:(id
)sender
;
59 - (void)takeFindStringFromSelection
:(id
)sender
;
60 - (void)takeReplaceStringFromSelection
:(id
)sender
;
61 - (void)jumpToSelection
:(id
)sender
;