9 Jun 2008 10:35
Re: copy bookmarked lines
Philippe Lhoste <PhiLho <at> GMX.net>
2008-06-09 08:35:15 GMT
2008-06-09 08:35:15 GMT
On 08/06/2008 21:58, mozers wrote:
> ----------------------------------------------------
> function CopyBookmarkedLines()
> editor:Home()
> local ml = 0
> local s_text = ""
> local sel_start = editor.CurrentPos
> while true do
> ml = editor:MarkerNext(ml, 2)
> if (ml == -1) then break end
> s_text = s_text .. editor:GetLine(ml)
> ml = ml + 1
> end
> editor:CopyText(s_text)
> end
> ----------------------------------------------------
Nice one! Thanks, it saves us some research...
It probably won't change anything with few markers, but in general I
would avoid raw concatenation in a loop, so my version would be:
----------------------------------------------------
function CopyBookmarkedLines()
local ml = 0
local lines = {}
while true do
ml = editor:MarkerNext(ml, 2)
if (ml == -1) then break end
table.insert(lines, (editor:GetLine(ml)))
ml = ml + 1
end
editor:CopyText(table.concat(lines))
print('Copied lines: ' .. table.getn(lines))
end
----------------------------------------------------
With added information at the end (Lua 5.0 style) to confirm something
have been done...
Perhaps it would be nicer to display such info in the status bar,
avoiding displaying the output pane. But I don't know if Lua can change it.
--
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To post to this group, send email to scite-interest <at> googlegroups.com
To unsubscribe from this group, send email to scite-interest-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/scite-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
RSS Feed