Skip to content

Refactor data flow and terminal library#117

Merged
hannesm merged 72 commits intomasterfrom
notty
Feb 7, 2016
Merged

Refactor data flow and terminal library#117
hannesm merged 72 commits intomasterfrom
notty

Conversation

@hannesm
Copy link
Owner

@hannesm hannesm commented Feb 6, 2016

The data flow design was slightly broken, a global Cli_state.state was passed around and mutated, by both user input, the rendering loop, and network input. Error handling was done at the beginning of the rendering loop. Also, by using (outdated) Lambda_term/Zed/Camomile libraries, the width of unicode characters (can be 2 columns) lead to UI problems (motivated by 茶 as status line, initially reported by @mirko).

Now, there is a rewrite: the main loop renders the state, receives a state -> state Lwt.t function from a Lwt_mvar, and continues (unless quit was executed).

Terminal input handling is done in a separate task (to have SMP question support, where both a question and a shared secret needs to be entered, another Lwt_mvar is used (plus a global bool ref, bad bad bad).

Commands, navigation, also network input puts something into the state -> state Lwt.t mvar. Thus, there's a single (immutable!) state (NB: the Contact.contacts still uses a Hashtbl, but should be straightforward to use a Map.t now). To comply with this design, the network interaction needed slight improvement. Error handling is now done while executing the action, and while rendering (instead of having every potentially failing network send wrapped in a try_lwt). Once a disconnect happens, a reconnect timer is started (via Lwt.async from the main loop)!

The rendering now uses the notty library, which exposes combinators for rendering text. The rendering code is hugely improved (and much more readable), additionally, there is no need anymore to compute width and height manually.

There might be some regression (such as certain key bindings do not work, C-, C-, mark/yank/paste, undo/redo), also smart line wrapping (find whitespace within the last 10 chars) is not implemented yet.

@hannesm
Copy link
Owner Author

hannesm commented Feb 6, 2016

There is no longer any need for force_redraw and thus no hex characters in the lower left corner. The resulting binary is self-sufficient (no need for camomile data files) and roughly 13MB in size (on an amd64). After decrypting a message, the resulting data is validated to be UTF-8.

New features include that suggestions for commands are now rendered in lightgray (type / to see an example); the configuration dialog has been rewritten and does not exit the program anymore if invalid data is entered.

@hannesm
Copy link
Owner Author

hannesm commented Feb 7, 2016

I think this is good now... will see what reports I get in ;)

hannesm added a commit that referenced this pull request Feb 7, 2016
Refactor data flow and terminal library
@hannesm hannesm merged commit f827b1f into master Feb 7, 2016
@hannesm hannesm deleted the notty branch February 7, 2016 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants