App-Codit

 view release on metacpan or  search on metacpan

lib/App/Codit/Plugins/SearchReplace.pm  view on Meta::CPAN


	$self->{CASE} = \$casesensitive;
	$self->{CURRENT} = undef;
	$self->{LASTRESULTS} = [];
	$self->{MODE} = \$searchmode;
	$self->{OFFSET} = {};
	$self->{REPLACE} = \$replaceterm;
	$self->{REPLACED} = 0;
	$self->{REGEX} = \$useregex;
	$self->{SEARCH} = \$searchterm;
	$self->{SKIPPED} = 0;

	my @padding = (-padx => 2, -pady => 2);

	my $sa = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -fill => 'x');

	my $sf = $sa->Frame->pack(-expand => 1, -fill => 'x');
	$sf->Label(
		-text => 'Search',
		-width => 7,
		-anchor => 'e',
	)->pack(@padding, -side => 'left');
	my $se = $sf->Entry(
		-textvariable => \$searchterm,
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');
	$se->bind('<Return>', [$self, 'Find']);

	my $rf = $sa->Frame->pack(-expand => 1, -fill => 'x');
	$rf->Label(
		-text => 'Replace',
		-width => 7,
		-anchor => 'e',
	)->pack(@padding, -side => 'left');
	$rf->Entry(
		-textvariable => \$replaceterm,
	)->pack(@padding, -side => 'left', -expand => 1, -fill => 'x');

	my $sb = $page->LabFrame(
		-labelside => 'acrosstop',
		-relief => 'groove',
		-label => 'Search options',
	)->pack(@padding, -fill => 'x');

	$sb->Checkbutton(
		-variable => \$useregex,
		-text => 'Regular expression',
		-onvalue => '-regexp',
		-offvalue => '-exact',
		-anchor => 'w',
	)->pack(@padding, -fill => 'x');
	$sb->Checkbutton(
		-variable => \$casesensitive,
		-onvalue => '-case',
		-offvalue => '-nocase',
		-text => 'Case sensitive',
		-anchor => 'w',
	)->pack(@padding, -fill => 'x');
	my $mb = $sb->Menubutton(
#		-relief => 'raised',
		-anchor => 'w',
		-textvariable => \$searchmode,
	)->pack(@padding, -fill => 'x');
	my @menu = ();
	for ($srchcur, $srchall, $srchprj, $srchres) {
		my $mode = $_;
		push @menu, [command => $mode,
			-command => sub { $searchmode = $mode },
		];
	}
	$mb->configure(-menu => $mb->Menu(
		-menuitems => \@menu,
	));


	my $sc = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -fill => 'x');
	$sc->gridColumnconfigure(0, -weight => 2);
	$sc->gridColumnconfigure(1, -weight => 2);
	$sc->Button(
		-command => ['Find', $self],
		-text => 'Find',
		-width => 8,
	)->grid(@padding, -column => 0, -row => 0, -sticky => 'ew');
	$sc->Button(
		-command => ['Clear', $self],
		-text => 'Clear',
		-width => 8,
	)->grid(@padding, -column => 1, -row => 0, -sticky => 'ew');
	$sc->Button(
		-command => ['Replace', $self],
		-text => 'Replace',
		-width => 8,
	)->grid(@padding, -column => 0, -row => 1, -sticky => 'ew');
	$sc->Button(
		-command => ['Skip', $self],
		-text => 'Skip',
		-width => 8,
	)->grid(@padding, -column => 1, -row => 1, -sticky => 'ew');


	my $tf = $page->Frame(
		-relief => 'groove',
		-borderwidth => 2,
	)->pack(@padding, -expand => 1, -fill => 'both');
	$tf->gridColumnconfigure(0, -weight => 2);
	$tf->gridColumnconfigure(1, -weight => 2);
	$tf->gridRowconfigure(1, -weight => 2);
	$tf->Button(
		-text => 'Previous',
		-command => ['BrowsePrevious', $self],
		-width => 8,
	)->grid(@padding, -column => 0, -row => 0, -sticky => 'ew');
	$tf->Button(
		-text => 'Next',
		-command => ['BrowseNext', $self],
		-width => 8,
	)->grid(@padding, -column => 1, -row => 0, -sticky => 'ew');
	my $results = $tf->Scrolled('ITree',
		-height => 4,
		-browsecmd => ['Select', $self],
		-scrollbars => 'osoe',
		-separator => '@',
	)->grid(@padding, -column => 0, -columnspan => 2, -row => 1, -sticky => 'nsew');
	$results->autosetmode;
	$self->{RESULTSLIST} = $results;
	
	$self->cmdHookAfter('doc_select', 'ShowResults', $self);



( run in 0.577 second using v1.01-cache-2.11-cpan-d7f47b0818f )