xterm

Working with xterms

xterms can be integrated into a Tcl app in several ways:

Running under xterm control

This is the simplest case, you just run your app inside an xterm as normal. Either start the xterm and manually interact with the default shell or start xterm with the -e flag with your Tcl program as its arguments. The Tcl/Tk program will run in the xterm.

Controlling xterm remotely

A Tcl app can start up xterms after the Tcl app starts using xterm's -S flag. This really pays off when you need to control multiple xterms. Some Tcl examples:

xkibitz - an Expect script that starts multiple xterms, each of which is controlling the same shared process. Works with shells, editors or anything that can run in an xterm.

multixterm - an Expect script that starts multiple xterms, each of which is controlling a separate process. A special window is supplied allowing you to type to all xterms at the same time. We use it to ssh to a group of hosts and do ad hoc system administration where we need to see the responses dynamically.

Reparenting an xterm

TkSteal TkXext


GPS Apr 30 2002 - I recently sent a patch to Thomas E. Dickey (tedickey) for xterm that adds an -into flag. This new flag allows you to embed xterm into a Tk application. It may appear in the release after this (current is #166). In my own application I actually link in the xterm code by renaming xterm's main() to xterm_main(). Then before xterm enters its event loop I fork() and do "signal(SIGCHLD, SIG_IGN);". Then I added a Tcl command (xterm) that calls xterm_main. The end result is that I have an embedded xterm in a stand-alone executable. If anyone is interested I could post my patch on the Wiki.

RJ Feb 2, 2004 - Some time has passed. Has this been incorporated into xterm? By "do signal" do you mean trap? Yes GPS, I would like to see this patch.

AMG: -into is incorporated into xterm, and it works. This page needs to be updated with some examples of its use. Something along the lines of:

toplevel .xterm -container 1
exec xterm -into [scan [winfo id .xterm] %x] &

But with support for communicating geometry to xterm, if that's possible. Or if it's not, why?, and how can we fix it?

One thing I'm very interested in is writing a Tcl/Tk script that creates a full-screen window into which xterm is parented. xterm lacks a full-screen option, although a patch is available [L1 ].

I'm sure GPS meant trapping SIGCHLD. I added quotes to his comment to make this more clear.


[Nice work, GPS!]