This is a tiny Gopher client written in RETRO. It's only for the iOS implementation, but could be adapted for others with a little reworking of the file I/O code.
It's intentionally kept minimal, handling only text files and directories. The interface is line oriented.
# General Configuration
`GOPHER-DATA` is the name of the file to store the last downloaded content into.
`WrapPoint` holds the number of characters to display before wrapping output.
There is also a `Results` variable which will point to the data set being displayed.
~~~
'GopherData.txt 'GOPHER-DATA s:const
#34 'WrapPoint var<n>
'Results var
~~~
# Download Data
Specify a server, a port number, and the initial seletor to fetch.
~~~
:grab (sns-)
s:empty 'abcd 'ddabc reorder gopher:get
drop GOPHER-DATA file:spew ;
~~~
# Indexes
An output line will have a format like this:
1234: TXT About this server
1235: DIR Archive
1236: This is an information line or
unknown type
I define a variable `Displayed` to track how
many characters have been displayed so far.
~~~
{{
'Displayed var
~~~
A `wrap` word handles wrapping and indenting lines based on the `Displayed` characters and the global `WrapPoint`.
I define a `line` word to display the line number. This lets me pad the number with a leading number of spaces and have a colon and space following it.
I now define a custom version of `s:put` that will call the `wrap` word defined earlier. I've not used `s:for-each` here as this will be called frequently, so it's a little faster to have a manually constructed loop here.