Quote Marked Area

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: 2432
Joined: Fri Aug 13, 2004 5:10 pm

Quote Marked Area

Post by jussij » Tue May 27, 2014 5:45 am

The macro below is designed to be bound to the quote (") character using the Options, Editor Options menu, Keyboard Mapping panel.

The macro will wrap any marked region of text in quotes.

Code: Select all

--
--        Name: Add Quote to Marked Area
--
--      Author: Jussi Jumppanen
--
--    Language: Lua Macro
--
-- Description: This macro is designed to be bound to the quote character
--              and it will wrap the marked area in quotes. If no marked
--              area is defined it just passes the event to the default
--              keybaord handler.
--
function key_macro()

  local processed = false

  if is_document() == 1 and is_read_only() == 0 then
    if is_marked() == 1 then
        -- disable screen updates
        screen_update_disable()

        -- get the marked text details
        top    = get_marked_top()
        left   = get_marked_left()
        bottom = get_marked_bottom()
        right  = get_marked_right()
        mode   = get_marked_mode()

        -- remnove the marked area
        MarkHide()

        -- insert the trailing quoted
        set_line_pos(bottom, right)
        print("\"")

        -- insert the leading quoted
        set_line_pos(top, left)
        print("\"")

        -- adjust the end of the marked region
        if top == bottom then
            right = right + 2
        else
            right = right + 1
        end

        -- apply the new marked region
        set_marked_area(mode, top, left, bottom, right)

        -- restore screen updates
        screen_update_enable()

        -- processing complete
        processed = true
    end
  end

  if processed == false then
    -- let the default handle the quote char
    keyboard_default("\"")
  end
end

key_macro() -- run the macro

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 1 guest