Re: Find Dialog Suggestion

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

On Thu, May 6, 2010 at 2:11 PM, Ryan Pusztai <rpusz....at.gmail.com> wrote:
>
> 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!
>

Sorry for replying to myself, but I fixed the weird behavior by removing the
EOL characters.

So here is an update:

-- 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():gsub( "%c", "" )
buffer:clear_selections()
 end

t.find.find_entry_text = text

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

I don't know if this could go in the main application, but I find this very
helpful.

-- 
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:22:45 EDT

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