Kevin C. Krinke

Business and technology consultant.

Curses!

8 minutes
November 12, 2021

It’s been a while since my last posting and I feel compelled to say some things as well as introduce everyone to my curses project.

Saying some things…

… to those whom I’ve not responded too in a while.

I have struggled my whole life with mental-illness of varying forms and degrees of symptomatic expression. I’ve thought I was bipolar, schizophrenic and/or manic depressive at various periods of my life. This past near-decade has been a ramped-up roller-coaster of traumatic levels of my problems. COVID has nothing to do with this. I’m a very private person in general and self isolation has never been a real issue.

What is an issue is how sensitive I’ve gotten about what people say to me and how easily the thought process can spiral out of control and curl up in the darkest recesses of my mind. It makes me positively crazy and I know it has nothing really to do with the person speaking to me in the moment and everything to do with what happens in my brains.

I’ve adopted a general case of monk-like silence with pretty much everyone in my life, family included. This has proven wonderful in terms of alleviating anxiety and keeping me sane as I work on this journey within. This means I’ve not been responding to calls, texts, emails or even reading social media at all unless it’s my mom or ultimately an imperative at the time.

This is not to say I don’t like you, that I don’t love you, that I don’t respect you. Not at all. This is to say that I’ve now applied an alternate approach where I’m saying that I do like me, that I do love me and that I do respect my self in addition to loving you all unconditionally. My self has been crying out in pain and swimming in stress while my mind’s I has been clinging to the “man’s man” persona and just plowing forward with brute force. Brute force proved to be a tremendous error in judgment and I implore all male-identifying people to not fall for the trap of being a “man’s man”. That world, the old world, the frat-boy status quo, all that needs to die a quiet death. Just stop it. Listen to your self, your gut, your heart, your two hemispheres and all the nervous systems holding you together - not what the bullies in life try to hammer into you.

So, without this turning into some lengthy diatribe on my mental-health practices and personal world view, I just have one thing to say to the people who may or may not feel dropped or ignored from my life: I still love you, please allow me the time to heal, without grief, and learn the lesson of why I’m still alive.

Okay, so that’s a little dark, talking all about the curse of my mental-illness and such… Let’s move on to something not so dark…

Go-Curses!

For those that know me in programming capacities, you’ll know that I’ve always been a fan of terminal user interfaces like ncurses employed by programs such as dialog and whiptail.

A long time ago I even wrote a perl module UI::Dialog to automate tasks and generally make my life and the lives of co-workers easier. I still use this library to this day, however, there are limitations and drawbacks. I can’t just design a customized UX per-application as they’re all driven by whiptail underneath.

So, I decided to make a GTK-inspired curses perl module and that died fast. I just didn’t have the steam to pour into a language that is fading in popularity with the new coders out there.

Then Go appeared in my life and I gave birth to my setlist generator project. I’ve always envisioned this ideal of having one formal UI library that works on modern desktops with GTK and seamlessly works in pure console environments where X is not present and all the widgets are entirely curses based versions of their GTK counterparts. Given that I needed to learn Go more and not get too complex, I settled on just implementing the GTK interface for the setlist project.

In the time since my last posting, I’m happy to say that I’ve actually built something entirely new that feels old. CTK. The Curses Tool Kit is not finished at all of course as this is a monumental hill to climb alone, however I’m happy to report that I finally got to a stage where I’m comfortable with publicly sharing the code. Will I support this code long-term? No idea (and yes I’m a fan of cleaning house on things I won’t maintain for others). As it stands this thing is entirely an intellectual curiosity and deep dive into writing something big in Go. So why does this new thing feel old? Because when you code up a hello world… it feels distinctly GTK-ish in respects, which to me feels old because I’m used to coding GTK (in c, perl and Go).

Go-Curses consists of two main projects. CTK and CDK which are equivalent to the GTK and GDK relationship.

Hello World

Take a look over the README files for the two main libraries in the Go-Curses project space if you’re interested in seeing actual code. For this posting, it’ll just be screenshots and words describing things instead of a line-by-line walkthrough.

CTK Example

The first and main example, is a very simple program that displays a button that when pressed will exit. See the Programming Hello World in CTK section of the CTK README file. It looks like this:

Hello World in CTK

Nothing really special in actual functionality, however, in order to display this content a whole slew of things had to be implemented. There needs to be a Window that contains everything. That Window needs to have a VBox to organize and contain things in. There needs to be an Alignment widget to center the button in the view and of course there’s the Button itself which uses a Label and various Signal handlers to do things like exit the program when the button is clicked. Read the example code in the repo for more details as I’ve basically done a line-by-line commentary of what’s happening and why.

CDK Example

The Curses Development Kit isn’t something that is intended to be used directly, however, I needed to write some examples in order to test that layer of things while developing. Necessity drives invention and nothing says necessary like making some thing to say “Hello World”.

Now, while CDK does in fact have it’s own Hello World example, that’s not the one I’d like to mention here. Rather, there’s a second example called appserver and that one’s the one I think will help demonstrate the bizzare things one can do with these kits.

The appserver works like this. Clone the CDK repo and cd into it. Then run make examples and if the stars have aligned, two binaries should have been built (helloworld and appserver).

In the current terminal session, run ./appserver and you should see something like the following screenshot displayed (and updating the timestamp every second or so, not exact but roughly close enough). This invocation is what we’ll call the “Server Side”, which is clearly labelled at the top of the screen.

appserver server-side

Now, start up a second terminal session and this time let’s login to the appserver using ssh on localhost with port 2200. There are two possible users to use: foo with password bar and bar with passwod foo.

$ ssh -p 2200 [email protected]
Password: ***

appserver client-side

Neat! If we take a look at the server-side session again we can see that there’s a client connection being reported.

appserver server-side-with-client

Ideas that go “curses!”

wg-appserver

Now, the above examples may not do much, however they are in fact clear proofs of the concept. For an example idea for an appserver based thing, an interesting one would be to write a system for managing a WireGuard VPN in a weirdly secure way.

the curses desktop

How about a little bit of insanity that may in fact be the sanest choice in some cases… an appserver that is really a curses desktop environment where each new client session is being used like a secondary monitor is used by X11, it extends the space available. This could be implemented locally via IPC or remotely via ssh connections. Add a WindowManager to CTK and now we’ve got a curses desktop.

Would anyone need this? Like for real? Sure! Why not in industrial control systems, embedded assembly line touch-screens, or any number of niche situations where the encumbrance of a full graphical environment is overkill or worse entirely cosmetic in it’s necessity for being. Using Android for such things may be a “good idea” though I suspect it’s a recipe for security issues, upgrade path problems, hardware support problems and so on.

Sometimes curses can be a good thing.

Post-Script

This wasn’t as long as I’d thought it’d be. Groovy.

Thanks for reading!

If you’re interested in Go-Curses and really do want to get my attention, twitter is probably the best, with email being the means of actually causing my notifications to notify me.