CSL-1.12 and CamlTK4, text tag problem

Mark C. Chu-Carroll (carroll@louie.udel.edu)
Mon, 04 Dec 1995 14:40:28 -0500

To: caml-list@pauillac.inria.fr
Subject: CSL-1.12 and CamlTK4, text tag problem
From: "Mark C. Chu-Carroll" <carroll@louie.udel.edu>
Date: Mon, 04 Dec 1995 14:40:28 -0500

Greetings!

I'm working on a TK based text editor/user environment loosely based on
Rob Pike's Acme for Plan9. For some details of how some of the more advanced
features are going to work, CSLs functors are probably going to turn out to
be extremely useful. So when CSL-1.11 came out, I eagerly grabbed it, and
compiled it with Camltk4 libraries that came with the MMM source distribution.

It seems to be working pretty well, with one minor (frustrating) exception.
One very important feature of Acme is the sweeping of text with the middle
and right mouse buttons. To do this, I have an action associated with
mouse motion events which inserts the swept text into a tag, and then
tries to highlight the tag.

After a lot of hacking, what I seem to have found is that tags are not
being created correctly by Text.tag_add. The following code fragment
demonstrates the problem:

Text.tag_add textwin "command" t1 t2;
let str = Text.get textwin (TextIndex(TagFirst("command"), []))
(TextIndex(TagLast("command"), []))
in print_string str

In this fragment, "textwin" is a text window, and t1 and t2 are valid
text indices. The indices are definitely not a problem; "Text.get
textwin t1 t2" works correctly. But when the above code fragment is
run, it produces "Fatal error: uncaught exception TkError".

"Text.tag_allnames textwin" returns a list containing the "command" tag,
so the tag is being created somehow. But any attempt to try to access
the tag, or to use any index created from the tag, causes an
exception.

I took a quick look at the CamlTK4 source to see if I could figure out
the problem. Unfortunately, I haven't been able to find anything
obvious, and I won't have the time to figure it out for a while. Can
anyone give me a clue of how to get this to work? I'd really hate to
have to migrate back to itcl!

<MC>