Code: Select all
--
-- Name: Mark Folded Region
--
-- Author: Jussi Jumppanen
--
-- Language: Lua Macro
--
-- Description: This macro will mark the region between two fold points. To
-- use the macro place the cursor somewhere in between the fold
-- points and run the macro.
--
function key_macro()
-- macro only works for documents
local document = is_document()
if (document == 0) then
message("This macro only works document files.");
beep();
return;
end
screen_update_disable()
cursor_save()
if FoldingParentFindPrevious() == 1 then
local y1 = get_line_pos()
local x1 = get_cursor_pos()
cursor_restore()
if FoldingParentFindNext() == 1 then
MoveLineEnd()
local y2 = get_line_pos()
local x2 = get_cursor_pos()
-- values taken from Zeuus help file
local MARK_LINE = 1
local MARK_BLOCK = 2
-- use block mode to mark the region
set_marked_area(MARK_BLOCK, y1, x1, y2, x2)
-- uncomment to use line mode to mark the region
--set_marked_area(MARK_LINE, y1, x1, y2, x2)
return
end
else
cursor_restore()
end
screen_update_enable()
screen_update()
message("No fold points found.")
end
key_macro() -- run the macro