Re: [textadept] Textadept 4.0

From: steve donovan <steve.j.dono....at.gmail.com>
Date: Wed, 21 Sep 2011 10:38:31 +0200

On Tue, Sep 20, 2011 at 3:54 PM, steve donovan
<steve.j.dono....at.gmail.com> wrote:
> It would be a good fit, and it's fairly small.  I'll try & see how to
> integrate at least the 'silent' execute function.

Right - that was easy!

1) download http://stevedonovan.github.com/files/winapi-1.3.0-TA-bin.zip
and put winapi.dll next to your textadept.exe

2) add this monkey-patch to your ~/.textadept/init.lua

local ok, winapi = pcall(require,'winapi')
if ok then
  io.popen = function(cmd)
    local tmpfile = winapi.temp_name()
    cmd = cmd:gsub('2>&1','')
    winapi.execute(cmd..' > '..tmpfile..' 2>&1')
    return io.open(tmpfile)
  end
end

Et voilą, no more flashing black box! I've made sure it captures both
stdout and stderr, hence the rearragement of the command line. It
_feels_ faster, but that may be subjective.

The zip also contains a textadept.la which you can use to link any
mingw Lua C extension against the Textadept executable. It was made
from textadept.def, also included. The build-ta.bat can be used as a
template for any C extensions you wish to build for textadept.

 Note that any arbitrary compiled Lua extension you find on the web is
unlikely to work, due to issues with Windows and DLLs:
 - they need to linik against a precise known target (against
lua51.dll is _not_ good enough)
 - binaries may be linked against the horrible MS runtime and will
fail in interesting ways

It is not what I would call a final solution; the full winapi.dll is
only 35K but is overkill for this simple job. If there's interest,
I'll make an extension that just does a quiet popen, which will be
small enough to bundle with the exe without messing with mitchell's
beloved C line count (which I totally approve of BTW)

io.popen is in any case a flawed function, since in Lua 5.1 you have
no easy way of finding what the return code of the process is
(p:close() in Lua 5.2 does return this, but that's a major effort to
sort out one API call!)

steve d
Received on Wed 21 Sep 2011 - 04:38:31 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:21:45 EST