Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add history to Highlight Char/Regex entry field #1248

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/guiguts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
our @replace_history;
our @search_history;
our @quicksearch_history;
our @highlight_history;
our @sopt = ( 0, 0, 0, 0, 0 ); # default is not whole word search
our @wfsearchopt;
our @userchars; # user defined chars for common characters dialog
Expand Down
8 changes: 8 additions & 0 deletions src/lib/Guiguts/FileMenu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,14 @@ EOM
}
print $save_handle ");\n\n";

print $save_handle ("\@highlight_history = (\n");
@array = @::highlight_history;
for my $index (@array) {
$index = ::escapeforperlstring($index);
print $save_handle qq/\t"$index",\n/;
}
print $save_handle ");\n\n";

print $save_handle ("\@multidicts = (\n");
for my $index (@::multidicts) {
print $save_handle qq/\t"$index",\n/;
Expand Down
23 changes: 17 additions & 6 deletions src/lib/Guiguts/Highlight.pm
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,20 @@ sub hilitepopup {
$::lglobal{hilitepop}->title('Character Highlight');
::initialize_popup_with_deletebinding('hilitepop');
my $hilitemode = 'exact';
my $f = $::lglobal{hilitepop}->Frame->pack( -side => 'top', -anchor => 'n' );
my $f = $::lglobal{hilitepop}->Frame->pack( -side => 'top', -anchor => 'n', -padx => 3 );
$f->Label( -text => 'Highlight Character(s) or Regex', )
->pack( -side => 'top', -pady => 2, -padx => 2, -anchor => 'n' );
my $entry = $f->Entry( -width => 40, )->pack(
$f->Button(
-command => sub {
::entry_history( $::lglobal{highlightentry}, \@::highlight_history );
},
-image => $::lglobal{hist_img},
-width => 9,
-height => 15,
)->pack( -side => 'left', -anchor => 'w' );
$::lglobal{highlightentry} = $f->Entry( -width => 40, )->pack(
-expand => 1,
-fill => 'x',
-padx => 3,
-pady => 3,
-anchor => 'n'
);
Expand Down Expand Up @@ -285,16 +292,20 @@ sub hilitepopup {
-width => 16,
)->grid( -row => 1, -column => 2, -padx => 2, -pady => 2 );
$f3->Button(
-command => sub { hilite( $entry->get, $hilitemode ) },
-text => 'Apply Highlights',
-width => 16,
-command => sub {
hilite( $::lglobal{highlightentry}->get, $hilitemode );
::add_entry_history( $::lglobal{highlightentry}->get, \@::highlight_history );
},
-text => 'Apply Highlights',
-width => 16,
)->grid( -row => 2, -column => 1, -padx => 2, -pady => 2 );
$f3->Button(
-command => \&::hiliteremove,
-text => 'Remove Highlight',
-width => 16,
)->grid( -row => 2, -column => 2, -padx => 2, -pady => 2 );
}
$::lglobal{highlightentry}->focus;
}

#
Expand Down
1 change: 1 addition & 0 deletions src/lib/Guiguts/Utilities.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,7 @@ sub add_entry_history {
push @$history_array_ref, $_;
last if @$history_array_ref >= $::history_size; # don't exceed maximum history size
}
::savesettings();
}

#
Expand Down
Loading