From 4afa0b8da16769c38050e0d3f499ed1045cad42a Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 31 Jan 2022 16:38:17 -0500 Subject: loading and saving pager option fixed --- gmi.pl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'gmi.pl') diff --git a/gmi.pl b/gmi.pl index 5d9f589..d61353c 100755 --- a/gmi.pl +++ b/gmi.pl @@ -10,7 +10,7 @@ use warnings; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v0.0.32'; +our $VERSION = 'v0.0.33'; # TODO: # back() only works once; should fix this @@ -46,7 +46,6 @@ my %config = ( 'pager' => 'less -R', 'doc_out' => 1, ); -$ENV{PAGER} = $config{pager}; my @doc; my @links; my $current_url = ""; @@ -82,6 +81,7 @@ if (! -e $xdg_cache) { load_config(); my $wrapper = Text::Wrapper->new(columns=>$config{textwrap}, body_start=>''); +$ENV{PAGER} = $config{pager}; my $term=new Term::ReadLine "hmm, what goes here?"; my $OUT = $term->OUT || \*STDOUT; @@ -135,7 +135,7 @@ my %commands = ( 'pretty_headers' => [sub { toggle($config{pretty_headers}) }, "0 = do nothing, 1 = pretty."], 'textwrap' => [sub { textwrap($_[0]) }, "Set textwrap length.\nGiving 'auto' will " . "automatically determine the appropriate length."], - 'pager' => [sub { pager($_[0]) }, "Set which pager to use. (currently $config{pager})"], + 'pager' => [sub { pager($_[0],$_[1]) }, "Set which pager to use. (currently $config{pager})"], 'save-config' => [sub { save_config() }, 'Save the config settings.'], 'load-config' => [sub { load_config() }, "Load the config settings.\n" . 'This is not needed as the configs are loaded when the program is started.' ], @@ -173,17 +173,17 @@ $prompt = "$current_url > "; print $OUT "Press to see available commands.\n"; while ( defined ($_ = $term->readline($prompt)) ) { if ($_) { - my ($command, $detail) = split(/\s/, $_); - do_command(\$command, \$detail); + my ($command, $detail, @other_details) = split(/\s/, $_); + do_command(\$command, \$detail, @other_details); } $prompt = "$current_url > "; } sub do_command { - # referenced command, referenced arg - my ($rCmd, $rArg) = @_; + # referenced command, referenced arg, additional args + my ($rCmd, $rArg, $rArgs) = @_; - # ## @_ + ### @_ # checking if %commands even has the command if (exists $commands{$$rCmd}) { @@ -191,7 +191,8 @@ sub do_command { my $rsub = $commands{$$rCmd}[0]; #running the subroutine - &$rsub($$rArg); + &$rsub($$rArg,$rArgs); + } # options doesn't have the command else { @@ -861,9 +862,15 @@ sub textwrap { } sub pager { - my ($p) = @_; + my ($p,@other) = @_; + ### @other if ($p) { $config{pager} = $p; + if ($other[0]) { + for (@other) { + $config{pager} .= " $_"; + } + } print $OUT "save-config, and restart the program for change to take effect.\n"; } else { -- cgit v1.2.3