text_set assumes a complete replacement of the entire document with
something different, in which case moving to cursor position 1 is
appropriate.

If you are replacing with something identical or close to the current
content, you should instead create a Padre::Delta object with
Padre::Delta->from_scalars and then apply the delta to the current
document. Delta objects are applied in a way that retains the correct
location of the cursor and scroll in the kinds of scenarios where a
document is being modified rather than replaced wholesale.

Padre::Delta is new in 0.92, so it would mean WebGUI needs to upgrade
to support 0.92.

Adam

On 15 November 2011 23:52, arjan <ar...@unitedknowledge.nl> wrote:
> Hi Zeno,
>
> Oh, don't excuse yourself, I'm very happy you asked.
>
> - Yes it scrolls completely to the top. The cursor goes to position 1.
> - No this happens not all the time, and now that you asked me this, I
> tried several things and found when it does: It always does when I save
> using Padre-Plugin-WebGUI.
>
> And the problem is probably here:
> - on save the server returns the contents of the file.
> - the plugin processes this response and calls sub render there:
>
> $self->text_set($text);
> $self->{original_content} = $self->text_get;
>
> I suppose this is where the cursor returns to the first position,
> because the content of the editor is replaced with the content returned
> by the server.
>
> Hmm. What would be the best way to solve this? On the one hand, one
> could simply not process the response. On the other hand, this does make
> it clear what is actually stored.
>
> I cc'ed Patrick, who wrote the Plugin.
>
> Kind regards,
> Arjan.
>
> On 11/15/2011 01:14 PM, Zeno Gantner wrote:
>> Hi,
>>
>>>> On Tue, Nov 15, 2011 at 12:10 PM, arjan<ar...@unitedknowledge.nl>    wrote:
>>>>> Is there a similar trick to prevent Padre from scrolling to the top of
>>>>> the page on save?
>> I do not have this issue, so please excuse my questions:
>>
>> Does it scroll completely to the top?
>> Does it happen all of the time?
>> Does it happen with all file types?
>>
>> @list:
>> Does anybody know a possible cause of this and how it can be switched off?
>>
>> Best regards,
>>    Zeno
>>
>
>
> --
> NIEUW: http://www.makeso.com
>
> Hoe verslaan de media het nieuws? Wie haalt het nieuws en hoe werkt dat uit? 
> Bekijk het in The Makeso Media Calculator: www.makeso.com
>
> Recent: http://www.lomcongres.nl/
> Congres- en nieuwsbriefportaal met relatiebeheer systeem voor het Landelijk 
> Overleg Milieuhandhaving
>
> Setting Standards, a Delft University of Technology and United Knowledge 
> simulation exercise on strategy and cooperation in standardization, 
> http://www.setting-standards.com
>
> United Knowledge, internet voor de publieke sector
> Keizersgracht 74
> 1015 CT Amsterdam
> T +31 (0)20 52 18 300
> F +31 (0)20 52 18 301
> bur...@unitedknowledge.nl
> http://www.unitedknowledge.nl
>
> M +31 (0)6 2427 1444
> E ar...@unitedknowledge.nl
>
> Bezoek onze site op:
> http://www.unitedknowledge.nl
>
> Of bekijk een van onze projecten:
> http://www.handhavingsportaal.nl/
> http://www.setting-standards.com/
> http://www.lomcongres.nl/
> http://www.clubvanmaarssen.org/
>
> _______________________________________________
> Padre-dev mailing list
> Padre-dev@perlide.org
> http://mail.perlide.org/mailman/listinfo/padre-dev
>
_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to