mirror of https://github.com/Hilbis/Hilbish
feat: change multiline prompt via multiprompt function (closes #13)
parent
4c63009f56
commit
84d55a38b0
7
lua.go
7
lua.go
|
@ -25,6 +25,7 @@ func LuaInit() {
|
|||
l.SetGlobal("_ver", lua.LString(version))
|
||||
|
||||
l.SetGlobal("prompt", l.NewFunction(hshprompt))
|
||||
l.SetGlobal("multiprompt", l.NewFunction(hshmlprompt))
|
||||
l.SetGlobal("alias", l.NewFunction(hshalias))
|
||||
|
||||
// Add fs module to Lua
|
||||
|
@ -76,6 +77,12 @@ func hshprompt(L *lua.LState) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
func hshmlprompt(L *lua.LState) int {
|
||||
multilinePrompt = L.ToString(1)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func hshalias(L *lua.LState) int {
|
||||
alias := L.ToString(1)
|
||||
source := L.ToString(2)
|
||||
|
|
4
main.go
4
main.go
|
@ -21,6 +21,8 @@ const version = "0.3.0-dev"
|
|||
var l *lua.LState
|
||||
// User's prompt, this will get set when lua side is initialized
|
||||
var prompt string
|
||||
var multilinePrompt = "> "
|
||||
|
||||
// Map of builtin/custom commands defined in the commander lua module
|
||||
var commands = map[string]bool{}
|
||||
// Command aliases
|
||||
|
@ -113,7 +115,7 @@ func main() {
|
|||
}
|
||||
|
||||
func ContinuePrompt(prev string) (string, error) {
|
||||
fmt.Printf("> ")
|
||||
fmt.Print(multilinePrompt)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
|
|
Loading…
Reference in New Issue