summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-31 16:38:17 -0500
committerjake <jake@jakes-mail.top>2022-01-31 16:38:17 -0500
commit4afa0b8da16769c38050e0d3f499ed1045cad42a (patch)
treea34aa8ccabd26a349d33ef16d30c47c831918aa0
parent77c065850b6cb163e9d895360111fd93666b0b80 (diff)
loading and saving pager option fixed
-rwxr-xr-xgmi.pl27
1 files changed, 17 insertions, 10 deletions
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 <tab><tab> 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 {