Re: textadept 2.0 ideas/suggestions

From: M Rawash <mraw....at.gmail.com>
Date: Tue, 07 Jul 2009 20:58:00 +0300

sorry, i didn't have an internet access at home for the past few days..

On Tue, 2009-06-30 at 20:22 +0700, Vyacheslav Egorov wrote:
> > this is probably one of the more trivial tasks yet, i've come up
> with a
> > way to fork run.execute in the background and then back, using
> > lua-posix, but it keeps crashing ta (so it only works in theory),
> would
> > you be interested in debugging it?
>
> Could you please share it with us?
>

as i said, i hadn't had a chance to test it thoroughly, you can,
however, modify it for use outside of ta as a proof of concept:

require 'posix'
function execute(command)
  local filepath = textadept.iconv(buffer.filename, _CHARSET, 'UTF-8')
  local filedir, filename = filepath:match('^(.+[/\\])([^/\\]+)$')
  local filename_noext = filename:match('^(.+)%.')
  command = command:gsub('%%%b()', {
    ['%(filepath)'] = filepath, _CHARSET, 'UTF-8',
    ['%(filedir)'] = filedir,
    ['%(filename)'] = filename,
    ['%(filename_noext)'] = filename_noext,
  })
  local current_dir = lfs.currentdir()
  lfs.chdir(filedir)
  local pfork = assert(posix.fork())
  if ( pfork==0 )then
    local p = io.popen(command..' 2>&1')
    local out = p:read('*all')
    p:close()
    lfs.chdir(current_dir)
    textadept.print(textadept.iconv('..done!', 'UTF-8', _CHARSET))
    buffer:clear_all()
    textadept.print(textadept.iconv('> '..command..'\n'..out, 'UTF-8', _CHARSET))
    buffer:goto_pos(buffer.length)
  else
    textadept.print(textadept.iconv('waiting for \''..command..'\' to finish..', 'UTF-8', _CHARSET))
  end
end
Received on Tue 07 Jul 2009 - 13:58:00 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:38:19 EST