aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/init.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2014-03-27 13:45:29 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2014-03-27 13:45:29 -0400
commit7785897657cd9c3a5e1483ebacad73939f375a7e (patch)
treeb168e4ec9c72248be21841807177870a07f32659 /core/init.lua
parentf65b2b2a66f05b20010256ca1d81cc3252ea1471 (diff)
Added basic project support for snapopen and build scripts.
Also fixed some curses errors introduced by the last commit.
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