A while ago I came across a terminal emulator called HATE: the High Availability Terminal Emulator. The original idea was for it to be a terminal emulator that could survive X crashing, but what caught my eye was the fact that it was written in Python. Therefore, I reasoned, it would be easy to extend.
What I’ve Done With It
Step 1: Refactoring
I got a copy of HATE from Jerub’s repository and had a look at the source code. Seeing that it was a small yet complete Python program, the first thing I decided to do with it was to use it as an example of my Pyj extension, which I wrote about recently. So I carefully refactored the code, updating Pyj as I went. After this step, my new version of HATE:
- did not construct any classes;
- was made up of a whole bunch of small files each defining one function, object or constant; and
- still did exactly the same thing as the original did.
Step 2: Terminal Stack and Colours
Inspired by the Tab Kit extension for Firefox, I added a vertical stack of terminals on the left-hand side of the window. Each entry in the stack has an icon, a title, and a letter which can be typed in the “Go” box in order to switch to that terminal. Pressing Ctrl+Shift+G will jump to the “Go” box, Ctrl+Shift+T will open a new terminal, and Ctrl+Shift+B will switch to the terminal at the bottom of the stack (least recently used). I also made each terminal have a random colour to make it easier to remember which terminal was used for what purpose.
You can get my code on launchpad here. Or if you have bazaar, you can type
bzr branch lp:~jd-bartlett/+junk/hate. To see what the project looked like after refactoring, have a look at the tag 10.4. You may wish to compare it with the 8.7 tag, which is how things were before the refactoring. The 10.5 tag is what the project looked like at time of writing. Please note though that:
- in 10.4, setup.py does not work because it picks up .py files (of which there is only one) and ignores .pyj files;
- you will need to get a copy of pyj for this to workâ€”
hg clone https://email@example.com/talljosh/pyj; and
- the 0.9 tag of Pyj works with the 10.4 tag of HATE, and the 0.9.1 tag of Pyj works with the 10.5 tag of HATE, but other combinations of revisions may not work together.
What I May Yet Do
Inspired by the MiniBufExplorer plugin for vim, and the Terminator terminal emulator, I would like to add viewports to HATE. When using Terminator, you can split the current viewport either vertically or horizontally, ending up with multiple viewports in the one window. I’d like to see this in HATE. There should also be key combinations to switch to each viewport.
And of course, the more work I do on HATE, the more fun I have with Pyj!