This feature can be found in the 2.0 script editor. Coincidentally,
the second alpha-test release of 2.0 has just been released, and can
be acquired via anonymous FTP from ftp.metacard.com:/MetaCard/2.0.
> The problem is that I want to run some code *after* the character has
> been put into field 2. This lets MC take care of inputting characters
> (including delete, hilighting, etc.) However, the keydown message only
> lets you run code *before* you put chars into the field. As soon as you
> do a "pass" or "send" there isn't anything else you can do. Is there
> anyway I can get a message after the char has been entered into the
> field?
>
> Any thoughts out there?
What the 2.0 script editor does is the same as what Emacs does (and is
the reverse of what you're trying to do): it just puts the text into
the field that shows the text string typed so far, and leaves the
cursor in the editing field, repositioning it as needed. In this
case, you're bypassing the normal keypress message hierarchy and so
you don't want to pass the message at all. Here's the guts of the
script, which is for the editing field (note that it uses the
new-to-2.0 "switch" keyword. Look for the # to find the interesting
parts):
on doselect
put offset(field "Buffer", me, markchar) into foundpos
if foundpos is 0
then beep 1
else select after char foundpos + markchar + length(field "Buffer") of me
end doselect
on stopsearch
hide field "Prompt"
put field "Buffer" into lastsearch
hide field "Buffer"
show field "Editing Object"
put false into searching
end stopsearch
on keyDown which
switch
case searching
#### here's the important line for entering the character
put which after field "Buffer"
doselect
break
case cx
switch which
case "["
select before char 1 of me
break
case "]"
select after last char of me
break
end switch
put false into cx
break
default
pass keyDown
break
end switch
end keyDown
on commandKeyDown which
put searching into wassearching
if which is not empty and which is not "s" then stopsearch
switch which
case " "
put word 2 of the selectedChunk into markchar
break
case "g"
beep 1
# control-g stops the search
if wassearching then select before char searchmark of me
break
# here's the control-s that starts a search (it retrieves the last
# searched string if pressed twice, just like Emacs).
case "s"
if wassearching then
if field "Buffer" is empty
then put lastsearch into field "Buffer"
else put word 2 of the selectedChunk into markchar
doselect
else
hide field "Editing Object"
show field "Prompt"
put empty into field "Buffer"
show field "Buffer"
put word 2 of the selectedChunk into markchar
put markchar into searchmark
put true into searching
end if
break
case "w"
cut char markpos to (word 2 of the selectedChunk) of field "Editor Field"
break
case "x"
put true into cx
break
default
put false into cx
pass commandKeyDown
break
end switch
end commandKeyDown
> Something really minor:
>
> According to the limits in the MC reference stack, the maximum string
> that can be sent/received from an external is 64K. I think that this
> isn't quite true, as it is a limit of the X server, and may be as small
> as 16K (but no smaller). ("X Protocol Reference Manual for X11 R5"
> volume 0, p. 19). I recently bumped into this limit, a bit of a pain to
> get around (now sending multiple chunks).
The 64K limit was probably derived empirically based on the minimum of
the native servers on the systems MetaCard is supported on. But
you're correct: the actual limit is determined by the X server.
> Does the libmc.a library also have this limit (i.e. does it still use X
> properties to implement externals?
In Embedded MetaCard (libmc.a) calls are direct and so there is no
limit on message size.
> -Earle
>
> --
> Earle Lowe
> emlowe@fsa.ca
> FSA Corporation
> Performance and system software for UNIX networks.
-- *********************************************************************** * Scott Raney 303-447-3936 Remember: the better you look, * * raney@metacard.com the more you'll see -- Lidia * ***********************************************************************