From 7785897657cd9c3a5e1483ebacad73939f375a7e Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 27 Mar 2014 13:45:29 -0400 Subject: Added basic project support for snapopen and build scripts. Also fixed some curses errors introduced by the last commit. --- core/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/init.lua') 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 -- cgit v1.2.3