diff options
author | 2016-01-30 22:10:09 -0500 | |
---|---|---|
committer | 2016-01-30 22:10:09 -0500 | |
commit | 491a5f0b794c799a1c45971ef92e86488b322b81 (patch) | |
tree | c7be4cf887b1b7bbc820c2175d543f2f4409d09c /core/init.lua | |
parent | aad5a9aeab1390d4c8fb07e6d790425f6d84b9c1 (diff) |
Replaced `buffer:text_range()` C function with a Lua function.
Diffstat (limited to 'core/init.lua')
-rw-r--r-- | core/init.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/init.lua b/core/init.lua index 093d0faa..ce126943 100644 --- a/core/init.lua +++ b/core/init.lua @@ -33,6 +33,18 @@ if CURSES and WIN32 then end end +-- Replacement for original `buffer:text_range()`, which has a C struct for an +-- argument. +-- Documentation is in core/.buffer.luadoc. +local function text_range(buffer, start_pos, end_pos) + local target_start, target_end = buffer.target_start, buffer.target_end + buffer:set_target_range(start_pos, end_pos) + local text = buffer.target_text + buffer:set_target_range(target_start, target_end) -- reset + return text +end +events.connect(events.BUFFER_NEW, function() buffer.text_range = text_range end) + --[[ This comment is for LuaDoc. --- -- Extends Lua's _G table to provide extra functions and fields for Textadept. |