Compare commits

..

4 Commits

Author SHA1 Message Date
TorchedSammy 9d69b63a0f
chore: update golua (closes #142) 2022-04-19 14:37:57 -04:00
TorchedSammy b83c09a2b3
fix(readline): check stdin error properly 2022-04-19 10:30:04 -04:00
TorchedSammy bee8d6e9e6
fix(readline): input going to next line if its longer than terminal width 2022-04-18 22:42:27 -04:00
TorchedSammy 48cb62282d
fix(readline): input getting cut off on enter 2022-04-18 22:36:54 -04:00
4 changed files with 12 additions and 5 deletions

2
go.mod
View File

@ -28,4 +28,4 @@ replace github.com/maxlandon/readline => ./readline
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-20220406024702-f447a8095170
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20220419183026-6d22d6fec5ac

2
go.sum
View File

@ -1,5 +1,7 @@
github.com/Rosettea/golua v0.0.0-20220406024702-f447a8095170 h1:k2MAUwR1diHqqoFPEhxMKAQoz131tMSti8ArzCTg2HI=
github.com/Rosettea/golua v0.0.0-20220406024702-f447a8095170/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/golua v0.0.0-20220419183026-6d22d6fec5ac h1:dtXrgjch8PQyf7C90anZUquB5U3dr8AcMGJofeuirrI=
github.com/Rosettea/golua v0.0.0-20220419183026-6d22d6fec5ac/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
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/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=

View File

@ -2,6 +2,7 @@ package readline
import (
"bytes"
"errors"
"fmt"
"os"
"regexp"
@ -78,9 +79,7 @@ func (rl *Instance) Readline() (string, error) {
var err error
i, err = os.Stdin.Read(b)
if err != nil {
// i shouldnt really check the error like this but i dont know what
// the actual thing is so
if err.Error() == "read /dev/stdin: resource temporarily unavailable" {
if errors.Is(err, syscall.EAGAIN) {
err = syscall.SetNonblock(syscall.Stdin, false)
if err == nil {
continue
@ -868,6 +867,8 @@ func (rl *Instance) escapeSeq(r []rune) {
}
func (rl *Instance) carridgeReturn() {
rl.moveCursorByAdjust(len(rl.line))
rl.updateHelpers()
rl.clearHelpers()
print("\r\n")
if rl.HistoryAutoWrite {

View File

@ -47,6 +47,10 @@ func (rl *Instance) updateReferences() {
fullRest := toEndLine % GetTermWidth()
rl.fullX = fullRest
if fullRest == 0 && fullOffset > 0 {
print("\n")
}
// Use rl.pos value to get the offset to go TO/FROM the CURRENT POSITION
lineToCursorPos := rl.promptLen + cPosLine
offsetToCursor := lineToCursorPos / GetTermWidth()
@ -116,7 +120,7 @@ func (rl *Instance) renderHelpers() {
rl.getHintText()
rl.writeHintText()
} else if !rl.compConfirmWait {
// for the same reason above, do nothing here
// for the same reason above of wanting it below user input, do nothing here
} else {
rl.writeHintText()
}