From 19ed105d4180a292dc7a3f02fc95d0df1c851492 Mon Sep 17 00:00:00 2001 From: HAYAMA_Kaoru Date: Wed, 1 Oct 2014 14:20:11 +0900 Subject: [PATCH] =?UTF-8?q?Lua=E9=96=A2=E6=95=B0=20nyagos.echo=20=E3=81=8C?= =?UTF-8?q?=E3=82=A8=E3=82=B9=E3=82=B1=E3=83=BC=E3=83=97=E3=82=B7=E3=83=BC?= =?UTF-8?q?=E3=82=B1=E3=83=B3=E3=82=B9=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lua.go b/lua.go index d160546f..5267b5f2 100644 --- a/lua.go +++ b/lua.go @@ -14,6 +14,8 @@ import "./dos" import "./interpreter" import "./mbcs" +import "github.com/shiena/ansicolor" + const nyagos_exec_cmd = "nyagos.exec.cmd" type LuaFunction struct { @@ -150,19 +152,15 @@ func cmdEval(L *Lua) int { } func cmdEcho(L *Lua) int { - var out io.Writer + var out io.Writer = os.Stdout L.GetField(Registory, nyagos_exec_cmd) if L.GetType(-1) == TLIGHTUSERDATA { - cmd := (*exec.Cmd)(L.ToUserData(-1)) - if cmd != nil { + if cmd := (*exec.Cmd)(L.ToUserData(-1)); cmd != nil { out = cmd.Stdout - } else { - out = os.Stdout } - } else { - out = os.Stdout } L.Pop(1) + out = ansicolor.NewAnsiColorWriter(out) n := L.GetTop() for i := 1; i <= n; i++ {