Re: Find Dialog Suggestion

From: Ryan Pusztai <rpusz....at.gmail.com>
Date: Thu, 6 May 2010 14:11:09 -0400

Jay,

On Thu, May 6, 2010 at 10:37 AM, Jay <robert.jay.go....at.gmail.com> wrote:

> Mine does it :)
>
> change key_commands.lua so
> -------------------
> keys.cf = { function()
> local text = buffer:get_sel_text()
> if #text ~= 0 then
> t.find.find_entry_text = text
> end
> t.find.focus()
> end}
> -------------------
>
> that should do it
>

Nice. I even improved it a bit more by adding the current word if there is
no selected text.
-- key_commands.lua ---------------
local m_editing = _m.textadept.editing
-- Add the current selection/word under the cursor to the default find.
keys.cf = {
function()
local buffer = buffer
 local t = textadept
local text = buffer:get_sel_text()
if #text == 0 then
 -- select current word
m_editing.current_word()
-- get the selected text
 text = buffer:get_sel_text()
buffer:clear_selections()
end

t.find.find_entry_text = text

t.find.focus()
end }
---------------

The only thing that is sorta wierd is that the current_word() function is
getting the end of line charascters if your cursor is on the end of the
line.
Example: if the cursor is next to the 'd' in 'end' it will pick up "end<LF>"
instead of "end"
Any ideas?

Man TextAdept is so configurable!

-- 
Regards,
Ryan
-- 
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.
Received on Thu 06 May 2010 - 14:11:09 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:45:11 EST