[code] Adding multiple selection on double click

From: Milind Gupta <milind.gupta.att.gmail.com>
Date: Thu, 13 Jul 2017 12:00:44 -0700

Hi,
      I am trying to add a functionality similar to notepad++ where when a
word is double clicked all similar words are highlighted in the document.
It works fine except it scrolls down to the bottom of the document and does
not maintain the scroll position. Here is my code:

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

findAllAtCursor is from the findall.lua file here
https://foicica.com/wiki/multi-edit.

The scroll_range command works fine if I run it from the command entry but
somehow here it does not reset the scroll view. Also is there a way to
prevent the scrolling from happening in the first place. I think
add_selection scroll it.

Thanks,
Milind

-- 
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 Thu 13 Jul 2017 - 15:00:44 EDT

This archive was generated by hypermail 2.2.0 : Fri 14 Jul 2017 - 06:30:19 EDT