From 4f2fc096e5949aacb5f0c5cb27463295796663c9 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 27 Aug 2017 17:18:56 +0100 Subject: [PATCH] add comment and let multi values to the log to make it easy to log. (#788) * add comment and let multi values to the log to make it easy to log. * added WorkingDirectory to lua bindings (returns the current directory) --- cmd/micro/messenger.go | 6 ++++-- cmd/micro/micro.go | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 0056c61e..5715be84 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -70,9 +70,11 @@ type Messenger struct { gutterMessage bool } -func (m *Messenger) AddLog(msg string) { +// AddLog sends a message to the log view +func (m *Messenger) AddLog(msg ...interface{}) { + logMessage := fmt.Sprint(msg...) buffer := m.getBuffer() - buffer.insert(buffer.End(), []byte(msg+"\n")) + buffer.insert(buffer.End(), []byte(logMessage+"\n")) buffer.Cursor.Loc = buffer.End() buffer.Cursor.Relocate() } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index d4668508..483d74e7 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -363,6 +363,7 @@ func main() { L.SetGlobal("Loc", luar.New(L, func(x, y int) Loc { return Loc{x, y} })) + L.SetGlobal("WorkingDirectory", luar.New(L, os.Getwd)) L.SetGlobal("JoinPaths", luar.New(L, filepath.Join)) L.SetGlobal("DirectoryName", luar.New(L, filepath.Dir)) L.SetGlobal("configDir", luar.New(L, configDir))