Re: [textadept] replace_sel also causes weird scrolling?

From: mitchell <c....at.caladbolg.net>
Date: Thu, 5 May 2011 22:52:49 -0400 (EDT)

Hi David,

On Fri, 6 May 2011, David Tweed wrote:

> Hi,
>
> I'm getting some "interesting" behaviour which might be at either the
> GTKScintilla or textadept layer. With textadept 3.7 beta 3 I've added
> some preliminary abbreviation expansion code. The end of the text
> replacement routine in lua is
>
> if replacement then
> --massage replacement so case matches original
> if firstCharIsUpper then
> replacement=replacement:gsub("^%l", string.upper)
> end
> buffer:replace_sel(replacement)
> end
> --clear selection so next keypress doesn't zap it
> buffer:set_sel(cur_pos,cur_pos)
> buffer:goto_pos(cur_pos) -- ************
>
> This works correctly semantically, but when I use it on a buffer with
> wrapped lines (I'm primarily writing natural language text), at the
> point where a replacement is triggered the screen seems to "implictly
> scroll" so that the text cursor position is "scrolled down"
> four-or-five of lines (and if the cursor is near the bottom of the
> screen, this can even result in it moving off the screen). When I type
> the next character the line snaps back to what looks like where it
> originally was. The starred goto_pos isn't actually needed by the
> code, but I put it in to see if it would avoid this effect, but it
> doesn't.

This is a Scintilla thing. According to the Scintilla docs, the
SCI_REPLACESEL (replace_sel), SCI_SETSEL (set_sel) and SCI_GOTOPOS
(goto_pos) messages all scroll the caret into view, so this would likely
explain the odd scrolling behavior you see. It may be worth asking about
this on the Scintilla mailing list. Just explain how your buffer is
configured and what messages you are sending (e.g buffer:replace_sel() ==
SCI_REPLACESEL) and what behavior you are experiencing.

mitchell

>
> I've scanned through the snippets lua code but it doesn't appear to do
> anything special about this, but then I imagine that it wouldn't be an
> issue with snippets since it looks like they're designed to be
> multi-line (rather than single word insertions/replacements) where it
> wouldn't matter if the display scrolls.
>
> I just thought I'd ask if anyone else has encountered (and maybe
> solved) this issue in the past?
>
> --
> cheers, dave tweed__________________________
> computer vision reasearcher: david.tw....at.gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
>
>

mitchell
Received on Thu 05 May 2011 - 22:52:49 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:06:24 EST