diff options
-rwxr-xr-x | gmi.pl | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -9,7 +9,7 @@ use bytes; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v0.0.11'; +our $VERSION = 'v0.0.12'; # TODO: # back() only works once; should fix this @@ -95,12 +95,11 @@ my %modes = my $flag; $flag=TUI_Run("gc",\%modes); -#print "*** ABORT ***\n" if ($flag); +print "*** ABORT ***\n" if ($flag); #TUI_Script(\%modes,"/config pager;"); sub url { - # gemini://website.com/request-path.gmi my ($url) = @_; if (!$url) { TUI_Out("Example: [gemini://]capsule.com/\n"); return 0;} if ( $url !~ m|^.*://.*|) { @@ -118,7 +117,7 @@ sub url { # when gemini removes TLSv1_2 as a supported version SSL_version => 'TLSv1_2', - ); #or die "error=$!, ssl_error=$SSL_ERROR"; + ); if ($cl) { my $path; @@ -158,7 +157,6 @@ sub url { sub get_links { undef(@links); my ($doc) = @_; - #map(push(@links, $_), $doc =~ m/^=>[\s]*([\w\-\\\/\.\:\~\?\=]+)[\s]*(.+)?$/gm); for my $line (split('\n', $doc)) { if ($line =~ m/^=>[\s]*([\w\d\-\\\/\.\:\~\?\=\#]+)[\s]*(.+)?$/gm) { if ($2) { @@ -176,8 +174,7 @@ sub hist { my $hist; my $counter = 1; for my $item (@history) { - $hist .= "[$counter] $$item[0] $$item[1]\n"; - #$hist .= "$$item[1][0]\n"; + $hist .= "[$counter] ". colored("$$item[0]", 'underline') ." $$item[1]\n"; $counter++; } if ($hist) { @@ -218,22 +215,26 @@ sub nav { # Setting 0: from links # Setting 1: from history my ($setting,$n) = @_; - if (! $n) { + ### $n + ### $setting + ### @_ + if (! $n or $n !~ /\d+/) { TUI_Out("Try 'links' or 'hist' then 'nav x', where x is the number.\n"); return 1; } $n -= 1; - ### $n - ### $setting - ### @_ my $link; - if ($setting == 0) { + if ($setting == 0 and @links) { $link = $links[$n][0]; - } elsif ($setting == 1) { + } elsif ($setting == 1 and @history) { $link = $history[$n][0]; } + else { + TUI_Out("'$n' isn't available.\n"); + return 1; + } # This implies it is valid if (has_scheme($link)) { @@ -264,7 +265,6 @@ sub nav { } sub has_scheme { - #print ($_[0]); return ($_[0] =~ m|^.*(://)|); } @@ -278,7 +278,6 @@ sub back { ### @_ ### $display - # my $dok_out = $doc_out; $doc_out = 0 if ($display == 1); |