STC + vertical offset

Heyas folks,

I have an application where I call SetText() on a STC control
repeatedly.

I have overridden SetText to save the anchor/position so that the
selection position but I would also like to attempt to restore the
vertical scroll position. I think the function I would like to have
is GetYOffset although it doesn't seem to exist in scintilla.

Does anyone an idea better than scrolling to the original cursor
postion?

This has the undesired effect of adjusting where the current line is
if I change to a differening text (with enough lines) and then go back
to the original.

    def SetText(self, txt):
        """ Set the data in this control to text but also try to
        restore the current position"""

        # turn off read only
        x = self.GetReadOnly()
        self.SetReadOnly(0)

        linenum = self.GetCurrentLine()

        pos = self.GetCurrentPos()
        anchor = self.GetAnchor()
        wx.stc.StyledTextCtrl.SetText(self, txt)
        self.SetAnchor(anchor)
        self.SetCurrentPos(pos)

        # center the current selection if there is any
        # this doesn't really do a good job as the focus shifts
        self.LineScroll(0,linenum)

        # turn it back on
        self.SetReadOnly(x)

···

--
Chris Green <cmg@dok.org>
Laugh and the world laughs with you, snore and you sleep alone.