Skip to content

ogios/ansisgr-process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ANSI SGR Process

Extract ANSI SGR Sequences from string

Note

Tab\t will be replaced by 4 spaces

Usage

  • Extract(string) -> (*ANSITableList, string)
    split string with ansi into ansi sequences and raw string
  • Render(atl *ANSITableList, _s string, startIndex int) -> []byte
    Render string with ansi sequences, startIndex is the start index of _s which will be used to fetch ansi table
  • Search(bs []BoundStruct, position int) -> (res []int)
    binary search index given Bound [2]int, the result is index.
    len(res) <= 2 and -1 means reach the start/end of the slice
    len(res) == 1 means the position is within bs[res[0]].Bounds
    len(res) == 2 means the position is between bs[res[0]].Bounds[1] and bs[res[1]].Bounds[0]
  • *ANSITableList SetStyle(style []byte, startIndex, endIndex int)
    set style for string[startIndex:endIndex]

About

terminal ANSI SGR sequences process

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages