Skip to content

Commit 9e0d66b

Browse files
committed
Fixing a bug of the info pane refresh
1 parent ba1f643 commit 9e0d66b

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pacbro.pl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use strict;
77
use warnings;
8-
use Getopt::Long qw(:config no_auto_abbrev no_ignore_case);
98
use Time::HiRes ();
109
use POSIX ();
1110

@@ -23,12 +22,12 @@
2322
my $log_fname = "$work_dir/app.log"; # global log
2423
my $path_pfx = "$work_dir/$sess_code";
2524

26-
Getopt::Long::GetOptions(
27-
'aur' => \(my $use_aur),
28-
'help|h' => \(my $show_help),
29-
);
25+
my %cmd_args = ();
26+
while (my $arg = shift(@ARGV)) {
27+
if ($arg eq '-h' || $arg eq '--help') { $cmd_args{help} = 1; }
28+
elsif ($arg eq '--aur') { $cmd_args{aur} = 1; }
29+
}
3030

31-
# die("Install 'yay' to use AUR feature\n") if $use_aur && !$yayx;
3231
# TODO: new information report dialog - package full dependency tree
3332

3433
my $shutdown_hooks = [];
@@ -48,7 +47,8 @@
4847
my $pac_inst_states = [
4948
{ code => 'E', label => 'Explicitly Installed', short => 'explicit' },
5049
{ code => 'D', label => 'Installed as Dependency', short => 'as dep' }, # was 'I'
51-
{ code => 'N', label => 'Not Installed', short => 'not inst' }
50+
{ code => 'N', label => 'Not Installed', short => 'not inst' },
51+
{ code => '*', label => 'All', short => '' }
5252
];
5353

5454
my $outdated_states = [
@@ -153,7 +153,7 @@
153153
# prepare key map
154154
my $tmux_key_map = {map {$_->{key} => $_} @$tmux_key_list};
155155

156-
$show_help && do{ print(help()); exit(0); };
156+
$cmd_args{help} && do{ print(help()); exit(0); };
157157
tmux_start($tmux);
158158

159159
while (my $msg = pacbro_next_input_cmd($tmux)) {
@@ -196,7 +196,7 @@ sub tmux_start {
196196
my $binds = "--bind enter:'$sel_action' --bind double-click:'$sel_action'";
197197
$binds .= " --bind left-click:'$sel_action'";
198198
$binds .= " --bind focus:'execute-silent(echo PACFOCUS {} >> $cmd_in)'";
199-
# $binds .= " --bind focus:'$sel_action'" if !$use_aur; # do not auto-load package info
199+
# $binds .= " --bind focus:'$sel_action'" if !$cmd_args{aur}; # do not auto-load package info
200200
$binds .= " --bind 'ctrl-alt-r:reload(cat $main_file)'";
201201
$binds .= " --bind 'load:first'";
202202
$binds .= " --bind 'start:unbind(ctrl-c,ctrl-g,ctrl-q,esc)'"; # do not allow exiting keys
@@ -402,7 +402,7 @@ sub package_sel {
402402

403403
if (!($_ = $tmux->{pac}) || $_->{name} ne $pac->{name}) { # if package is different
404404
write_file("$tmux->{pans}->{info}->{file}", $pac->{info_text} // '');
405-
$tmux->{comm}->("send-keys -t $tmux->{pans}->{info}->{id} q g");
405+
$tmux->{comm}->("send-keys -t $tmux->{pans}->{info}->{id} g R");
406406
}
407407
$tmux->{pac} = $pac;
408408
my $pac_det_lists = pac_deps_lists_get_or_load($pac, $tmux->{db}->{pac_map}); # { list_name => multiline_text }
@@ -493,7 +493,7 @@ sub pac_db_load_full { # load/pull full package list & package details map
493493

494494
report(iso_tstmp_now() . " will load packages' metadata now");
495495

496-
my $pac_list_exe = ($use_aur ? "(curl -sL https://aur.archlinux.org/packages.gz | gunzip | sed -e 's/^/aur /'; pacman -Sl)" : "pacman -Sl") . ' | sort -k 2.1';
496+
my $pac_list_exe = ($cmd_args{aur} ? "(curl -sL https://aur.archlinux.org/packages.gz | gunzip | sed -e 's/^/aur /'; pacman -Sl)" : "pacman -Sl") . ' | sort -k 2.1';
497497
my ($pac_list_file, $pac_inst_file, $pac_sync_file, $pac_files_file) = ("$work_dir/db_pac_list", "$work_dir/db_pac_inst", "$work_dir/db_pac_sync", "$work_dir/db_pac_files");
498498

499499
system(<<~"CMD");
@@ -932,14 +932,16 @@ sub repo_filter {
932932
sub inst_filter {
933933
my ($tmux, $menu, $item_list) = @_;
934934
!@$item_list && return; # exited via Esc
935-
$item_list = [] if scalar(@$item_list) == scalar(@$pac_inst_states); # ALL - no filter
935+
$item_list = [] if scalar(@$item_list) >= (scalar(@$pac_inst_states) - 1); # ALL - no filter
936936

937937
my $code_by_lab = ($::{pac_inst_cd_by_lab} //= {map {$_->{label} => $_->{code}} @$pac_inst_states});
938938
my $codes = join('', sort grep { $_ } map {$code_by_lab->{$_}} @$item_list);
939+
($item_list, $codes) = ([], '') if index($codes, '*') > -1;
940+
$menu->{chosen} = $item_list;
941+
939942
$codes eq ($tmux->{flt}->{inst} // '') && return; # not changed
940943
$tmux->{flt}->{inst} = $codes;
941944

942-
$menu->{chosen} = $item_list;
943945
pac_list_load($tmux);
944946
tmux_status_bar_update($tmux);
945947
}

0 commit comments

Comments
 (0)