diff options
author | 2008-06-17 16:43:09 -0400 | |
---|---|---|
committer | 2008-06-17 16:43:09 -0400 | |
commit | 102c01ba2db51190c7c79592a6ea2fdb29d4d4fa (patch) | |
tree | 781576920293b05c7585e410f8dc9d3f2e48a44f /core/events.lua | |
parent | e47fe640c0cd6826fa2b46d3b3fad7268766a093 (diff) | |
download | textadept-102c01ba2db51190c7c79592a6ea2fdb29d4d4fa.tar.gz textadept-102c01ba2db51190c7c79592a6ea2fdb29d4d4fa.zip |
Added Tab-completion to Lua Command Entry.
Diffstat (limited to 'core/events.lua')
-rw-r--r-- | core/events.lua | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/core/events.lua b/core/events.lua index fffa5aca..7a1ed360 100644 --- a/core/events.lua +++ b/core/events.lua @@ -383,74 +383,6 @@ add_handler('quit', return true end) - ---- --- Shows completions for the current command_entry text. --- Opens a new buffer (if one hasn't already been opened) for printing possible --- completions. --- @param command The command to complete. -function show_completions(command) - local textadept = textadept - local cmpl_buffer, goto - if buffer.shows_completions then - cmpl_buffer = buffer - else - for index, buffer in ipairs(textadept.buffers) do - if buffer.shows_completions then - cmpl_buffer = index - goto = buffer.doc_pointer ~= textadept.focused_doc_pointer - elseif buffer.doc_pointer == textadept.focused_doc_pointer then - textadept.prev_buffer = index - end - end - if not cmpl_buffer then - cmpl_buffer = textadept.new_buffer() - cmpl_buffer.shows_completions = true - else - if goto then view:goto(cmpl_buffer) end - cmpl_buffer = textadept.buffers[cmpl_buffer] - end - end - cmpl_buffer:clear_all() - - local substring = command:match('[%w_.:]+$') or '' - local path, o, prefix = substring:match('^([%w_.:]-)([.:]?)([%w_]*)$') - local ret, tbl = pcall(loadstring('return ('..path..')')) - if not ret then tbl = getfenv(0) end - if type(tbl) ~= 'table' then return end - local cmpls = {} - for k in pairs(tbl) do - if type(k) == 'string' and k:match('^'..prefix) then - cmpls[#cmpls + 1] = k - end - end - if path == 'buffer' then - if o == ':' then - for f in pairs(textadept.buffer_functions) do - if f:match('^'..prefix) then cmpls[#cmpls + 1] = f end - end - else - for p in pairs(textadept.buffer_properties) do - if p:match('^'..prefix) then cmpls[#cmpls + 1] = p end - end - end - end - table.sort(cmpls) - for _, cmpl in ipairs(cmpls) do cmpl_buffer:add_text(cmpl..'\n') end - cmpl_buffer:set_save_point() -end - ---- --- Hides the completion buffer if it is currently focused and restores the --- previous focused buffer (if possible). -function hide_completions() - local textadept = textadept - if buffer.shows_completions then - buffer:close() - if textadept.prev_buffer then view:goto_buffer(textadept.prev_buffer) end - end -end - --- -- Default error handler. -- Opens a new buffer (if one hasn't already been opened) for printing errors. |