~mna/zzcsi

773d5a48696b1058945be581b3befb0ab1527fba — Martin Angers 1 year, 2 months ago 6b99075
doc and example
4 files changed, 36 insertions(+), 0 deletions(-)

M doc.go
A example_test.go
M go.mod
A go.sum
M doc.go => doc.go +17 -0
@@ 1,1 1,18 @@
// Package zztermcsi implements functions for the execution of Control Sequence
// Introducer (CSI) sequences on xterm-compatible terminals. The complete
// documentation of CSI functions is available at [1].
//
// Usage
//
// All CSI functions are represented by the CSI type and a corresponding constant.
// Call Func to get the byte sequence to write to the terminal to execute a
// given CSI function. FuncString is the same but returns a string that can be
// easily inserted e.g. in a fmt.Fprintf call (for example, to wrap some text
// in a bold or colored attribute before resetting it to normal).
//
// For efficient generation of CSI sequences, use AppendFunc to append the bytes
// to a caller-provided buffer.
//
//     [1]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
//
package zztermcsi // import "git.sr.ht/~mna/zztermcsi"

A example_test.go => example_test.go +15 -0
@@ 0,0 1,15 @@
package zztermcsi_test

import (
	"fmt"

	"git.sr.ht/~mna/zztermcsi"
)

func ExampleCSI_FuncString() {
	bold := zztermcsi.ChAttr.FuncString(zztermcsi.ChAttrBold)
	norm := zztermcsi.ChAttr.FuncString(zztermcsi.ChAttrNoBoldDim)
	blueBlink := zztermcsi.ChAttr.FuncString(zztermcsi.ChAttrFgBlue, zztermcsi.ChAttrBlink)
	defNoBlink := zztermcsi.ChAttr.FuncString(zztermcsi.ChAttrFgDef, zztermcsi.ChAttrNoBlink)
	fmt.Printf("%sHello%s, %sworld!%s\n", bold, norm, blueBlink, defNoBlink)
}

M go.mod => go.mod +2 -0
@@ 1,3 1,5 @@
module git.sr.ht/~mna/zztermcsi

go 1.14

require github.com/golang/example v0.0.0-20170904185048-46695d81d1fa

A go.sum => go.sum +2 -0
@@ 0,0 1,2 @@
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa h1:iqCQC2Z53KkwGgTN9szyL4q0OQHmuNjeoNnMT6lk66k=
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa/go.mod h1:tO/5UvQ/uKigUjQBPqzstj6uxd3fUIjddi19DxGJeWg=