Scrolling editor panes programmatically
I have a CAPI application which has a couple of editor panes with
scrollbars. I want to programmatically scroll the panes to a certain
position (based on the contents of the panes) even if the panes don't
have the focus.
I want to avoid using the SCROLL function directly because in that
case I'd have to compute the amount of scrolling based on the contents
of the editor pane (including font size, line breaks, all that stuff)
so I thought I'd use the editor's "Refresh Screen" command.
My idea was to do it like this, more or less:
(defun foo (pane)
(let ((buffer (capi:editor-pane-buffer pane)))
(editor::buffer-save-excursion (buffer)
(editor:with-point ((point (editor:current-point)))
(editor:move-point point
(compute-point-where-i-want-to-go))
(editor:refresh-screen-command)))))
But that doesn't work. Then I looked at the editor's source code and
found out that the definition of "Refresh Screen" is rather short. It
just calls MOVE-LINE-TO-POSITION (which isn't defined in the
sources). So, OK, could I call it directly? I need a "window" for
that, how do I get it? I tried something like this but that also
didn't work:
(car (editor:buffer-windows buffer))
So, hmm, what's the best way to accomplish this? Can I use "Refresh
Screen" but I'm just too dumb to find out how? Or is there a function
which maps the positon of the current point to its corresponding
scroll position? Anything else that I'm missing?
Thanks,
Edi.