On 22/08/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Brad Beveridge wrote:

<SNIP>
>
> Q1) Is using ml_append from (effectively) within RealWaitForChar a bad
> thing?  At the moment it appears to work properly.

Yes.  You never know where in Vim you are, the caller may not handle the
situation that the text changes unexpectedly.  It's similar to
autocommands, which have caused crashes in the past.
I've protected the callbacks from re-entrancy now, but I'm glad to
hear that this is indeed a problem.

> At the moment, after the callback has run we call
> screen_update(NOT_VALID).  However, from what I can see, calling
> screen_update may (does?) re-call RealWaitForChar, which can retrigger
> the callback, etc.
> Q2) Is this nesting of RealWaitForChar a bad thing? (I thing it may
> be)

Yes, it must be avoided.
I now return 0 from RealWaitForChar, and test for the callback
requesting a redraw in getchar.c

<SNIP>


> If the list would like to see this code, I can post a patch, or you
> can use Darcs to get a Vim+Callbacks+ECL from
> http://theclapp.org/repos/vim70+async+ecl/.
>
> Q4) Would this callback mechanism be more generally useful for other
> scripting engines?

Yes, if you can implement it for various systems (at least Unix, Mac and
MS-Windows).

If I would have time I would look into making the code that waits for a
character to be typed more generic.  Currently quite a bit of code is
repeated for every system.

I believe that we currently support the unix based OSes (os_unix.c),
Cygwin and Win32 - though I am not sure.  I will confirm that we have
users of each of the main systems.  The code is not quite mine to give
away, although the comments in the file suggest the author (Jim
Bailey) is happy to have his code under the Vim license, I would like
to confirm with him first.

I hope to hear from Jim soon.

Cheers
Brad

Reply via email to