[Openmcl-devel] Two quick questions

Gary Byers gb at clozure.com
Sun Nov 4 20:44:00 UTC 2007



On Sun, 4 Nov 2007, Ron Garret wrote:

> I can probably figure these out myself, but I thought I'd see if
> anyone knew the answer offhand before I spent a lot of time on this.
>
> 1.  What is the difference between marked and selected text in an
> NSTextInput object?

Some input methods require multiple key events to enter a character;
if you type "ctrl-q option-` option-e" in a Hemlock buffer on a US
keyboard, you'll see that the text is "marked" between the last two
key events and becomes complete (and the marking gets removed) after
the last of these events.

>
> 2.  Is there in the Hemlock code somewhere (or anywhere else) a
> function that, given a string and an index of a close-paren within
> that string will return the index of the corresponding open-paren?
> It's easy to write a naive version of this, not so easy to write one
> that correctly handles all Lisp syntax, including strings, escape
> characters and reader macros.

If there was, it'd probably involve:

1) creating as lightweight of a Hemlock buffer as possible.
2) initializing the buffer's contents to contain the string
3) generating (mostly-) lisp-aware annotations on the lines
in the buffer
4) calling some fairly-high-level Hemlock functions to navigate
around; at this level, that'd involve dealing with marks rather
than character positions, and moving a copy of a mark that at
the close-paren to make it point to the beginning of the list
5) determining the absolute position of the result mark

In other words: all of the lisp-aware movement (c-m-f, etc)
operates on something a few notches above the string level.
(Hemlock's parsing code gets things like strings and ;-style
comments right, but I think that it's fooled by #||#.)

>
> Thanks,
> rg
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list