Added Go Home functionality, revised the status bar to give request status, and moved the current url to be reported in the window (tab) title.
This commit is contained in:
parent
aa985bdddf
commit
745ac8605a
@ -4,9 +4,9 @@
|
||||
# This program uses telnet instead of nc to make nex requests, because I couldn't get the Perl nc module to work right.
|
||||
|
||||
#TODO: Some branding (status popup on load?, Connex menu item?), About dialog
|
||||
#TODO: Fill out help Dialog
|
||||
#TODO: Fill out help Dialog, mention vi navigatio and search
|
||||
#TODO: Fill out About Dialog
|
||||
#Make status dialog actually useful
|
||||
#TODO:Make status dialog actually useful
|
||||
|
||||
|
||||
|
||||
@ -35,6 +35,13 @@ my $port = $PORT_DEFAULT;
|
||||
my $pathspec = $PATHSPEC_DEFAULT;
|
||||
my $docname; # = "";
|
||||
|
||||
|
||||
#new status bar purpose, tracking state
|
||||
my $S_REQUESTING = "Requesting...";
|
||||
my $S_READY= " Ready";
|
||||
my $S_DIDNT= "(page not requested) " . $S_READY;
|
||||
my $S_NORESPONSE ="(No Response) " . $S_READY;
|
||||
|
||||
#for future use, when you think you can deal with doc types
|
||||
my $doctype = "txt";
|
||||
my $dot_ext = ".";
|
||||
@ -56,6 +63,7 @@ if (defined $full_url){
|
||||
die "Need a $SCHEME_NEX url, or start without supplying URL argument.\n";
|
||||
}
|
||||
$full_url= $uri->as_string;
|
||||
$HOME_URL = $full_url; #TODO make sure you want to do this, mostly go home and other defaults will go here instead o nightfall.city
|
||||
}else{
|
||||
$full_url = $HOME_URL;
|
||||
}
|
||||
@ -80,7 +88,8 @@ my @menu = (
|
||||
{ -label => 'Choose Link >', -value => \&goto_link_dialog },
|
||||
{ -label => 'Back ^B/<', -value => \&goto_back },
|
||||
{ -label => 'Go to Link ^G', -value => \&navigate_link_dialog },
|
||||
{ -label => 'Page Links ^P', -value => \&page_links_dialog },
|
||||
{ -label => 'Go Home ^M', -value => \&goto_home },
|
||||
{ -label => 'Page Links ^P', -value => \&page_links_dialog },
|
||||
{ -label => 'History ^Y', -value => \&history_status_dialog },
|
||||
{ -label => 'Exit ^Q', -value => \&exit_dialog }
|
||||
]
|
||||
@ -141,7 +150,6 @@ sub navigate_link_dialog()
|
||||
#if not user canceled then navigate
|
||||
if($return){
|
||||
navigate($return);
|
||||
update_status_bar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +162,8 @@ sub goto_link_dialog()
|
||||
if($return){
|
||||
my $linkcount = scalar @page_links;
|
||||
if($return <= $linkcount && $return >0){
|
||||
update_status($S_REQUESTING);
|
||||
goto_link($return);
|
||||
update_status_bar();
|
||||
}else{
|
||||
#$browser->focus();
|
||||
my $return1 = $cui->status("there is no link # " . $return);
|
||||
@ -174,14 +182,28 @@ sub goto_back()
|
||||
my $fetched = fetch_history();
|
||||
#if($fetched) {
|
||||
$full_url =$fetched;
|
||||
update_status($S_REQUESTING);
|
||||
load($full_url,0); #don't move back to top
|
||||
update_status_bar();
|
||||
history_status_dialog();
|
||||
#}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#let's consider home to be the first item in the history
|
||||
sub goto_home()
|
||||
{
|
||||
if(@history) {
|
||||
$full_url = $history[0]; #peek at first item
|
||||
}else{
|
||||
$full_url=$HOME_URL;
|
||||
}
|
||||
update_status($S_REQUESTING);
|
||||
load($full_url,0); #don't move back to top
|
||||
history_status_dialog();
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub goto_link{
|
||||
my $linknum = shift;
|
||||
@ -205,23 +227,37 @@ sub navigate{
|
||||
my $link = shift;
|
||||
add_history($full_url); #add last link to history before going forward!
|
||||
$full_url = $link;
|
||||
update_status($S_REQUESTING);
|
||||
load($full_url, 1); #new URL go to top of page
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub update_status_bar
|
||||
{
|
||||
my $status = shift;
|
||||
my $browser = $win1->getobj("browser");
|
||||
my $statusbar = $win1->getobj("status");
|
||||
#$full_url = construct_valid_url($SCHEME_NEX, $host, $pathspec, $docname);
|
||||
$statusbar->text("$full_url" . " | Press '>' key to enter link #. ctl-x for Menu. '<' to go back.");
|
||||
$statusbar->text($status . " | Press '>' key to enter link #. ctl-x for Menu. '<' to go back.");
|
||||
$statusbar->draw();
|
||||
$browser->focus();
|
||||
|
||||
}
|
||||
|
||||
sub update_browser_tab
|
||||
{
|
||||
my $browser = $win1->getobj("browser");
|
||||
$browser->title("$full_url");
|
||||
$browser->draw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub update_status
|
||||
{
|
||||
my $status = shift;
|
||||
update_status_bar($status);
|
||||
update_browser_tab();
|
||||
}
|
||||
|
||||
sub add_history
|
||||
{
|
||||
@ -367,6 +403,7 @@ $cui->set_binding( \&navigate_link_dialog , "\cG");
|
||||
$cui->set_binding( \&goto_back , "\cB");
|
||||
$cui->set_binding( \&goto_back , "<");
|
||||
$cui->set_binding( \&goto_link_dialog , ">");
|
||||
$cui->set_binding( \&goto_home , "\cM");
|
||||
$cui->set_binding( \&page_links_dialog , "\cP");
|
||||
$cui->set_binding( \&history_status_dialog , "\cY");
|
||||
$cui->set_binding( \&help_dialog , "\cH");
|
||||
@ -442,6 +479,9 @@ sub load
|
||||
my $top = shift;
|
||||
#my $scheme, $host, $path, $query, $frag;
|
||||
my ($scheme, $host, $path, $query, $frag) = uri_split($url);
|
||||
|
||||
|
||||
|
||||
#what happens with different scheme?
|
||||
if ($scheme eq $SCHEME_NEX){
|
||||
#A lot of trial and error here, connect->print of path was somehow important to get output to complete...
|
||||
@ -476,6 +516,12 @@ sub load
|
||||
if ($top){
|
||||
$widget->pos(0);
|
||||
}
|
||||
if ($page_contents eq ''){
|
||||
update_status($S_NORESPONSE);
|
||||
}else{
|
||||
update_status($S_READY);
|
||||
}
|
||||
|
||||
}else{
|
||||
#can't load non-nex as of now
|
||||
my $browser = $win1->getobj("browser");
|
||||
@ -484,6 +530,7 @@ sub load
|
||||
#pop and revert to history for display
|
||||
#my $fetched = fetch_history();
|
||||
$full_url = fetch_history();
|
||||
update_status($S_DIDNT);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user