process

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ESCAPE_SEQUENCE     = '\x1b'
	SGR_FUNC            = byte('\x6d')
	ESCAPE_SEQUENCE_END = string(ESCAPE_SEQUENCE) + "[0" + string(SGR_FUNC)
)
View Source
const LINE_SPLIT = "\n"
View Source
const TAB_RUNE = '\t'

NOTE: Planning to make these rune process function available to be set from outside

Variables

View Source
var (
	SPACE_HODLER   = []byte(" ")
	SPACE_RUNEDATA = &RuneData{
		Byte: SPACE_HODLER,
	}
)
View Source
var EMPTY_ANSITABLELIST = make([]BoundsStruct, 0)
View Source
var TAB_BYTES = []byte{32, 32, 32, 32}

Functions

func CropView

func CropView(atablelist *ANSITableList, lines []*SubLine, x, y, width, height int) string

extract certain area of the given lines, and render ansi sequence

func IsEndOfSGR

func IsEndOfSGR(data []byte) bool

func IsEscEnd

func IsEscEnd(c rune) bool

func IsSGR

func IsSGR(data []byte) bool

func ProcessContent

func ProcessContent(s string) (*ANSITableList, []*SubLine)

separate ansi and normal string, separate lines into RuneData list

func Search(list []BoundsStruct, pos int) []int

func SliceFrom

func SliceFrom[S ~[]E, E comparable](src S, start, end int) S

if endIndex bigger than length, return copy of rest. mainly for cut slice easier

Types

type ANSIQueueItem

type ANSIQueueItem struct {
	// contains filtered or unexported fields
}

type ANSITable

type ANSITable struct {
	Sub   *ANSITable
	Data  []byte
	Bound [2]int // rune index
}

func (*ANSITable) AddStyle added in v0.1.4

func (a *ANSITable) AddStyle(data []byte, boundLeft int)

func (*ANSITable) Split added in v0.1.4

func (a *ANSITable) Split(index int) (*ANSITable, *ANSITable)

split ansi table given index(bounds), left: [:index] right: [index:]

type ANSITableList

type ANSITableList struct {
	L []BoundsStruct
}

func GetANSIs

func GetANSIs(s string) (*ANSITableList, string)

split `string with ansi` into `ansi sequences` and `raw string`

func (*ANSITableList) GetSlice

func (a *ANSITableList) GetSlice(startIndex, endIndex int) []BoundsStruct

get a slice of ansi table, it will find all tables between `startIndex` and `endIndex`

func (*ANSITableList) SetStyle added in v0.1.4

func (a *ANSITableList) SetStyle(style []byte, startIndex, endIndex int)

type BoundsStruct

type BoundsStruct interface {
	// contains filtered or unexported methods
}

type RuneData

type RuneData struct {
	Byte  []byte
	Bound [2]int // refers to the visible width
}

type RuneDataList

type RuneDataList struct {
	L          []BoundsStruct
	TotalWidth int
}

func (*RuneDataList) Init

func (r *RuneDataList) Init(s []rune) *RuneDataList

init RuneData list given runes

RuneDataList can only be set with this function, no more process allowed afterwards

type SubLine

type SubLine struct {
	Data  *RuneDataList
	Bound [2]int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL