@ -78,7 +78,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
------------------------ )
: gopher.help ( _ -- _ :: Prints a helpful message about using the gopher module )
"gopher\n------\n\ngopher.visit\tNavigate to a host/resource; will query for info; no stack effects\ngopher.follow\tEats top of stack as the link to follow and navigates to that link\ngopher.back\tGo back a page, up to three levels; no stack effects\ngopher.reload\treloads the current page; no stack effects\ngopher.url?\tEats top of stack as the link to print the url information for\ngopher.favs-path\tSet this string var to a local path that leads to a gophermap to use for favorites\ngopher.fav\tEats top of stack as the link id to store as a favorite; must have set gopher.favs-path\ngopher.favs\tNavigates to the file set by gopher.favs-path, which must be set; no stack effects"
"gopher\n------\n\ngopher.visit\tNavigate to a host/resource; will query for info; no stack effects\ngopher.follow\tEats top of stack as the link to follow and navigates to that link\ngopher.back\tGo back a page, up to three levels; no stack effects\ngopher.reload\treloads the current page; no stack effects\ngopher.url?\tEats top of stack as the link to print the url information for\ngopher.favs-path\tSet this string var to a local path that leads to a gophermap to use for favorites\ngopher.fav\tEats top of stack as the link id to store as a favorite; must have set gopher.favs-path\ngopher.favs\tNavigates to the file set by gopher.favs-path, which must be set; no stack effects"
str.print-buf
;
@ -96,7 +96,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
: gopher.follow ( link-num -- _ :: Follows a link with the given link number )
depth 1 < if
"must have a link number on TOS for gopher.follow" error
"must have a link number on TOS for gopher.follow" error
then
dup gopher.private.links @ ++ < if
gopher.host:port @ num.positive? if
@ -105,7 +105,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
gopher.private.get-link-address
gopher.private.request-and-parse
else
"Invalid link ID" error
"Invalid link ID" error
then
gopher.private.print-separator
;
@ -116,7 +116,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
: gopher.private.add-to-history ( _ -- _ :: Adds a new url to history )
@ -233,21 +233,21 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
gopher.private.page set-string
else
tcp.close
"Could not read from resource" error
"Could not read from resource" error
then
else
tcp.close
"Writing resource to host failed" error
"Writing resource to host failed" error
then
else
"Unable to connect to requested host:port" error
"Unable to connect to requested host:port" error
then
;
: gopher.private.input-host:port ( _ -- _ :: Requests the host and port from the user and stores it in the gopher.host:port variable )
"\e[1mhost:port $\_\e[0m" str.print-buf ( Print the query )
"\e[1mhost:port $\_\e[0m" str.print-buf ( Print the query )
input str.buf-addr @ num.zero? if
"empty host/port" error
"empty host/port" error
then
gopher.host:port set-string
gopher.private.add-default-port
@ -263,9 +263,9 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
;
: gopher.private.input-resource ( _ -- _ :: Requests the resource from the user and stores it in the gopher.resource variable, adding a newline to the end for use in sending the request )
"\e[1mresource \_$\_\e[0m" str.print-buf
"\e[1mresource \_$\_\e[0m" str.print-buf
input str.buf-addr @ num.zero? if
"/"
"/"
then
`\r str.buf-addr str.append-char
`\n str.buf-addr str.append-char
@ -304,7 +304,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar
: gopher.private.parse-map ( _ -- _ :: Initiates parsing of gophermaps and intiates link building and text output )
gopher.private.page @ 1 < if
"No page data to display" error
"No page data to display" error
then
1 gopher.private.line-offset ! ( Set to the beginning )
0 gopher.private.links ! ( Reset the link count to zero )
@ -354,7 +354,7 @@ var gopher.favs-path 100 allot ( a string representing a local path to a bookmar