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("_ver", lua.LString(version))
|
||||||
|
|
||||||
l.SetGlobal("prompt", l.NewFunction(hshprompt))
|
l.SetGlobal("prompt", l.NewFunction(hshprompt))
|
||||||
|
l.SetGlobal("multiprompt", l.NewFunction(hshmlprompt))
|
||||||
l.SetGlobal("alias", l.NewFunction(hshalias))
|
l.SetGlobal("alias", l.NewFunction(hshalias))
|
||||||
|
|
||||||
// Add fs module to Lua
|
// Add fs module to Lua
|
||||||
|
@ -76,6 +77,12 @@ func hshprompt(L *lua.LState) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hshmlprompt(L *lua.LState) int {
|
||||||
|
multilinePrompt = L.ToString(1)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func hshalias(L *lua.LState) int {
|
func hshalias(L *lua.LState) int {
|
||||||
alias := L.ToString(1)
|
alias := L.ToString(1)
|
||||||
source := L.ToString(2)
|
source := L.ToString(2)
|
||||||
|
|
4
main.go
4
main.go
|
@ -21,6 +21,8 @@ const version = "0.3.0-dev"
|
||||||
var l *lua.LState
|
var l *lua.LState
|
||||||
// User's prompt, this will get set when lua side is initialized
|
// User's prompt, this will get set when lua side is initialized
|
||||||
var prompt string
|
var prompt string
|
||||||
|
var multilinePrompt = "> "
|
||||||
|
|
||||||
// Map of builtin/custom commands defined in the commander lua module
|
// Map of builtin/custom commands defined in the commander lua module
|
||||||
var commands = map[string]bool{}
|
var commands = map[string]bool{}
|
||||||
// Command aliases
|
// Command aliases
|
||||||
|
@ -113,7 +115,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContinuePrompt(prev string) (string, error) {
|
func ContinuePrompt(prev string) (string, error) {
|
||||||
fmt.Printf("> ")
|
fmt.Print(multilinePrompt)
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
|
2
shell.go
2
shell.go
|
@ -162,7 +162,7 @@ func StartMultiline(prev string, sb *strings.Builder) bool {
|
||||||
// save input from previous prompts
|
// save input from previous prompts
|
||||||
if sb.String() == "" { sb.WriteString(prev + "\n") }
|
if sb.String() == "" { sb.WriteString(prev + "\n") }
|
||||||
|
|
||||||
fmt.Printf("sh> ")
|
fmt.Print(multilinePrompt)
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue