2
3
spegling av https://github.com/sammy-ette/Hilbish synced 2025-08-10 02:52:03 +00:00

Jämför commits

..

No commits in common. "61c9e12a4af59fcdd5f7f9b746966febd6111d60" and "2fb481c4cbe44ec0cc99b7d07a29dc48b95fe016" have entirely different histories.

6 ändrade filer med 1 tillägg och 70 borttagningar

14
api.go
Visa fil

@ -28,7 +28,6 @@ var exports = map[string]lua.LGFunction {
"exec": hlexec,
"runnerMode": hlrunnerMode,
"goro": hlgoro,
"highlighter": hlhighlighter,
"hinter": hlhinter,
"multiprompt": hlmlprompt,
"prependPath": hlprependPath,
@ -518,16 +517,3 @@ func hlhinter(L *lua.LState) int {
return 0
}
// highlighter(cb)
// Sets the highlighter function. This is mainly for syntax hightlighting, but in
// reality could set the input of the prompt to display anything. The callback
// is passed the current line as typed and is expected to return a line that will
// be used to display in the line.
// --- @param cb function
func hlhighlighter(L *lua.LState) int {
highlighterCb := L.CheckFunction(1)
highlighter = highlighterCb
return 0
}

Visa fil

@ -16,11 +16,6 @@ exec(cmd) > Replaces running hilbish with `cmd`
goro(fn) > Puts `fn` in a goroutine
highlighter(cb) > Sets the highlighter function. This is mainly for syntax hightlighting, but in
reality could set the input of the prompt to display anything. The callback
is passed the current line as typed and is expected to return a line that will
be used to display in the line.
hinter(cb) > Sets the hinter function. This will be called on every key insert to determine
what text to use as an inline hint. The callback is passed 2 arguments:
the current line and the position. It is expected to return a string

Visa fil

@ -33,13 +33,6 @@ function hilbish.exec(cmd) end
--- @param fn function
function hilbish.goro(fn) end
--- Sets the highlighter function. This is mainly for syntax hightlighting, but in
--- reality could set the input of the prompt to display anything. The callback
--- is passed the current line as typed and is expected to return a line that will
--- be used to display in the line.
--- @param cb function
function hilbish.highlighter(cb) end
--- Sets the hinter function. This will be called on every key insert to determine
--- what text to use as an inline hint. The callback is passed 2 arguments:
--- the current line and the position. It is expected to return a string

Visa fil

@ -176,9 +176,3 @@ func (rl *Instance) deleteToBeginning() {
rl.line = rl.line[rl.pos:]
rl.pos = 0
}
func (rl *Instance) deleteToEnd() {
rl.resetVirtualComp(false)
// Keep everything before the cursor
rl.line = rl.line[:rl.pos]
}

Visa fil

@ -189,16 +189,6 @@ func (rl *Instance) Readline() (string, error) {
rl.resetHelpers()
rl.updateHelpers()
case charCtrlK:
if rl.modeTabCompletion {
rl.resetVirtualComp(true)
}
// Delete everything after the cursor position
rl.saveBufToRegister(rl.line[rl.pos:])
rl.deleteToEnd()
rl.resetHelpers()
rl.updateHelpers()
case charBackspace, charBackspace2:
// When currently in history completion, we refresh and automatically
// insert the first (filtered) candidate, virtually

29
rl.go
Visa fil

@ -13,8 +13,7 @@ type lineReader struct {
rl *readline.Instance
}
var fileHist *fileHistory
var hinter lua.LValue = lua.LNil
var highlighter lua.LValue = lua.LNil
var hinter lua.LValue
// other gophers might hate this naming but this is local, shut up
func newLineReader(prompt string, noHist bool) *lineReader {
@ -47,10 +46,6 @@ func newLineReader(prompt string, noHist bool) *lineReader {
hooks.Em.Emit("hilbish.vimAction", actionStr, args)
}
rl.HintText = func(line []rune, pos int) []rune {
if hinter == lua.LNil {
return []rune{}
}
err := l.CallByParam(lua.P{
Fn: hinter,
NRet: 1,
@ -69,28 +64,6 @@ func newLineReader(prompt string, noHist bool) *lineReader {
return []rune(hintText)
}
rl.SyntaxHighlighter = func(line []rune) string {
if highlighter == lua.LNil {
return string(line)
}
err := l.CallByParam(lua.P{
Fn: highlighter,
NRet: 1,
Protect: true,
}, lua.LString(string(line)))
if err != nil {
fmt.Println(err)
return string(line)
}
retVal := l.Get(-1)
highlighted := ""
if luaStr, ok := retVal.(lua.LString); retVal != lua.LNil && ok {
highlighted = luaStr.String()
}
return highlighted
}
rl.TabCompleter = func(line []rune, pos int, _ readline.DelayedTabContext) (string, []*readline.CompletionGroup) {
ctx := string(line)
var completions []string