Closed vhakulinen closed 5 years ago
@vhakulinen Looks great, thanks! I’ll get working on this for sure! I think what you laid out is enough to get things going, but I’ll let you know if I run into any problems along the way. Once I get things started (hopefully later today) I’ll open a PR to track the progress.
As for handle_redraw_event
in ui.rs, should I refactor things to break up that function? It isn’t strictly necessary, but it may make things cleaner and more readable (and since we’d already be refactoring it from the event parsing refactor, it’d probably be the best time to do it).
The UI part needs to get a refactor too, but hold on it for a bit. I'll try to layout some foundation for you to work off from.
Sounds good! Just @ me once you get things laid out. It’ll be nice to get things working and refactored (and to get a cleaner codebase).
As briefly mentioned in #72 (as result of #63), our current redraw handling is (partly) incorrect. While it works mostly fine, there are situations where we might end up in incorrect screen state. The underlying problem is that we are not parsing all the arguments for each redraw event type.
My idea for a fix
Currently the parsed type looks something like this:
Where the only correct type is the
GridLine
. We need to change all the enum members to contain a vector of data, tho' in some cases it doesn't really make sense (for example,SetTitle
). But once that change is made, theprase_redraw_event
will need to wrap each match arm into a for loop. E.g., it'll go from something like this:into something like this:
As you can see, you're gonna get for loops everywhere. We could simplify this easily:
Of course, you'll need to remember to change the UI code too.
@smolck these are my ideas for refactoring of the event parsing code. Just leave a comment here if you're going to work on it. I can provide more feedback if needed, and I'm also open for other suggestions.