Version 9 of terminal emulator

Updated 2004-07-30 14:58:53

[...]

[Describe rxvt and the one Don distributes with Expect.]


I've seen the expect example, and it works amazingly well. What I would like to know is whether or not it's possible to get the same effect with pure tcl/tk. The acid test would be to run vi within a tk based emulator without using the expect extension.

RJM Hm. Don't know exactly what you mean. But for the sake of this pages' title an example of an extremely simple terminal emulator follows here. You can adapt/extend it for your own purpose.

 set serial [open com1 r+]
 fconfigure $serial -mode "9600,n,8,1" -blocking 0 -buffering none -translation binary
 fileevent $serial readable {.t insert end [read $serial]}
 pack [text .t]
 bind .t <KeyPress> {puts -nonewline $serial %A; break}

The break prevents local echo of typed characters on the text widget.

'''Exactly what I mean: I want to exec vi and have its input and output managed through a tk widget. It has nothing to do with a serial communications port."


DL I think the answer to the original question may have different answers depending on whether you're on a UNIX-based platform (which would include MacOS) or a Windows platform. On UNIX, you need pseudottys, something vanilla Tcl just doesn't provide support for - except with the Expect extension. On Windows, there is no concept of pseudottys nor is there any concept of a unified mechanism for interacting with other programs. The simple script above merely opens a connection to a serial port. If your idea of a terminal emulator is to interact with a serial port, then yes you can get by with a pure Tcl script.


See also A simple serial terminal


Category Glossary