From 31a88b7ba4eeef416d9e3bf726d283878cc3bfd0 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Sat, 13 Oct 2018 18:34:28 +0100 Subject: [PATCH] newedit/core: Unexport Highlighter. --- newedit/core/editor.go | 11 ++++++----- newedit/core/render.go | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/newedit/core/editor.go b/newedit/core/editor.go index 280e671e..92611b5c 100644 --- a/newedit/core/editor.go +++ b/newedit/core/editor.go @@ -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 } diff --git a/newedit/core/render.go b/newedit/core/render.go index 512d72da..93408c6f 100644 --- a/newedit/core/render.go +++ b/newedit/core/render.go @@ -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