diff options
author | jake <jake@jakes-mail.top> | 2022-02-01 22:11:23 -0500 |
---|---|---|
committer | jake <jake@jakes-mail.top> | 2022-02-01 22:11:23 -0500 |
commit | 0410446c5b540a12251f71c8d3f0c6affcedd0b9 (patch) | |
tree | 34d4da0d17839637782c8dea539cf20c61b4219f | |
parent | 166c2f0affcdf05bcef25f833ed27c77294886ab (diff) |
back() will load the cached paged. it only caches once (useful for slow search engine)
-rwxr-xr-x | gmi.pl | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -26,10 +26,7 @@ use warnings; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v1.0.0'; - -# TODO: -# back() only works once; should fix this +our $VERSION = 'v1.0.1'; # Modules use IO::Socket::SSL; # CPAN @@ -96,6 +93,7 @@ if (! -e $xdg_cache) { ### $xdg_config ### $xdg_data ### $xdg_cache +my @cache; load_config(); my $wrapper = Text::Wrapper->new(columns=>$config{textwrap}, body_start=>''); @@ -142,7 +140,7 @@ my %commands = ( 'hist' => [sub { hist() }, 'Returns history.' ], 'h' => [sub { hist() }, 'Alias of `hist\'.' ], - 'back' => [sub { back(0) }, 'Go back in history.' ], + 'back' => [sub { back(0) }, 'Go back in history, once. The previously accessed URI is cached.' ], 'b' => [sub { back(0) }, 'Alias of `back\'.' ], 'backnodisplay' => [sub { back(1) }, 'Go back in history but do not display the page' . @@ -306,6 +304,9 @@ sub url { ### $current_url ### $url + if (@doc) { + @cache = @doc; + } undef(@doc); if (peer_cert($cl, $url->{host})) { @@ -823,7 +824,17 @@ sub back { $config{doc_out} = 0 if ($display == 1); if (@history >= 2) { - url("$history[-2][0]"); + $current_url="$history[-2][0]"; + if (@cache) { + my @array = @doc; + @doc = @cache; + @cache = @array; + display(); + } + else { + # when the user just started the program and types 'back' and has history + url("$history[-2][0]"); + } } else { print $OUT "No such history there."; |