Re: [code] Adding multiple selection on double click

From: Milind Gupta <milind.gupta.att.gmail.com>
Date: Mon, 17 Jul 2017 11:44:53 -0700

Thanks for the lead. I was able to make it work finally. The
findAllAtCursor did not have to change. Here is the new double click even
function

events.connect(events.DOUBLE_CLICK,function(string)
        -- Get the word
        local cp = buffer.current_pos
        local fl = buffer.first_visible_line
        local buf = buffer
        --local cp = buffer.current_pos
        local pos = findAllAtCursor()
        for i = 1,#pos do
            buffer:add_selection(pos[i][2],pos[i][1])
        end
        buffer:add_selection(cp, cp)
    end
)

On Fri, Jul 14, 2017 at 4:27 PM, Mitchell <m.att.foicica.com> wrote:

> Hi Milind,
>
> On Fri, 14 Jul 2017, Milind Gupta wrote:
>
> Another interesting observation is that if I put the line:
>>
>> *ui.dialogs.colorselect({title="Hello"})*
>>
>> just before the line buffer.first_visible_line=fl then it pops up the
>> dialog but first_visible_line works now.
>>
>> Somehow without any ui interaction the buffer.first_visible_line=fl has no
>> effect. I don't know if this is a bug.
>>
>
> Thanks for the additional information. Anytime you perform a batch set of
> operations that involve scrolling or altering the view, the view cannot
> exactly know what state it is in until there is a redraw. (The
> `ui.dialogs.colorselect()` call happened to trigger a redraw). What you
> should do is try to avoid altering the scroll position at all during your
> selection operation. For example, I noticed in your `findAllAtCursor()`
> function you call `buffer:set_sel(position, position)`. That will alter the
> scroll position if `position` is not currently in view. I think you
> mentioned `buffer:add_selection()` in a previous e-mail. That call does not
> scroll the view.
>
> I hope this helps somewhat.
>
>
> Cheers,
> Mitchell
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Mon 17 Jul 2017 - 14:44:53 EDT

This archive was generated by hypermail 2.2.0 : Tue 18 Jul 2017 - 06:50:38 EDT