feat(hilbish.editor): add getLine function to get contents of line

pull/194/head
TorchedSammy 2022-07-19 17:55:03 -04:00
parent 09a8b41063
commit 3e0a2d630b
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
3 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@ func editorLoader(rtm *rt.Runtime) *rt.Table {
"insert": {editorInsert, 1, false}, "insert": {editorInsert, 1, false},
"setVimRegister": {editorSetRegister, 1, false}, "setVimRegister": {editorSetRegister, 1, false},
"getVimRegister": {editorGetRegister, 2, false}, "getVimRegister": {editorGetRegister, 2, false},
"getLine": {editorGetLine, 0, false},
} }
mod := rt.NewTable() mod := rt.NewTable()
@ -68,3 +69,9 @@ func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil
} }
func editorGetLine(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
buf := lr.rl.GetLine()
return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil
}

View File

@ -18,7 +18,7 @@ func (rl *Instance) updateLine(line []rune) {
// getLine - In many places we need the current line input. We either return the real line, // getLine - In many places we need the current line input. We either return the real line,
// or the one that includes the current completion candidate, if there is any. // or the one that includes the current completion candidate, if there is any.
func (rl *Instance) getLine() []rune { func (rl *Instance) GetLine() []rune {
if len(rl.currentComp) > 0 { if len(rl.currentComp) > 0 {
return rl.lineComp return rl.lineComp
} }

View File

@ -24,7 +24,7 @@ func delayedSyntaxTimer(rl *Instance, i int64) {
// } // }
// We pass either the current line or the one with the current completion. // We pass either the current line or the one with the current completion.
newLine := rl.DelayedSyntaxWorker(rl.getLine()) newLine := rl.DelayedSyntaxWorker(rl.GetLine())
var sLine string var sLine string
count := atomic.LoadInt64(&rl.delayedSyntaxCount) count := atomic.LoadInt64(&rl.delayedSyntaxCount)
if count != i { if count != i {