newedit/core: Unexport Highlighter.

This commit is contained in:
Qi Xiao 2018-10-13 18:34:28 +01:00
parent 6a625751e2
commit 31a88b7ba4
2 changed files with 8 additions and 7 deletions

View File

@ -30,8 +30,9 @@ type Editor struct {
// that has been read.
AfterReadline func(string)
// Callback for highlighting the code the user has typed.
Highlighter Highlighter
// Callback for computing the highlight and errors of the code the user has
// typed.
Highlighter func(string) (styled.Text, []error)
// Left-hand and right-hand prompt.
Prompt, RPrompt Prompt
@ -204,11 +205,11 @@ func (ed *Editor) Notify(note string) {
ed.Redraw(false)
}
// Highlighter is the type of callbacks for highlighting code.
type Highlighter func(string) (styled.Text, []error)
// Callbacks for highlighting code.
type highlighter func(string) (styled.Text, []error)
// Calls the highlighter, falling back to no highlighting if hl is nil.
func (hl Highlighter) call(code string) (styled.Text, []error) {
func (hl highlighter) call(code string) (styled.Text, []error) {
if hl == nil {
return styled.Unstyled(code), nil
}

View File

@ -16,7 +16,7 @@ type renderSetup struct {
prompt styled.Text
rprompt styled.Text
highlighter Highlighter
highlighter highlighter
initMode types.Mode
}
@ -46,7 +46,7 @@ func render(st *types.RawState, r *renderSetup) (notes, main *ui.Buffer) {
var transformerForPending = "underline"
func prepareCode(code string, dot int, pending *types.PendingCode, hl Highlighter) (
func prepareCode(code string, dot int, pending *types.PendingCode, hl highlighter) (
styledCode styled.Text, newDot int, errors []error) {
newDot = dot