[−][src]Crate phetch
phetch is a terminal Gopher client designed to help you quickly navigate the Gophersphere securely. It includes support for browsing via TLS or Tor proxy, but can also be used the old fashioned way. The menu-based interface is driven entirely by your keyboard, and emphasis has been put on swiftness of navigation. Both "jump to link" and incremental search options are available.
We don't use any ncurses-style library for drawing but instead do
it manually, mainly in UI
. This is the application class that
prints to the screen and manages the loaded Gopher "views".
Meanwhile, the bulk of the menu system, responding to user
input, and rendering of the colored interface itself takes place
in the Menu
view. The two work hand-in-hand.
This crate includes its own Gopher parsing and fetching library, which may eventually get extracted. It seems that most existing Gopher libraries in Rust allow you to parse menu lines individually into items, but phetch needs to know about the links' relationships to each other for its navigation/numbering/cursor system to work. So phetch parses all the lines in a Menu as a whole and knows which link is which.
Finally, a note on the code itself: this is not my first Rust program, but you probably wouldn't know that by looking at it! Suggestions and improvements are more than welcome.
Modules
args | args::parse() is used to parse command line arguments into a Config structure. |
bookmarks | Bookmarks are enabled if you create a ~/.config/phetch/ directory
manually. They are stored as a simple Gophermap, |
color | Terminal colors. Provides a macro to color text as well as sturcts to get their raw ansi codes. |
config | phetch will load |
gopher | phetch's Gopher library contains a few phetch-specific features: the ability to make requests or downloads over TLS or Tor, cleaning Unicode control characters from Gopher responses, and URL parsing that recognizes different protocols like telnet and IPv6 addresses. |
help | The |
history | phetch will append every URL visited to a Gophermap if a
|
menu | The Menu is a View representing a Gopher menu. It renders the colorful representation, manages the cursor and selection state, and responds to input like the UP and DOWN arrows or other key combinations. |
phetchdir | The phetchdir is |
terminal | The terminal module mostly provides terminal escape sequences for things like clearing the screen or going into alternate mode. |
text | A View representing a Gopher text entry. Responds to user input by producing an Action which is then handed to the main UI to perform. |
ui | The UI is what drives the interactive phetch application: it spawns threads to fetch Gopher pages and download binary files, it manages the opened pages (Views), it asks the focused View to respond to user input, and it performs actions based on what the View returns - like opening a telnet client, or displaying an error on the status line. |
utils | Helper functions and macros. |
Constants
BUG_URL | Where to file issues. We try to catch and display all errors nicely, but if we have to crash we will try to show this. |
BUILD_DATE | Date when this release was built. |
GIT_REF | Git SHA of current build. |
PLATFORM | Current OS. Used to check for updates. |
TLS_SUPPORT | Whether we compiled with TLS support. |
TOR_SUPPORT | Whether we compiled with Tor support. |
VERSION | Current version of phetch. |