tkterm is a terminal emulator similar to xterm except that it can be used inside of a Tk script. Unlike a true xterm, you can query the tkterm to see what's on it and you can update the display manually if desired. tkterm is implemented by some clever Expect scripting that uses a pty and a Tk text widget to achieve fast and accurate terminal emulation.
Tkterm supports vi, emacs, and other character-graphic programs built using curses, termcap, or terminfo. (Tkterm also support non-character graphic programs so you run your shell in it and switch back and forth between smart and dumb modes.) Tkterm's most recent enhancement is to automatically provide scrollbars while in 'dumb' mode [L1 ].
tkterm can be found in the example directory of the Expect distribution: http://expect.nist.gov although the distributed version is a bit rickety; a fixed and extended version and a working version of virterm, which does the same but doesn't require X, can be found in https://github.com/martinwguy/xvi/blob/2.50/test/scripts
NEM 18May2003 - Just tried tkterm for the first time. When I run vi (which is aliased to Vim), I get a message about "unknown terminal: defaulting to ANSI" and then vi just hangs. Any ideas how to fix this?
escargo - What environment are you running in? If you are running in a UNIX-like environment, what is the value of your TERM environment variable?
Does Tkterm support "answer back" strings? In the "old days" systems connected to terminals would determine the terminal type based on the results of a query string sent to the terminal. I don't know if that is still true or not, but Tkterm behavior in that regard would be worth knowing.
Martinwguy: No.
NEM - Environment:
$ uname -a Linux latimer 2.4.19-4GB #1 Mon Oct 14 22:11:39 UTC 2002 i686 unknown $ echo $TERM xterm
No idea what tkterm supports in terms of functionality, or how it works at all. Just thought it would be neat to have Vim running in a Tk window ;)
NEM - Update. My problem has been fixed now. Search google groups archive of c.l.t. for a post by Don Libes (in a thread called "looking for tkterm + scrollbars (pterm, maybe?)" which contains updated code. The problem was with something not liking the terminal name "tt", as it is too short. Don changed it to "tkterm" and now it works ok.
Bruce Stephens updated it to his "Pterm".
dther - 2024-04-26 15:30:53
I'm working on expanding tkterm into a fully capable ANSI terminal and embeddable Tk widget, as part of a larger pet project of mine. I'm not ready to publish just yet, but I do have this major bugfix for anyone who might be having trouble getting it running.
tkterm has no mechanism for unrecognised escape codes. This means that if your shell has advanced line editing by default or your .rc contains any ANSI control sequences, tkterm will appear to hang (produce no output, but the underlying shell is still accessible).
The easy fix to this is to simply add a pattern to expect_background right at the end, for catching any ESC characters that aren't part of a valid sequence, like so:
# ... on line 486 ... } "^\x1b\\\[?1l\x1b>" { # (rmkx,ke) end keyboard-transmit mode graphicsSet 0 } "^\x1b" { # dump unrecognised codes straight to the terminal term_insert $expect_out(0,string) } }
"ESC" will be drawn to the terminal as the <= symbol, followed by any bytes that were part of the unrecognised code.