diff options
author | 2014-03-26 10:15:53 -0400 | |
---|---|---|
committer | 2014-03-26 10:15:53 -0400 | |
commit | f65b2b2a66f05b20010256ca1d81cc3252ea1471 (patch) | |
tree | c7ee3cd4753a9e8a73f9e9d3e8a45f96eb5b36c7 /core/file_io.lua | |
parent | 6304010d93b3cfe43e246dbb49c60d147a366b1b (diff) | |
download | textadept-f65b2b2a66f05b20010256ca1d81cc3252ea1471.tar.gz textadept-f65b2b2a66f05b20010256ca1d81cc3252ea1471.zip |
Include my new "lspawn" module by default for spawning processes.
The `textadept.run` module now uses `spawn()` instead of `io.popen()`.
This module replaces the dependency on winapi. Removed experimental
`io.popen()` and `os.execute()` hooks. They may be re-implemented later using
`spawn()`.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r-- | core/file_io.lua | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index 35ca5c03..a313cc66 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -418,48 +418,3 @@ function io.snapopen(paths, filter, exclude_FILTER, opts) for i = 1, #files do files[i] = files[i]:iconv(_CHARSET, 'UTF-8') end io.open_file(files) end - --- On Windows, override `io.popen` and `os.execute` to use winapi to prevent the --- flashing black box. -if WIN32 then - local winapi = require('winapi') - io.popen = function(prog) - local p, f = winapi.spawn_process(os.getenv('COMSPEC')..' /c '..prog) - if not p then return nil, f end - local file - file = { - read = function(self, format) - if not format or not format:find('^%*a') then return f:read() end - local chunk, text = f:read(), {} - while chunk do - text[#text + 1] = chunk - chunk = f:read() - end - return table.concat(text, '') - end, - write = function(self, ...) f:write(...) end, - flush = function() end, - lines = function() - local output, pos = file:read('*a'), 1 - if not output:find('\r?\n$') then output = output..'\n' end - return function() - local s, e, line = output:find('([^\r\n]*)\r?\n', pos) - if not s then return nil end - pos = e + 1 - return line - end - end, - close = function() - local _, status = p:wait(100) - if status == 'TIMEOUT' then p:kill() end - return true, 'exit', p:get_exit_code() - end - } - return file - end - os.execute = function(prog) - if not prog then return true end -- shell is available - local code = winapi.execute(prog) - return code == 0 and true or nil, 'exit', code - end -end |