many changes from Alpha #1

Merged
peteyboy merged 7 commits from uris into develop 2024-06-24 20:21:34 -04:00
Showing only changes of commit a7acb6501e - Show all commits

View File

@ -16,8 +16,6 @@ my $PATHSPEC_DEFAULT = '';
my $PORT_DEFAULT = 1900; my $PORT_DEFAULT = 1900;
my $SCHEME_NEX = "nex"; my $SCHEME_NEX = "nex";
my $home_default= $SCHEME_NEX . $HOST_DEFAULT;
my $host = "nightfall.city"; my $host = "nightfall.city";
my $port = "1900"; my $port = "1900";
my $pathspec = ""; my $pathspec = "";
@ -28,7 +26,17 @@ my $dot_ext = ".";
my $HOME_URL = uri_join($SCHEME_NEX,$HOST_DEFAULT); my $HOME_URL = uri_join($SCHEME_NEX,$HOST_DEFAULT);
my $full_url = $HOME_URL; #if argument entered, it should be a nex url:
my $full_url= $ARGV[0];
if (defined $full_url){
my $uri=URI->new($full_url, $SCHEME_NEX);
if ($uri->scheme ne $SCHEME_NEX){
die "need a $SCHEME_NEX url, or start without supplying URL argument.\n";
}
$full_url= $uri->as_string;
}else{
$full_url = $HOME_URL;
}
my @history; my @history;
my @page_links; my @page_links;
@ -42,14 +50,20 @@ my $connect = new Net::Telnet (Timeout => 10,
my @menu = ( my @menu = (
{ -label => 'File', { -label => 'File',
-submenu => [ -submenu => [
{ -label => 'Go to Link ^G', -value => \&navigate_link_dialog },
{ -label => 'Choose Link >', -value => \&goto_link_dialog }, { -label => 'Choose Link >', -value => \&goto_link_dialog },
{ -label => 'Back ^B', -value => \&goto_back }, { -label => 'Back ^B/<', -value => \&goto_back },
{ -label => 'History ^H', -value => \&history_status_dialog }, { -label => 'Go to Link ^G', -value => \&navigate_link_dialog },
{ -label => 'Page Links ^P', -value => \&page_links_dialog }, { -label => 'Page Links ^P', -value => \&page_links_dialog },
{ -label => 'History ^Y', -value => \&history_status_dialog },
{ -label => 'Exit ^Q', -value => \&exit_dialog } { -label => 'Exit ^Q', -value => \&exit_dialog }
] ]
}, },
{ -label => 'Help',
-submenu => [
{ -label => 'Help ^H', -value => \&help_dialog },
{ -label => 'About ', -value => \&about_dialog },
]
},
); );
@ -170,7 +184,7 @@ sub update_status_bar
my $browser = $win1->getobj("browser"); my $browser = $win1->getobj("browser");
my $statusbar = $win1->getobj("status"); my $statusbar = $win1->getobj("status");
#$full_url = construct_valid_url($SCHEME_NEX, $host, $pathspec, $docname); #$full_url = construct_valid_url($SCHEME_NEX, $host, $pathspec, $docname);
$statusbar->text("$full_url" . " | Press '>' key to enter link #. ctl-g to enter nex URL. '<' to go back."); $statusbar->text("$full_url" . " | Press '>' key to enter link #. ctl-x for Menu. '<' to go back.");
$statusbar->draw(); $statusbar->draw();
$browser->focus(); $browser->focus();
@ -238,7 +252,34 @@ sub page_links_list
} }
} }
sub about_dialog
{
my $browser = $win1->getobj("browser");
$browser->focus();
my $return = $cui->status("Connex browser\n by gorf\@rawtext.club\n 2024");
}
sub help_dialog
{
my $browser = $win1->getobj("browser");
$browser->focus();
my $message = <<'END_MESSAGE';
Navigation:
Press '>' key to select a '[>#]link by #
Press '<' key to go back to previous page
Program Features:
Press ctl-x for menu
END_MESSAGE
my $return = $cui->dialog(
-message => $message,
-title => "Connex Help",
-buttons => ['ok'],
);
}
my $menu = $cui->add( my $menu = $cui->add(
'menu','Menubar', 'menu','Menubar',
@ -249,6 +290,7 @@ my $menu = $cui->add(
$win1 = $cui->add( $win1 = $cui->add(
'win1', 'Window', 'win1', 'Window',
-title => "Connex, a Nightfall Express (nex://) browser",
-border => 1, -border => 1,
-y => 1, -y => 1,
-bfg => 'red', -bfg => 'red',
@ -280,12 +322,10 @@ $statusbar = $win1->add("status", "TextViewer",
-width => -1, -width => -1,
-reverse => 1, -reverse => 1,
-paddingspaces => 1, -paddingspaces => 1,
-text => "$HOME_URL | Press '>' key to enter link #. ctl-g to enter nex URL. '<' to go back.", -text => "$full_url | Press '>' key to enter link #; ctl-x for menu; '<' to go back.",
); );
#key bindings, should match menu items #key bindings, should match menu items
$cui->set_binding(sub {$menu->focus()}, "\cX"); $cui->set_binding(sub {$menu->focus()}, "\cX");
$cui->set_binding( \&exit_dialog , "\cQ"); $cui->set_binding( \&exit_dialog , "\cQ");
@ -293,6 +333,9 @@ $cui->set_binding( \&navigate_link_dialog , "\cG");
$cui->set_binding( \&goto_back , "\cB"); $cui->set_binding( \&goto_back , "\cB");
$cui->set_binding( \&goto_back , "<"); $cui->set_binding( \&goto_back , "<");
$cui->set_binding( \&goto_link_dialog , ">"); $cui->set_binding( \&goto_link_dialog , ">");
$cui->set_binding( \&page_links_dialog , "\cP");
$cui->set_binding( \&history_status_dialog , "\cY");
$cui->set_binding( \&help_dialog , "\cH");
$cui->set_binding(sub { $cui->set_binding(sub {
my $cui = shift; my $cui = shift;
$cui->layout; $cui->layout;
@ -304,12 +347,12 @@ $cui->set_binding(sub {
# There is no need for the editor widget to loose focus, so # There is no need for the editor widget to loose focus, so
# the "loose-focus" binding is disabled here. This also enables the # the "loose-focus" binding is disabled here. This also enables the
# use of the "TAB" key in the editor, which is nice to have. # use of the "TAB" key in the editor, which is nice to have.
$texteditor->clear_binding('loose-focus'); #$texteditor->clear_binding('loose-focus');
#start up #start up
#$texteditor->focus(); $texteditor->focus();
navigate($HOME_URL); navigate($full_url);
$cui->mainloop(); $cui->mainloop();