mirror of https://github.com/Hilbis/Hilbish
docs: add hilbish.editor interface docs
parent
0357141fbc
commit
9a42d399f0
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
title: Interface hilbish.editor
|
||||
description: interactions for Hilbish's line reader
|
||||
layout: doc
|
||||
menu:
|
||||
docs:
|
||||
parent: "API"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
The hilbish.editor interface provides functions to
|
||||
directly interact with the line editor in use.
|
||||
|
||||
## Functions
|
||||
### getLine()
|
||||
Returns the current input line.
|
||||
|
||||
### getVimRegister(register)
|
||||
Returns the text that is at the register.
|
||||
|
||||
### insert(text)
|
||||
Inserts text into the line.
|
||||
|
||||
### setVimRegister(register, text)
|
||||
Sets the vim register at `register` to hold the passed text.
|
||||
|
16
editor.go
16
editor.go
|
@ -6,6 +6,10 @@ import (
|
|||
rt "github.com/arnodel/golua/runtime"
|
||||
)
|
||||
|
||||
// #interface editor
|
||||
// interactions for Hilbish's line reader
|
||||
// The hilbish.editor interface provides functions to
|
||||
// directly interact with the line editor in use.
|
||||
func editorLoader(rtm *rt.Runtime) *rt.Table {
|
||||
exports := map[string]util.LuaExport{
|
||||
"insert": {editorInsert, 1, false},
|
||||
|
@ -20,6 +24,9 @@ func editorLoader(rtm *rt.Runtime) *rt.Table {
|
|||
return mod
|
||||
}
|
||||
|
||||
// #interface editor
|
||||
// insert(text)
|
||||
// Inserts text into the line.
|
||||
func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -35,6 +42,9 @@ func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.Next(), nil
|
||||
}
|
||||
|
||||
// #interface editor
|
||||
// setVimRegister(register, text)
|
||||
// Sets the vim register at `register` to hold the passed text.
|
||||
func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -55,6 +65,9 @@ func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.Next(), nil
|
||||
}
|
||||
|
||||
// #interface editor
|
||||
// getVimRegister(register)
|
||||
// Returns the text that is at the register.
|
||||
func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -70,6 +83,9 @@ func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil
|
||||
}
|
||||
|
||||
// #interface editor
|
||||
// getLine()
|
||||
// Returns the current input line.
|
||||
func editorGetLine(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
buf := lr.rl.GetLine()
|
||||
|
||||
|
|
|
@ -22,6 +22,18 @@ function hilbish.completions.call(name, query, ctx, fields) end
|
|||
--- You can check the completions doc for more info.
|
||||
function hilbish.completions.handler(line, pos) end
|
||||
|
||||
--- Returns the current input line.
|
||||
function hilbish.editor.getLine() end
|
||||
|
||||
--- Returns the text that is at the register.
|
||||
function hilbish.editor.getVimRegister(register) end
|
||||
|
||||
--- Inserts text into the line.
|
||||
function hilbish.editor.insert(text) end
|
||||
|
||||
--- Sets the vim register at `register` to hold the passed text.
|
||||
function hilbish.editor.setVimRegister(register, text) end
|
||||
|
||||
--- Sets an alias of `cmd` to `orig`
|
||||
--- @param cmd string
|
||||
--- @param orig string
|
||||
|
|
Loading…
Reference in New Issue