Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToRunes(bs []byte) []rune
- func CharWidth(r rune) int
- func CharWidthIn(r rune, index int) int
- func RunesToBytes(rs []rune) []byte
- func StringWidth(s string) int
- type ByHighlight
- type ByLineContextLine
- type Context
- type FileContext
- type Highlight
- type LineContent
- func (l *LineContent) EOLBytes() []byte
- func (l *LineContent) Length() int
- func (l *LineContent) Mark(start int, end int) *Context
- func (l *LineContent) MarkLine(start int, end int) *LineContext
- func (l *LineContent) Rune(n int) rune
- func (l *LineContent) String() string
- func (l *LineContent) ToLineContext(file *FileContext) *LineContext
- type LineContext
- func (l *LineContext) Duplicate() *LineContext
- func (l *LineContext) HighlighText(format string, args ...any) string
- func (l *LineContext) HighlighTextWith(indicator string, format string, args ...any) string
- func (l *LineContext) HighlightColour(colour color.Color, format string, args ...any) string
- func (l *LineContext) IsSameLine(other *LineContext) bool
- func (l *LineContext) Join(lctxs ...*LineContext) *LineContext
- func (l *LineContext) Last() int
- func (l *LineContext) Length() int
- func (l *LineContext) LineNumber() string
- func (l *LineContext) Mark(start int, end int) *Context
- func (l *LineContext) MarkLine(start int, end int) *LineContext
- func (l *LineContext) Rune(n int) (rune, bool)
- func (l *LineContext) String() string
- func (l *LineContext) StringContent() string
- func (l *LineContext) ToContext() *Context
Constants ¶
View Source
const ( FixedLeadingSpace = " " DefaultIndicator = "^" NoHighlightMessage = "" )
Variables ¶
View Source
var ( EolCR = []byte{'\r'} EolLF = []byte{'\n'} EolCRLF = []byte{'\r', '\n'} )
Functions ¶
func BytesToRunes ¶
func CharWidthIn ¶
func RunesToBytes ¶
func StringWidth ¶
Types ¶
type ByHighlight ¶
type ByHighlight []Highlight
func (ByHighlight) Len ¶
func (a ByHighlight) Len() int
func (ByHighlight) Less ¶
func (a ByHighlight) Less(i, j int) bool
func (ByHighlight) Swap ¶
func (a ByHighlight) Swap(i, j int)
type ByLineContextLine ¶
type ByLineContextLine []*LineContext
func (ByLineContextLine) Len ¶
func (a ByLineContextLine) Len() int
func (ByLineContextLine) Less ¶
func (a ByLineContextLine) Less(i, j int) bool
func (ByLineContextLine) Swap ¶
func (a ByLineContextLine) Swap(i, j int)
type Context ¶
type Context struct { File *FileContext PrevLines []*LineContext NextLines []*LineContext Lines []*LineContext }
func (*Context) HighlightTextWith ¶
type FileContext ¶
type FileContext struct { Filename string Contents []*LineContent }
func ReadFile ¶
func ReadFile(filename string) (*FileContext, error)
func ReadFileData ¶
func ReadFileData(filename string, data []byte) *FileContext
func (*FileContext) Line ¶
func (f *FileContext) Line(n int) *LineContent
func (*FileContext) LineContext ¶
func (f *FileContext) LineContext(n int) *LineContext
func (*FileContext) Lines ¶
func (f *FileContext) Lines() int
type Highlight ¶
func NewHighlight ¶
type LineContent ¶
func NewLineFromBytes ¶
func NewLineFromBytes(line int, data []byte, eol []byte) LineContent
func (*LineContent) EOLBytes ¶
func (l *LineContent) EOLBytes() []byte
func (*LineContent) Length ¶
func (l *LineContent) Length() int
func (*LineContent) MarkLine ¶
func (l *LineContent) MarkLine(start int, end int) *LineContext
func (*LineContent) Rune ¶
func (l *LineContent) Rune(n int) rune
func (*LineContent) String ¶
func (l *LineContent) String() string
func (*LineContent) ToLineContext ¶
func (l *LineContent) ToLineContext(file *FileContext) *LineContext
type LineContext ¶
type LineContext struct { Content *LineContent File *FileContext Highlights []Highlight }
func FindLineContextSameLine ¶
func FindLineContextSameLine(list []*LineContext, lctx *LineContext) *LineContext
func (*LineContext) Duplicate ¶
func (l *LineContext) Duplicate() *LineContext
func (*LineContext) HighlighText ¶
func (l *LineContext) HighlighText(format string, args ...any) string
func (*LineContext) HighlighTextWith ¶
func (l *LineContext) HighlighTextWith(indicator string, format string, args ...any) string
func (*LineContext) HighlightColour ¶
func (*LineContext) IsSameLine ¶
func (l *LineContext) IsSameLine(other *LineContext) bool
func (*LineContext) Join ¶
func (l *LineContext) Join(lctxs ...*LineContext) *LineContext
func (*LineContext) Last ¶
func (l *LineContext) Last() int
func (*LineContext) Length ¶
func (l *LineContext) Length() int
func (*LineContext) LineNumber ¶
func (l *LineContext) LineNumber() string
func (*LineContext) MarkLine ¶
func (l *LineContext) MarkLine(start int, end int) *LineContext
func (*LineContext) String ¶
func (l *LineContext) String() string
func (*LineContext) StringContent ¶
func (l *LineContext) StringContent() string
func (*LineContext) ToContext ¶
func (l *LineContext) ToContext() *Context
Click to show internal directories.
Click to hide internal directories.