Re: Scrolling an editor pane during create callback
Edi,
On Oct 23, 2005, at 10:52 AM, Jeff Caldwell wrote:
> My best guess is a race condition, which is why I tried mp:yield
> and friends.
> My hypothesis is that capi:display scrolls editor panes to the top
> after the
> pane's :create-callback has been called. In foo, capi:display
> creates a
> second process and returns. The race is between foo trying to (down
> (editor
> interface)) and capi:display trying to do it's version of (up (editor
> interface)).
You might also try using editor:process-character to call your
function that manipulates the editor. According to Martin, this is
critical on the Mac and necessary in some cases on Windows/Linux. I
have had to jump through a lot of hoops to make things work on the
Mac with the interface and editor running in separate processes.
John
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
====
From: martin@xanalys.com
Subject: Re: (Lisp Support Call #30129) editor pane issues
Date: June 4, 2004 6:34:41 AM EDT
To: desoi@icx.net
Cc: lisp-support@xanalys.com
Reply-To: lisp-support@xanalys.com
>>>>> On Thu, 3 Jun 2004 15:38:18 -0400, John DeSoi <desoi@icx.net>
>>>>> said:
>>>>>
John> DESCRIPTION:
John> I'm trying to setup an interface editor pane to edit a file.
It works
John> except that the insertion point is placed at the end of the
editor
John> buffer and the text is scrolled to this location at the end.
If I hit
John> the home key, the display flashes but nothing happens.
Hitting it a
John> second time actually scrolls the buffer to the beginning.
This is a multithreading problem, because the editor operations need
to run in
their own thread in the Mac OS X version of LispWorks, not the thread
of the
CAPI window. The way to initiate this is using the function
EDITOR:PROCESS-CHARACTER, which can be passed a list containing a
function and
its arguments. Note that you should not perform CAPI operations using
EDITOR:PROCESS-CHARACTER, only editor operations.
E.g.
(defun set-buffer-file (ed path)
(let* ((pane (edit-pane ed))
(buff (capi:editor-pane-buffer pane))
(window (capi:editor-window pane)))
(editor:process-character
`(editor:find-alternate-file-command nil ,path ,buff)
window)))
====
From: martin@xanalys.com
Subject: Re: (Lisp Support Call #30129) editor pane issues
Date: June 4, 2004 9:49:29 AM EDT
To: desoi@icx.net
Cc: lisp-support@xanalys.com
Reply-To: lisp-support@xanalys.com
>>>>> On Fri, 4 Jun 2004 08:47:14 -0400, John DeSoi <desoi@icx.net>
>>>>> said:
>>>>>
John> On Jun 4, 2004, at 6:34 AM, Martin Simmons wrote:
>> This is a multithreading problem, because the editor operations need
>> to run in
>> their own thread in the Mac OS X version of LispWorks, not the thread
>> of the
>> CAPI window. The way to initiate this is using the function
>> EDITOR:PROCESS-CHARACTER, which can be passed a list containing a
>> function and
>> its arguments. Note that you should not perform CAPI operations
>> using
>> EDITOR:PROCESS-CHARACTER, only editor operations.
>>
John> Works great now, thanks for your help on this.
John> Is this a work-around for OS X only or is it acceptable to
do this for
John> other platforms? Eventually I wish to target Linux and Windows.
Yes, it is the best thing for all platforms. On the other platforms,
editor
commands are run in the thread of the CAPI window, but
EDITOR:PROCESS-CHARACTER also sets up the current editor window and
buffer,
which some editor commands need to function correctly.
John> I have other editor commands called from capi menus (e.g.
John> editor:revert-buffer-command). These seem to work OK. Do I
need to
John> change all of them to use editor:process-character?
Yes.