Part of me wants to rewrite nomad because the code really is a mess.
I watched Boundaries by Gary Bernhardt again today, the video that inspired me to write my own terminal. I’ve realised the code itself has become something that is not exactly “functional core, imperative shell” and now it has a lot of tests and I’ve had a lot of experience with how programs expect terminals to handle them, I feel confident that I can extract functional pieces from the main class.
The Subterminal
class itself could also be completely
removed, I realise. It was initially quite convenient to
collect the functionality of a terminal into a single class
but a terminal is really a collection of distinct functions
that are controlled by different imperative instructions
as the user interacts with the programs being run.
For example, the cursor position of the terminal could exist separately to most functions, with other functions taking the current cursor position as input.
This would allow each function to be tested very easily, which currently cannot be done. SubTerminal does have a few tests that cover some functions of it, but these often cover multiple functions at once and so are more like integration tests.
It would be nice to test the cursor positioning function separately to the scroll margins function.