aboutsummaryrefslogtreecommitdiff
path: root/core/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'core/init.lua')
-rw-r--r--core/init.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/init.lua b/core/init.lua
index df4a5e38..2d540018 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -16,6 +16,17 @@ keys = require('keys')
_M = {} -- language modules table
-- LuaJIT compatibility.
if jit then module, package.searchers, bit32 = nil, package.loaders, bit end
+-- curses compatibility.
+if CURSES then
+ function spawn(argv, working_dir, stdout_cb, stderr_cb, exit_cb)
+ local current_dir = lfs.currentdir()
+ lfs.chdir(working_dir:iconv(_CHARSET, 'UTF-8'))
+ local p = io.popen(argv:iconv(_CHARSET, 'UTF-8')..' 2>&1')
+ stdout_cb(p:read('*all'))
+ exit_cb(select(3, p:close()))
+ lfs.chdir(current_dir)
+ end
+end
--[[ This comment is for LuaDoc.
---
@@ -128,6 +139,8 @@ local timeout
---
-- Spawns an interactive child process *argv* in a separate thread with the help
-- of GLib.
+-- The terminal version spawns processes in the same thread and does not use
+-- GLib.
-- @param argv A UTF-8-encoded command line string containing the program's name
-- followed by arguments to pass to it. `PATH` is searched for program names.
-- @param working_dir The child's UTF-8 current working directory (cwd) or `nil`
@@ -136,6 +149,8 @@ local timeout
-- of standard output read from the child. Stdout is read asynchronously in
-- 1KB or 0.5KB blocks (depending on the platform), or however much data is
-- available at the time. All text is encoded in `_CHARSET`.
+-- The terminal version sends all output, whether it be stdout or stderr to
+-- this callback.
-- @param stderr_cb A Lua function that accepts a string parameter for a block
-- of standard error read from the child. Stderr is read asynchronously in 1KB
-- or 0.5kB blocks (depending on the platform), or however much data is