Can I somehow find the width and height of the xterm?
Assuming a bash shell, you can add these two lines to your .bashrc:
export LINES
export COLUMNS
The xterm sets those two environment variables to the window's height and width, respectively, in characters, but since the xterm being run by your Perl/Tk script is in a sub-shell, the values for that particular xterm window won't be accessible by the perl script. (You only get to see the values for the xterm shell from which the perl script was run, as $ENV{LINES}, $ENV{COLUMNS}.
You can control the xterm size on start-up by adding this option: -geometry WxH (where W and H are width and height in characters). In the code that you cited (embedding xterm into a Tk app by zentara) just add that option to the string being passed to system() at line 46.
Using "-geometry 78x23" actually improved its behavior for me; YMMV. It seems that 80x24 is the typical default xterm size, but if your font is different from the one zentara used, your display might not seem to work right.
You'll probably need to experiment for a while with font sizes for the xterm and pixel sizes for the containing widget, to get a feel for how they relate.
(BTW, check out What shortcuts can I use for linking to other information? to see the easy way to link to other nodes at the monastery. -- Update: I changed this link, because Writeup Formatting Tips isn't the direct source for info about linking.) |