Compare commits
No commits in common. "01ec36c7b6c88c30b3e624eb6200759bb6d92c65" and "d2975303094669ba4a00de2f3fbe098ae4b2eef6" have entirely different histories.
01ec36c7b6
...
d297530309
@ -10,6 +10,8 @@ import (
|
|||||||
"git.portale-stac.it/go-pkg/golang"
|
"git.portale-stac.it/go-pkg/golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const varIntro = '$'
|
||||||
|
|
||||||
type ExpanderFunc func(ctx ExpanderContext, varValue string, args []string) (result string, err error)
|
type ExpanderFunc func(ctx ExpanderContext, varValue string, args []string) (result string, err error)
|
||||||
|
|
||||||
type ExpanderFuncBlock struct {
|
type ExpanderFuncBlock struct {
|
||||||
|
@ -17,18 +17,11 @@ const (
|
|||||||
// Flags symbols in the abova iota order
|
// Flags symbols in the abova iota order
|
||||||
const flagSymbols = "!=*"
|
const flagSymbols = "!=*"
|
||||||
|
|
||||||
const defaultVarIntro = '$'
|
|
||||||
|
|
||||||
|
|
||||||
type VariableHandler interface {
|
type VariableHandler interface {
|
||||||
Handle(varSpec string, flags ScannerFlag) (value string, err error)
|
Handle(varSpec string, flags ScannerFlag) (value string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Scan(handler VariableHandler, source string) (result string, err error) {
|
func Scan(handler VariableHandler, source string) (result string, err error) {
|
||||||
return ScanExt(defaultVarIntro, handler, source)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ScanExt(varIntro byte, handler VariableHandler, source string) (result string, err error) {
|
|
||||||
var spec, value string
|
var spec, value string
|
||||||
var flags ScannerFlag
|
var flags ScannerFlag
|
||||||
var backSlash bool
|
var backSlash bool
|
||||||
|
7
tty.go
7
tty.go
@ -26,18 +26,12 @@ func translateColor(name string) (c int) {
|
|||||||
c = 30
|
c = 30
|
||||||
case strings.HasPrefix("blue", norm):
|
case strings.HasPrefix("blue", norm):
|
||||||
c = 34
|
c = 34
|
||||||
case strings.HasPrefix("cyan", norm):
|
|
||||||
c = 36
|
|
||||||
case strings.HasPrefix("green", norm):
|
case strings.HasPrefix("green", norm):
|
||||||
c = 32
|
c = 32
|
||||||
case strings.HasPrefix("magenta", norm):
|
|
||||||
c = 35
|
|
||||||
case strings.HasPrefix("red", norm):
|
case strings.HasPrefix("red", norm):
|
||||||
c = 31
|
c = 31
|
||||||
case strings.HasPrefix("white", norm):
|
case strings.HasPrefix("white", norm):
|
||||||
c = 37
|
c = 37
|
||||||
case strings.HasPrefix("yellow", norm):
|
|
||||||
c = 33
|
|
||||||
default:
|
default:
|
||||||
c = -1
|
c = -1
|
||||||
}
|
}
|
||||||
@ -279,6 +273,7 @@ func Printf(templ string, args ...any) (int, error) {
|
|||||||
func Fprintf(w io.Writer, templ string, args ...any) (int, error) {
|
func Fprintf(w io.Writer, templ string, args ...any) (int, error) {
|
||||||
templ, _, _ = ToTtyStream(w, templ)
|
templ, _, _ = ToTtyStream(w, templ)
|
||||||
return fmt.Fprintf(w, templ, args...)
|
return fmt.Fprintf(w, templ, args...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// func DebugSprintf() {
|
// func DebugSprintf() {
|
||||||
|
Loading…
Reference in New Issue
Block a user