feat: set prompts and input mode

readline-upstream
sammyette 2023-01-14 10:25:50 -04:00
parent 0b95c3ebbe
commit f053bb2c8a
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
4 changed files with 14 additions and 4 deletions

4
api.go
View File

@ -579,10 +579,10 @@ func hlinputMode(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
switch mode {
case "emacs":
unsetVimMode()
//lr.rl.InputMode = readline.Emacs
lr.rl.Config.InputMode = readline.Emacs
case "vim":
setVimMode("insert")
//lr.rl.InputMode = readline.Vim
lr.rl.Config.InputMode = readline.Vim
default:
return nil, errors.New("inputMode: expected vim or emacs, received " + mode)
}

4
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/blackfireio/osinfo v1.0.3
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/pborman/getopt v1.1.0
github.com/reeflective/readline v0.1.0-beta.0.20230108012254-bb995a76b5cd
golang.org/x/sys v0.3.0
golang.org/x/term v0.3.0
mvdan.cc/sh/v3 v3.5.1
@ -18,7 +19,6 @@ require (
github.com/evilsocket/islazy v1.10.6 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 // indirect
github.com/reeflective/readline v0.1.0-beta.0.20230108012254-bb995a76b5cd // indirect
github.com/reiver/go-caret v0.0.0-20190726191135-0ad7aa63f55f // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
@ -31,3 +31,5 @@ replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.2022052421562
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-20221213193027-cbf6d4e4d345
replace github.com/reeflective/readline => github.com/Rosettea/rl v0.0.0-20230109220413-32e3c6f4baaa

2
go.sum
View File

@ -6,6 +6,8 @@ github.com/Rosettea/golua v0.0.0-20220621002945-b05143999437 h1:6lWu4YVLeKuZ8jR9
github.com/Rosettea/golua v0.0.0-20220621002945-b05143999437/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/golua v0.0.0-20221213193027-cbf6d4e4d345 h1:QNYjYDogUSiNUkffbhFSrSCtpZhofeiVYGFN2FI4wSs=
github.com/Rosettea/golua v0.0.0-20221213193027-cbf6d4e4d345/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/rl v0.0.0-20230109220413-32e3c6f4baaa h1:48kPGi0HKC+iGwxwXLi6HeqeGj14zm5XYeyyD8VvFOo=
github.com/Rosettea/rl v0.0.0-20230109220413-32e3c6f4baaa/go.mod h1:zSJq1ZyoiM0vGRBaF0uan1jbnoF+6M2hgZnQDtV3MX4=
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.20220524215627-dfd9a4fa219b h1:s5eDMhBk6H1BgipgLub/gv9qeyBaTuiHM0k3h2/9TSE=

8
rl.go
View File

@ -191,6 +191,9 @@ func (lr *lineReader) Read() (string, error) {
}
func (lr *lineReader) SetPrompt(p string) {
lr.rl.Prompt.Primary(func() string {
return p
})
/*
halfPrompt := strings.Split(p, "\n")
if len(halfPrompt) > 1 {
@ -209,8 +212,11 @@ func (lr *lineReader) SetPrompt(p string) {
}
func (lr *lineReader) SetRightPrompt(p string) {
/*
lr.rl.Prompt.Right(func() string {
return p
})
/*
lr.rl.SetRightPrompt(p)
if initialized && !running {
lr.rl.RefreshPromptInPlace("")