A small excursion back into the world of console apps
Of course, I should have just used some variation on Curses. But where would be the fun in that?
En-route to something else I worked up a simple (ha) split-screen console app, with a large upper pane for output and a smaller input pane, separated by a status line. In the end, it turned out ok:
but it was a fun process to go through; it exercises quite a few muscles on the way. I put the code, such as it is, into a repo named Old School Dot Net on GitHub.
So, as part of this whirlwind tour I was briefly ambushed by:
- Going out to Process.GetCurrentProcess().Id is a great big performance load I’d forgotten about.
- Console.ReadLine blocks, because of course it does.
- Writing a non-blocking Console.ReadLine is basically fine, until you go and do fancy things like using the delete key.
- C# doesn’t give you a custom ctrl-c handler out of the box, so it’s off to [DllImport(“Kernel32”)] for the first time in a while.
- There’s no moving-window collection in C#, not that it’s too hard to implement.
- Threading makes it more fun, as always, sending the cursor all over the place without locking.
And next? Maybe an exercise in Eliza-like AI; or an adventure game; maybe something that generates ASCII art for you; maybe a chat app; maybe a set of bots that can do each of these things …