Compare commits

..

4 Commits

Author SHA1 Message Date
TorchedSammy 237bc19f68
fix: prompt handling 2022-03-04 21:16:45 -04:00
TorchedSammy 63e33af34d
chore: update readline 2022-03-04 20:48:22 -04:00
TorchedSammy d7f10b0247 docs: [ci] generate new docs 2022-03-04 18:41:22 +00:00
TorchedSammy 99461e42d0
fix: export hilbish.goro (closes #98) 2022-03-04 14:40:54 -04:00
5 changed files with 9 additions and 7 deletions

3
api.go
View File

@ -25,6 +25,7 @@ var exports = map[string]lua.LGFunction {
"appendPath": hlappendPath, "appendPath": hlappendPath,
"cwd": hlcwd, "cwd": hlcwd,
"exec": hlexec, "exec": hlexec,
"goro": hlgoro,
"multiprompt": hlmlprompt, "multiprompt": hlmlprompt,
"prependPath": hlprependPath, "prependPath": hlprependPath,
"prompt": hlprompt, "prompt": hlprompt,
@ -265,7 +266,7 @@ func hlexec(L *lua.LState) int {
// goro(fn) // goro(fn)
// Puts `fn` in a goroutine // Puts `fn` in a goroutine
// --- @param fn function // --- @param fn function
func hlgoroutine(L *lua.LState) int { func hlgoro(L *lua.LState) int {
fn := L.CheckFunction(1) fn := L.CheckFunction(1)
argnum := L.GetTop() argnum := L.GetTop()
args := make([]lua.LValue, argnum) args := make([]lua.LValue, argnum)

View File

@ -29,7 +29,7 @@ function hilbish.exec(cmd) end
--- Puts `fn` in a goroutine --- Puts `fn` in a goroutine
--- @param fn function --- @param fn function
function hilbish.goroutine(fn) end function hilbish.goro(fn) end
--- 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

2
go.mod
View File

@ -16,6 +16,6 @@ require (
replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5 replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5
replace github.com/maxlandon/readline => github.com/Rosettea/readline-1 v0.0.0-20220302012429-9ce5d23760f7 replace github.com/maxlandon/readline => github.com/Rosettea/readline-1 v0.0.0-20220305004552-071c22768119
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

2
go.sum
View File

@ -1,5 +1,7 @@
github.com/Rosettea/readline-1 v0.0.0-20220302012429-9ce5d23760f7 h1:LoY+kBKqMQqBcilRpVvifBTVve84asa3btpx3D/+IvM= 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-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.1.0-beta.0.20211207003625-341c7985ad7d h1:KBttN41h/tPahmpaZavviwQ8q4rCkt5CD0HdVmfgPVA= 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.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 h1:+a61iNamZiO3Xru+l/1qtpKqqltVfWEm2r/rxH9hXxY=

7
rl.go
View File

@ -217,13 +217,12 @@ func (lr *lineReader) Read() (string, error) {
func (lr *lineReader) SetPrompt(prompt string) { func (lr *lineReader) SetPrompt(prompt string) {
halfPrompt := strings.Split(prompt, "\n") halfPrompt := strings.Split(prompt, "\n")
if len(halfPrompt) > 1 { if len(halfPrompt) > 1 {
lr.rl.Multiline = true
lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n")) lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n"))
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0] lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} else { } else {
// print cursor up ansi code lr.rl.Multiline = false
//fmt.Printf("\033[1A") lr.rl.SetPrompt(prompt)
lr.rl.SetPrompt("")
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} }
if !running { if !running {
lr.rl.RefreshPromptInPlace("") lr.rl.RefreshPromptInPlace("")