Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updated tkterm and virterm available

137 views
Skip to first unread message

Martin Guy

unread,
May 14, 2017, 8:09:54 PM5/14/17
to
Hi!
Over the last four months I've been working on the tkterm and virterm terminal emulators distributed in expect/example, turning them into
reusable software components that work well enough to drive the test suite
for a vi clone.
git clone git://github.com/martinwguy/xvi
cd xvi
make check

I just wondered if there is any interest in including these - a fixed tkterm,
a working virterm and a standalone term_expect - in the standard distribution.

For tkterm, the changes were:
- add missing termcap booleans :am:bs:xn: and to terminfo am,xenl
- add missing termcap strings le sf and cr and terminfo's cub1 and cud1
- add strings send by the F10 key, the arrow keys, PgUp, PgDn, Home, End,
Insert and Delete
- Bind these keys so that tkterm sends the appropriate strings
- fix a bug in clear-to-end-of-line while in standout mode (it used to clear
to the standout colour, but should clear to the background colour)j
- call "update idletasks" on every CR, not every 24th one, as this caused
random failures of a test that produces a lot of output
- make its cursor motion string index from 1 instead of 0 to be more similar
to ansi, vt100 and xterm, thereby making development easier.

In virterm instead te changes are more widespread, including
- Remove the trailing script to interrogate the Cornell Library Catalog
- It seems to be based on an older version of tkterm, so update the code
they have in common to what's in the latest tkterm.
- Fill out its feature set to match tkterm and the above changes,
except for the graphic charset, standout mode and scrollbars.

term_expect is reduced to just the code of term_expect() instead of including
a copy of tkterm and a following rogue example, so it can be used by both
tkterm and virterm and
- set the strobe when the cursor position changes, otherwise you can't
match tests that only move the cursor but don't change the screen contents
- fixes a bug in its error reporting


I also have a couple of technical questions, as I'm new to Tcl

With tkterm, I've tried to bind the Insert key using
bind $term <Insert> {exp_send -i $term_spawn_id "\033\[2~"}
but if I press the Insert key in the terminal window, the text in X's
mouse-driven copy-paste buffer (what you get by click-dragging in a text
window) is scribbled onto the terminal's screen at the cursor position but
no characters are sent to vi. The same happens if I click the left mouse
button in the terminal window, pasting the mouse buffer at the position I click. This seems to be a predefined behaviour of the text widget but I can't find any mention of it in the docs for Tk's "text" builtin. Is there a way
to turn this off so that pressing Insert makes it send the control sequence
to the application running in the terminal?

I've had to comment out the new window-resizing code in development because
scan [wm geometry .] "%dx%d" rows cols
throws an error window on startup saying:
variable is not assigned by any conversion specifiers
while executing
"scan [wm geometry .] "??x??" rows cols"
I'm not sure where those ??'s came from! However, if I open tclsh and say
package require Tk
scan [wm geometry .] "%dx%d" rows cols
it works. That's using Tcl8.6 on current Debian and Ubuntu on i386 and amd64.
It looks like the format string is getting corrupted in the interpreter
before it is handed to "scan". Is this a known bug?

Many thanks & enjoy!

M

Dave

unread,
May 14, 2017, 8:35:54 PM5/14/17
to
On 5/14/2017 7:09 PM, Martin Guy wrote:
> "scan [wm geometry .] "??x??" rows cols"
> I'm not sure where those ??'s came from! However, if I open tclsh and say

I'd guess that the script is a bind script and the %d is being
substituted there. Try scan [wm geometry .] %%dx%%d rows cols

--
computerjock AT mail DOT com

Colin Macleod

unread,
May 15, 2017, 8:55:59 AM5/15/17
to
On Monday, 15 May 2017 01:09:54 UTC+1, Martin Guy wrote:
> With tkterm, I've tried to bind the Insert key using
> bind $term <Insert> {exp_send -i $term_spawn_id "\033\[2~"}
> but if I press the Insert key in the terminal window, the text in X's
> mouse-driven copy-paste buffer (what you get by click-dragging in a text
> window) is scribbled onto the terminal's screen at the cursor position but

You probably need to add a "break" at the end of your binding script for the insert key, i.e.
bind $term <Insert> {exp_send -i $term_spawn_id "\033\[2~"; break}
This will cause it to skip any other predefined behaviour bound to this key.

What you are doing sounds like a useful piece of work to me :-)

Keith Nash

unread,
May 19, 2017, 2:50:32 PM5/19/17
to
Hi Martin,

These terminal emulators are very useful contributions. If they are not
included in the "core" distribution, they would be excellent additions to
the tklib collection.

I agree with the suggestions made by Colin and Dave. The bindtag "Text" has
an archaic binding to the <Insert> key, and it is best to suppress it with a
"break".

You can see the bindtags that respond to events on .t by typing:
bindtags .t
with the result
.t Text . all

The bindtag Text has the majority of the bindings that affect a text widget.
In a typical Tcl/Tk installation, these bindings are defined in the file
"lib/tk8.6/text.tcl". Mostly they do what you expect a terminal to do, but
the <Insert> binding is an exception.

Keith Nash.
0 new messages