Since few weeks, I have been working on terminology, a terminal emulator written with the Enlightenment Foundation Libraries.

I’ve specialized myself on tracking compatibility bugs: since we wrote our own pty escape codes parser/handler, some bugs slipped into the code and some applications are not working like on that good old xterm.

Terminology tries to mimic xterm as best as it can, hence $TERM is defined to xterm.

I was told that emacs (Disclaimer: I’m a proud vim user) wasn’t working correctly in terminology. When I launched it, the menu and the status bar were underlined. I couldn’t figure an issue with the underline code. Emacs was querying the device id but I thought already fixed that issue some time ago when I made vim work well in terminology.

On Sunday evening, I decided to write a pty proxy to know what was going on between emacs and xterm and try to understand why emacs wasn’t giving his love to terminology. (No, I won’t talk about emacs virgins.)

The code itself is simple: use forkpty() and when the child (emacs in our case) outputs something through the master file descriptor, write it back to the parent stdout. When there is something to read from the parent stdin, write it back to the child stdin through the master file descriptor. I used poll to do that since it was easy enough for my needs.

On Monday evening the code was working fine and I got 2 files: in.log and out.log. Just ran ptyproxy emacs -nw and enter ^X^C in xterm. Backup the 2 files. Repeat the action in terminology.

The in.log files were different:

0000000: 1b5b 3e30 3b32 3731 3b30 6318 03         .[>0;271;0c..
0000000: 1b5b 3e34 313b 3238 353b 3063 1803       .[>41;285;0c..

The device id is different. The second number (271 or 285) is xterm’s version. The first number denotes the terminal type as expressed below:

Terminology was telling the world it was a VT100 while xterm acts as VT420.

I’ve committed a one-liner to act as xterm in revision 83047 and now emacs users should enjoy running their favorite text editor in terminology as much as the vim users already does.

I’ve pushed ptyproxy to github.

If there are still some compatibility issues, please ping me on irc or open a bug report on our trac.