I spent the late morning getting my python virtual environments configured a bit better (gah, another tool to remember to use all the time, but in the long run it will help me keep python libraries organized).
I then played around for a while with blessed, a library that abstracts away the system terminal calls I had started to dig into. The nice thing about using libraries is that they have implemented (and tested) the ugly looking stuff. The frustrating thing is that it takes a fair bit of poking around to actually use the features that they’ve so kindly made available.
In this case, I needed to get backspace to delete content. At first, I could get the terminal to write letters, but I couldn’t figure out how to use the clear and move functions that the docs described! The missing link, which Tom filled in for me, was that attributes like terminal.clear_bol
(clear to the beginning of the line) and terminal.move_left
(move one space left) need to go inside calls to terminal.write()
. They aren’t functions of the terminal itself, they’re attributes telling the terminal how to write content to the screen. Curiously, blessed doesn’t have a ‘clear one letter’ attribute, so my implementation of backspace is:
terminal.write(terminal.move_left + ' ' + terminal.move_left
).
After that, I got my history feature working pretty quickly. And what a RUSH when it worked for the first time! I was sitting in the library with the RC crafternoon folks weaving together all the bits I had learned this week. I started up the shell, ran a few commands, and when I pressed the <UP>
key, it magically filled in the previous command! (I wrote the code, so I know it’s not magic, but it felt quite magical to have a feature I worked on for so long finally work).
I could definitely add features to my shell, and it probably has some bugs, but it’s time to let this project sit for a bit. I’m hoping to build the server I started a month ago into a full-fledged web framework and do some machine learning stuff for the next few weeks. Feel free to comment/play with my shell - you can download the code from github!
Things I learned over the weekend:
- Having someone around who has used a library is really helpful for getting to the bottom of non-intuitive API features (thanks for the millionth time, Tom…).
- Seeing old friends and family is good for the soul. Really really good.
- Adele Bloch-Bauer (the famous woman in gold of the Klimt painting) and her husband hyphenated their names in 1907 or thereabouts! How progressive! Vienna at the turn of the 20th century was a fascinating place, filled with artists and writers, who gathered in salons to discuss philosophy, art and the like. I sometimes wonder what the world would have been like had the Nazis not decimated Europe (While many of the people who attended these salons managed to escape before the war, the world they created was destroyed).
- It is possible to make an interactive museum appealing to adults. Haven’t you always wanted to use a digital pen to save images of your favorite things from a museum onto an pinterest-like board? Draw your own wallpaper and project it onto the walls of a room? Spin in a symmetrical round plastic chair designed by famous architects? All of these things are possible at the Cooper-Hewitt museum.