Mark Text Between Two Fold Points

This forum allows you to share scripts with other Zeus users. Please do not post bug reports, feature requests or questions to this forum, but rather use it exclusively for posting scripts or for the discussion of scripts that have been posted.
Post Reply
jussij
Site Admin
Posts: 2443
Joined: Fri Aug 13, 2004 5:10 pm

Mark Text Between Two Fold Points

Post by jussij » Fri Aug 08, 2014 5:13 am

As the name suggests this macro will mark the text between two fold points.

Code: Select all

-- 
--        Name: Mark Folded Region 
-- 
--      Author: Jussi Jumppanen 
-- 
--    Language: Lua Macro 
-- 
-- Description: This macro will mark the region between two fold points. 
-- 

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() 
            
            local MARK_BLOCK  = 2 

            set_marked_area(MARK_BLOCK, 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

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 2 guests