How to use EDITOR:PROCESS-CHARACTER?
Hi!
I'm trying to port my "Regex Coach" app[1] to Mac OS X. This basically
looked like a no-brainer but there's a serious timing problem related
to CAPI display updates. I searched around in the knowledgebase and in
old mailing list articles and I'm pretty sure this is the kind of
problem that has to be tackled with EDITOR:PROCESS-CHARACTER however I
fail to understand how this function should be applied properly.
I have specialized editor panes that are basically defined like this:
(defclass editor-pane* (editor-pane))
(defclass regex-editor-pane (editor-pane*) ())
(defmethod capi:call-editor :after ((pane regex-editor-pane) command)
(declare (ignore command))
(ignore-errors
(regex-editor-after-callback pane)))
In the REGEX-EDITOR-AFTER-CALLBACK function I call
X-HIGHLIGHT-WITH-FACE which is based on a function I once got from
Xanalys support:
(defun x-highlight-with-face (pane start-index end-index face)
(let ((buffer (capi:editor-pane-buffer pane)))
(editor::buffer-save-excursion (buffer)
(editor:with-point ((start (editor:buffers-start buffer))
(end (editor:buffers-start buffer)))
(editor:increment-point start start-index)
(editor:increment-point end end-index)
(cond (face
(editor::push-region-face face start end))
(t
(editor:remove-text-properties start end
(list 'editor::face t)))))))))
If I run this code (which works fine on Windows and Linux) unmodified
on OS X the editor panes only get updated with a delay of one key
pressed, i.e. the editor faces always reflect the state /before/ the
last key was pressed.
Now, where exactly do I use EDITOR:PROCESS-CHARACTER here? I tried to
wrap it around the whole BUFFER-SAVE-EXCURSION form but that didn't do
it. Then I wrapped it around PUSH-REGION-FACE and
REMOVE-TEXT-PROPERTIES respectively but that didn't help
either. Hmmm...
Thanks in advance,
Edi.
[1] <http://weitz.de/regex-coach/>