Compare commits

..

11 Commits

Author SHA1 Message Date
TorchedSammy 5a3b28142c
feat: add input mode 2022-03-29 18:51:14 -04:00
TorchedSammy 183b22e565
feat: implement aliases 2022-03-29 18:03:57 -04:00
TorchedSammy 8cf101cee2
chore: resolve merge conflict from master 2022-03-29 17:42:40 -04:00
TorchedSammy 34ae8ade7b
chore: tidy go modules 2022-03-29 15:28:39 -04:00
TorchedSammy 23b04159b0
chore: merge from master 2022-03-29 14:53:58 -04:00
TorchedSammy 294569d6e8
chore: update golua 2022-03-29 14:53:43 -04:00
TorchedSammy 9ff6e5879f
chore: bump go version to 1.17 2022-03-29 13:31:16 -04:00
TorchedSammy e775e5646f
chore: merge from master 2022-03-29 13:10:27 -04:00
TorchedSammy 1bd7b11ebc
chore: update lunacolors 2022-03-29 13:10:09 -04:00
TorchedSammy 20fae8a870
fix: prompt refresh (closes #116) 2022-03-29 13:07:27 -04:00
TorchedSammy 7373718416
feat: implement hilbish.interval 2022-03-29 13:05:43 -04:00
8 changed files with 133 additions and 102 deletions

View File

@ -4,7 +4,9 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/yuin/gopher-lua" "hilbish/util"
rt "github.com/arnodel/golua/runtime"
) )
var aliases *aliasHandler var aliases *aliasHandler
@ -64,41 +66,55 @@ func (a *aliasHandler) Resolve(cmdstr string) string {
// lua section // lua section
func (a *aliasHandler) Loader(L *lua.LState) *lua.LTable { func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
// create a lua module with our functions // create a lua module with our functions
hshaliasesLua := map[string]lua.LGFunction{ hshaliasesLua := map[string]util.LuaExport{
"add": a.luaAdd, "add": util.LuaExport{a.luaAdd, 2, false},
"list": a.luaList, "list": util.LuaExport{a.luaList, 0, false},
"del": a.luaDelete, "del": util.LuaExport{a.luaDelete, 1, false},
} }
mod := rt.NewTable()
mod := L.SetFuncs(L.NewTable(), hshaliasesLua) util.SetExports(rtm, mod, hshaliasesLua)
return mod return mod
} }
func (a *aliasHandler) luaAdd(L *lua.LState) int { func (a *aliasHandler) luaAdd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
alias := L.CheckString(1) if err := c.CheckNArgs(2); err != nil {
cmd := L.CheckString(2) return nil, err
a.Add(alias, cmd) }
alias, err := c.StringArg(0)
return 0 if err != nil {
} return nil, err
}
func (a *aliasHandler) luaList(L *lua.LState) int { cmd, err := c.StringArg(1)
aliasesList := L.NewTable() if err != nil {
for k, v := range a.All() { return nil, err
aliasesList.RawSetString(k, lua.LString(v))
} }
L.Push(aliasesList) a.Add(alias, cmd)
return 1 return c.Next(), nil
} }
func (a *aliasHandler) luaDelete(L *lua.LState) int { func (a *aliasHandler) luaList(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
alias := L.CheckString(1) aliasesList := rt.NewTable()
for k, v := range a.All() {
aliasesList.Set(rt.StringValue(k), rt.StringValue(v))
}
return c.PushingNext1(t.Runtime, rt.TableValue(aliasesList)), nil
}
func (a *aliasHandler) luaDelete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil {
return nil, err
}
alias, err := c.StringArg(0)
if err != nil {
return nil, err
}
a.Delete(alias) a.Delete(alias)
return 0 return c.Next(), nil
} }

111
api.go
View File

@ -4,26 +4,27 @@
package main package main
import ( import (
// "fmt" "errors"
"fmt"
"os" "os"
// "os/exec" // "os/exec"
"runtime" "runtime"
"strings" "strings"
// "syscall" // "syscall"
// "time" "time"
"hilbish/util" "hilbish/util"
rt "github.com/arnodel/golua/runtime" rt "github.com/arnodel/golua/runtime"
"github.com/arnodel/golua/lib/packagelib" "github.com/arnodel/golua/lib/packagelib"
// "github.com/maxlandon/readline" "github.com/maxlandon/readline"
// "github.com/blackfireio/osinfo" // "github.com/blackfireio/osinfo"
// "mvdan.cc/sh/v3/interp" // "mvdan.cc/sh/v3/interp"
) )
var exports = map[string]util.LuaExport{ var exports = map[string]util.LuaExport{
"alias": util.LuaExport{hlalias, 2, false},
/* /*
"alias": hlalias,
"appendPath": hlappendPath, "appendPath": hlappendPath,
*/ */
"complete": util.LuaExport{hlcomplete, 2, false}, "complete": util.LuaExport{hlcomplete, 2, false},
@ -38,11 +39,9 @@ var exports = map[string]util.LuaExport{
"prependPath": hlprependPath, "prependPath": hlprependPath,
*/ */
"prompt": util.LuaExport{hlprompt, 1, false}, "prompt": util.LuaExport{hlprompt, 1, false},
/* "inputMode": util.LuaExport{hlinputMode, 1, false},
"inputMode": hlinputMode, "interval": util.LuaExport{hlinterval, 2, false},
"interval": hlinterval, "read": util.LuaExport{hlread, 1, false},
*/
"read": util.LuaExport{hlprompt, 1, false},
/* /*
"run": hlrun, "run": hlrun,
"timeout": hltimeout, "timeout": hltimeout,
@ -51,7 +50,7 @@ var exports = map[string]util.LuaExport{
} }
var greeting string var greeting string
//var hshMod *lua.LTable var hshMod *rt.Table
var hilbishLoader = packagelib.Loader{ var hilbishLoader = packagelib.Loader{
Load: hilbishLoad, Load: hilbishLoad,
Name: "hilbish", Name: "hilbish",
@ -60,7 +59,7 @@ var hilbishLoader = packagelib.Loader{
func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) { func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) {
mod := rt.NewTable() mod := rt.NewTable()
util.SetExports(rtm, mod, exports) util.SetExports(rtm, mod, exports)
// hshMod = mod hshMod = mod
// host, _ := os.Hostname() // host, _ := os.Hostname()
username := curuser.Username username := curuser.Username
@ -82,7 +81,8 @@ Check out the {blue}{bold}guide{reset} command to get started.
util.SetField(rtm, mod, "dataDir", rt.StringValue(dataDir), "Directory for Hilbish's data files") util.SetField(rtm, mod, "dataDir", rt.StringValue(dataDir), "Directory for Hilbish's data files")
/* /*
util.SetField(L, mod, "interactive", lua.LBool(interactive), "If this is an interactive shell") util.SetField(L, mod, "interactive", lua.LBool(interactive), "If this is an interactive shell")
util.SetField(L, mod, "login", lua.LBool(interactive), "Whether this is a login shell")*/ util.SetField(L, mod, "login", lua.LBool(interactive), "Whether this is a login shell")
*/
util.SetField(rtm, mod, "greeting", rt.StringValue(greeting), "Hilbish's welcome message for interactive shells. It has Lunacolors formatting.") util.SetField(rtm, mod, "greeting", rt.StringValue(greeting), "Hilbish's welcome message for interactive shells. It has Lunacolors formatting.")
/*util.SetField(l, mod, "vimMode", lua.LNil, "Current Vim mode of Hilbish (nil if not in Vim mode)") /*util.SetField(l, mod, "vimMode", lua.LNil, "Current Vim mode of Hilbish (nil if not in Vim mode)")
util.SetField(l, hshMod, "exitCode", lua.LNumber(0), "Exit code of last exected command") util.SetField(l, hshMod, "exitCode", lua.LNumber(0), "Exit code of last exected command")
@ -111,11 +111,11 @@ Check out the {blue}{bold}guide{reset} command to get started.
// hilbish.aliases table // hilbish.aliases table
aliases = newAliases() aliases = newAliases()
/* aliasesModule := aliases.Loader(rtm)
aliasesModule := aliases.Loader(L) //util.Document(L, aliasesModule, "Alias inferface for Hilbish.")
util.Document(L, aliasesModule, "Alias inferface for Hilbish.") mod.Set(rt.StringValue("aliases"), rt.TableValue(aliasesModule))
L.SetField(mod, "aliases", aliasesModule)
/*
// hilbish.history table // hilbish.history table
historyModule := lr.Loader(L) historyModule := lr.Loader(L)
util.Document(L, historyModule, "History interface for Hilbish.") util.Document(L, historyModule, "History interface for Hilbish.")
@ -199,13 +199,14 @@ func luaBinaryComplete(L *lua.LState) int {
return 1 return 1
} }
*/ */
func setVimMode(mode string) { func setVimMode(mode string) {
// util.SetField(l, hshMod, "vimMode", lua.LString(mode), "Current Vim mode of Hilbish (nil if not in Vim mode)") util.SetField(l, hshMod, "vimMode", rt.StringValue(mode), "Current Vim mode of Hilbish (nil if not in Vim mode)")
// hooks.Em.Emit("hilbish.vimMode", mode) hooks.Em.Emit("hilbish.vimMode", mode)
} }
func unsetVimMode() { func unsetVimMode() {
// util.SetField(l, hshMod, "vimMode", lua.LNil, "Current Vim mode of Hilbish (nil if not in Vim mode)") util.SetField(l, hshMod, "vimMode", rt.NilValue, "Current Vim mode of Hilbish (nil if not in Vim mode)")
} }
/* /*
@ -294,20 +295,31 @@ func hlmlprompt(L *lua.LState) int {
return 0 return 0
} }
*/
// alias(cmd, orig) // alias(cmd, orig)
// Sets an alias of `cmd` to `orig` // Sets an alias of `cmd` to `orig`
// --- @param cmd string // --- @param cmd string
// --- @param orig string // --- @param orig string
func hlalias(L *lua.LState) int { func hlalias(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
alias := L.CheckString(1) if err := c.CheckNArgs(2); err != nil {
source := L.CheckString(2) return nil, err
}
cmd, err := c.StringArg(0)
if err != nil {
return nil, err
}
orig, err := c.StringArg(1)
if err != nil {
return nil, err
}
aliases.Add(alias, source) aliases.Add(cmd, orig)
return 1 return c.Next(), nil
} }
/*
// appendPath(dir) // appendPath(dir)
// Appends `dir` to $PATH // Appends `dir` to $PATH
// --- @param dir string|table // --- @param dir string|table
@ -411,30 +423,37 @@ func hltimeout(L *lua.LState) int {
} }
return 0 return 0
} }
*/
// interval(cb, time) // interval(cb, time)
// Runs the `cb` function every `time` milliseconds // Runs the `cb` function every `time` milliseconds
// --- @param cb function // --- @param cb function
// --- @param time number // --- @param time number
func hlinterval(L *lua.LState) int { func hlinterval(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
intervalfunc := L.CheckFunction(1) if err := c.CheckNArgs(2); err != nil {
ms := L.CheckInt(2) return nil, err
}
cb, err := c.ClosureArg(0)
if err != nil {
return nil, err
}
ms, err := c.IntArg(1)
if err != nil {
return nil, err
}
interval := time.Duration(ms) * time.Millisecond interval := time.Duration(ms) * time.Millisecond
ticker := time.NewTicker(interval) ticker := time.NewTicker(interval)
stop := make(chan lua.LValue) stop := make(chan rt.Value)
go func() { go func() {
for { for {
select { select {
case <-ticker.C: case <-ticker.C:
if err := L.CallByParam(lua.P{ _, err := rt.Call1(l.MainThread(), rt.FunctionValue(cb))
Fn: intervalfunc, if err != nil {
NRet: 0,
Protect: true,
}); err != nil {
fmt.Fprintln(os.Stderr, "Error in interval function:\n\n", err) fmt.Fprintln(os.Stderr, "Error in interval function:\n\n", err)
stop <- lua.LTrue // stop the interval stop <- rt.BoolValue(true) // stop the interval
} }
case <-stop: case <-stop:
ticker.Stop() ticker.Stop()
@ -443,10 +462,9 @@ func hlinterval(L *lua.LState) int {
} }
}() }()
L.Push(lua.LChannel(stop)) // TODO: return channel
return 1 return c.Next(), nil
} }
*/
// complete(scope, cb) // complete(scope, cb)
// Registers a completion handler for `scope`. // Registers a completion handler for `scope`.
@ -499,12 +517,20 @@ func hlwhich(L *lua.LState) int {
l.Push(lua.LString(path)) l.Push(lua.LString(path))
return 1 return 1
} }
*/
// inputMode(mode) // inputMode(mode)
// Sets the input mode for Hilbish's line reader. Accepts either emacs for vim // Sets the input mode for Hilbish's line reader. Accepts either emacs for vim
// --- @param mode string // --- @param mode string
func hlinputMode(L *lua.LState) int { func hlinputMode(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
mode := L.CheckString(1) if err := c.Check1Arg(); err != nil {
return nil, err
}
mode, err := c.StringArg(0)
if err != nil {
return nil, err
}
switch mode { switch mode {
case "emacs": case "emacs":
unsetVimMode() unsetVimMode()
@ -512,11 +538,14 @@ func hlinputMode(L *lua.LState) int {
case "vim": case "vim":
setVimMode("insert") setVimMode("insert")
lr.rl.InputMode = readline.Vim lr.rl.InputMode = readline.Vim
default: L.RaiseError("inputMode: expected vim or emacs, received " + mode) default:
return nil, errors.New("inputMode: expected vim or emacs, received " + mode)
} }
return 0
return c.Next(), nil
} }
/*
// runnerMode(mode) // runnerMode(mode)
// Sets the execution/runner mode for interactive Hilbish. This determines whether // Sets the execution/runner mode for interactive Hilbish. This determines whether
// Hilbish wll try to run input as Lua and/or sh or only do one of either. // Hilbish wll try to run input as Lua and/or sh or only do one of either.

17
go.mod
View File

@ -1,24 +1,31 @@
module hilbish module hilbish
go 1.16 go 1.17
require ( require (
github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86 github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86
github.com/blackfireio/osinfo v1.0.3
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036 github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
github.com/pborman/getopt v1.1.0 github.com/pborman/getopt v1.1.0
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
layeh.com/gopher-luar v1.0.10
mvdan.cc/sh/v3 v3.4.3 mvdan.cc/sh/v3 v3.4.3
) )
require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/arnodel/strftime v0.1.6 // indirect
github.com/evilsocket/islazy v1.10.6 // indirect
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
)
replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e
replace github.com/maxlandon/readline => ./readline replace github.com/maxlandon/readline => ./readline
replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.10 replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.10
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20220329005655-c29b74de7d20 replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20220329151031-261b8fbd3f78

26
go.sum
View File

@ -1,30 +1,13 @@
github.com/Rosettea/golua v0.0.0-20220329005655-c29b74de7d20 h1:i4XwNhWKlHP9+oHfpNandGsjj9XQG+uah+SdAjLknbc= github.com/Rosettea/golua v0.0.0-20220329151031-261b8fbd3f78 h1:9YuMWEHn85Av2ZF60OWkcha5Wt56+i6R7hRcHKB5how=
github.com/Rosettea/golua v0.0.0-20220329005655-c29b74de7d20/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE= github.com/Rosettea/golua v0.0.0-20220329151031-261b8fbd3f78/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/readline-1 v0.0.0-20220302012429-9ce5d23760f7 h1:LoY+kBKqMQqBcilRpVvifBTVve84asa3btpx3D/+IvM=
github.com/Rosettea/readline-1 v0.0.0-20220302012429-9ce5d23760f7/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/readline-1 v0.0.0-20220305004552-071c22768119 h1:rGsc30WTD5hk+oiXrAKsAIwZn5qBeTAdr29y3HhJh9E=
github.com/Rosettea/readline-1 v0.0.0-20220305004552-071c22768119/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/readline-1 v0.0.0-20220305123014-31d4d4214c93 h1:SmOkAEm3O7si8CURZSsSN0ZxCQ8IGiiulw8LMZ1V1Yc=
github.com/Rosettea/readline-1 v0.0.0-20220305123014-31d4d4214c93/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/readline-1 v0.1.0-beta.0.20211207003625-341c7985ad7d h1:KBttN41h/tPahmpaZavviwQ8q4rCkt5CD0HdVmfgPVA=
github.com/Rosettea/readline-1 v0.1.0-beta.0.20211207003625-341c7985ad7d/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/readline-1 v0.1.0-beta.0.20220228022904-61f5e4493011 h1:+a61iNamZiO3Xru+l/1qtpKqqltVfWEm2r/rxH9hXxY=
github.com/Rosettea/readline-1 v0.1.0-beta.0.20220228022904-61f5e4493011/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5 h1:ygwVRX8gf5MHA0VzSgOdscCEoAJLjM8joEotfQPgAd0=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e h1:P2XupP8SaylWaudD1DqbWtZ3mIa8OsE9635LmR+Q+lg= github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e h1:P2XupP8SaylWaudD1DqbWtZ3mIa8OsE9635LmR+Q+lg=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs= github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/arnodel/edit v0.0.0-20220202110212-dfc8d7a13890/go.mod h1:AcpttpuZBaL9xl8/CX+Em4fBTUbwIkJ66RiAsJlNrBk= github.com/arnodel/edit v0.0.0-20220202110212-dfc8d7a13890/go.mod h1:AcpttpuZBaL9xl8/CX+Em4fBTUbwIkJ66RiAsJlNrBk=
github.com/arnodel/golua v0.0.0-20220121091306-866962c51982/go.mod h1:d8hJbh/X80uQdSGMu5HZ64LrIgPh1jQxcNhnAqggpWE=
github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86 h1:pe4Q2R6Ei90ucm3m2CtzPh0SrThi/FgMyC46+Cb5Q9g=
github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw= github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw=
github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs= github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c=
github.com/blackfireio/osinfo v1.0.3/go.mod h1:Pd987poVNmd5Wsx6PRPw4+w7kLlf9iJxoRKPtPAjOrA=
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4= github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs= github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@ -46,8 +29,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/layeh/gopher-luar v1.0.10 h1:8NIv4MX1Arz96kK4buGK1D87DyDxKZyq6KKvJ2diHp0=
github.com/layeh/gopher-luar v1.0.10/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 h1:LiZB1h0GIcudcDci2bxbqI6DXV8bF8POAnArqvRrIyw= github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 h1:LiZB1h0GIcudcDci2bxbqI6DXV8bF8POAnArqvRrIyw=
@ -61,7 +42,6 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451 h1:d1PiN4RxzIFXCJTvRkvSkKqwtRAl5ZV4lATKtQI0B7I= github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451 h1:d1PiN4RxzIFXCJTvRkvSkKqwtRAl5ZV4lATKtQI0B7I=
github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw= github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw=
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
@ -72,8 +52,6 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210925032602-92d5a993a665/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210925032602-92d5a993a665/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 h1:BXxu8t6QN0G1uff4bzZzSkpsax8+ALqTGUtz08QrV00=
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

@ -1 +1 @@
Subproject commit 5a59d0f4543eb982593750c52f7393e2fd2d15f9 Subproject commit b362397a83e4516415c809c7d690b52e79a95f6e

View File

@ -57,9 +57,9 @@ const (
seqPosSave = "\x1b[s" seqPosSave = "\x1b[s"
seqPosRestore = "\x1b[u" seqPosRestore = "\x1b[u"
seqClearLineAfer = "\x1b[0k" seqClearLineAfer = "\x1b[0K"
seqClearLineBefore = "\x1b[1k" seqClearLineBefore = "\x1b[1K"
seqClearLine = "\x1b[2k" seqClearLine = "\x1b[2K"
seqClearScreenBelow = "\x1b[0J" seqClearScreenBelow = "\x1b[0J"
seqClearScreen = "\x1b[2J" // Clears screen fully seqClearScreen = "\x1b[2J" // Clears screen fully
seqCursorTopLeft = "\x1b[H" // Clears screen and places cursor on top-left seqCursorTopLeft = "\x1b[H" // Clears screen and places cursor on top-left

View File

@ -11,6 +11,7 @@ import (
// It also calculates the runes in the string as well as any non-printable escape codes. // It also calculates the runes in the string as well as any non-printable escape codes.
func (rl *Instance) SetPrompt(s string) { func (rl *Instance) SetPrompt(s string) {
rl.mainPrompt = s rl.mainPrompt = s
rl.computePrompt()
} }
// RefreshPromptLog - A simple function to print a string message (a log, or more broadly, // RefreshPromptLog - A simple function to print a string message (a log, or more broadly,
@ -68,7 +69,6 @@ func (rl *Instance) RefreshPromptLog(log string) (err error) {
// RefreshPromptInPlace - Refreshes the prompt in the very same place he is. // RefreshPromptInPlace - Refreshes the prompt in the very same place he is.
func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) {
// We adjust cursor movement, depending on which mode we're currently in. // We adjust cursor movement, depending on which mode we're currently in.
// Prompt data intependent // Prompt data intependent
if !rl.modeTabCompletion { if !rl.modeTabCompletion {
@ -82,7 +82,7 @@ func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) {
// Update the prompt if a special has been passed. // Update the prompt if a special has been passed.
if prompt != "" { if prompt != "" {
rl.mainPrompt = prompt rl.SetPrompt(prompt)
} }
if rl.Multiline { if rl.Multiline {
@ -137,7 +137,7 @@ func (rl *Instance) RefreshPromptCustom(prompt string, offset int, clearLine boo
// Update the prompt if a special has been passed. // Update the prompt if a special has been passed.
if prompt != "" { if prompt != "" {
rl.mainPrompt = prompt rl.SetPrompt(prompt)
} }
// Add a new line if needed // Add a new line if needed

View File

@ -23,6 +23,7 @@ func Document(L *lua.LState, module lua.LValue, doc string) {
// SetField sets a field in a table, adding docs for it. // SetField sets a field in a table, adding docs for it.
// It is accessible via the __docProp metatable. It is a table of the names of the fields. // It is accessible via the __docProp metatable. It is a table of the names of the fields.
func SetField(rtm *rt.Runtime, module *rt.Table, field string, value rt.Value, doc string) { func SetField(rtm *rt.Runtime, module *rt.Table, field string, value rt.Value, doc string) {
// TODO: ^ rtm isnt needed, i should remove it
mt := module.Metatable() mt := module.Metatable()
if mt == nil { if mt == nil {