2002-02-14 23:24:53 +00:00
|
|
|
#import "FindSheetController.h"
|
2002-03-21 04:02:26 +00:00
|
|
|
#import "HexWindowController.h"
|
2002-02-14 23:24:53 +00:00
|
|
|
|
|
|
|
@implementation FindSheetController
|
|
|
|
|
2002-03-21 04:02:26 +00:00
|
|
|
/* FORM DELEGATION METHOD */
|
|
|
|
|
2002-12-31 19:06:40 +00:00
|
|
|
- (void)controlTextDidEndEditing:(NSNotification *)notification
|
2002-03-21 04:02:26 +00:00
|
|
|
{
|
|
|
|
[self updateStrings];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateStrings
|
|
|
|
{
|
|
|
|
[findString autorelease];
|
|
|
|
[replaceString autorelease];
|
|
|
|
|
2002-11-16 23:03:59 +00:00
|
|
|
findString = [[[findReplaceForm cellAtIndex:0] stringValue] copy];
|
|
|
|
replaceString = [[[findReplaceForm cellAtIndex:1] stringValue] copy];
|
2002-03-21 04:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* HIDE AND SHOW SHEET */
|
|
|
|
|
|
|
|
- (IBAction)showFindSheet:(id)sender
|
|
|
|
{
|
2002-12-31 19:06:40 +00:00
|
|
|
// load window so I can play with boxes
|
|
|
|
[self window];
|
|
|
|
|
|
|
|
// enable/disable boxes
|
|
|
|
[searchSelectionOnlyBox setEnabled:([(NSTextView *)[[sender window] firstResponder] rangeForUserTextChange].length != 0)];
|
|
|
|
|
2008-07-31 20:27:55 +00:00
|
|
|
// set inital values
|
2002-12-31 19:06:40 +00:00
|
|
|
if( ![searchSelectionOnlyBox isEnabled] ) [searchSelectionOnlyBox setIntValue:0];
|
|
|
|
|
|
|
|
// show sheet
|
2002-03-21 04:02:26 +00:00
|
|
|
[NSApp beginSheet:[self window] modalForWindow:[sender window] modalDelegate:self didEndSelector:NULL contextInfo:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)hideFindSheet:(id)sender
|
|
|
|
{
|
|
|
|
[[self window] orderOut:nil];
|
|
|
|
[NSApp endSheet:[self window]];
|
|
|
|
}
|
|
|
|
|
2002-02-14 23:24:53 +00:00
|
|
|
- (IBAction)findNext:(id)sender
|
|
|
|
{
|
2002-03-21 04:02:26 +00:00
|
|
|
[self updateStrings];
|
|
|
|
[self hideFindSheet:self];
|
|
|
|
NSLog( @"Finding next \"%@\"", findString );
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)findPrevious:(id)sender
|
|
|
|
{
|
|
|
|
[self updateStrings];
|
|
|
|
[self hideFindSheet:self];
|
|
|
|
NSLog( @"Finding previous \"%@\"", findString );
|
2002-02-14 23:24:53 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 04:02:26 +00:00
|
|
|
- (IBAction)findWithSelection:(id)sender
|
2002-02-14 23:24:53 +00:00
|
|
|
{
|
2002-03-21 04:02:26 +00:00
|
|
|
[findString autorelease];
|
|
|
|
findString = [[NSString string] retain];
|
|
|
|
NSLog( @"Finding \"%@\"", findString );
|
2002-02-14 23:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)replaceAll:(id)sender
|
|
|
|
{
|
2002-03-21 04:02:26 +00:00
|
|
|
[self updateStrings];
|
|
|
|
[self hideFindSheet:self];
|
|
|
|
NSLog( @"Replacing all \"%@\" with \"%@\"", findString, replaceString );
|
2002-02-14 23:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)replaceFindNext:(id)sender
|
|
|
|
{
|
2002-03-21 04:02:26 +00:00
|
|
|
[self updateStrings];
|
|
|
|
[self hideFindSheet:self];
|
|
|
|
NSLog( @"Replacing \"%@\" with \"%@\" and finding next", findString, replaceString );
|
2002-02-14 23:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|