mirror of
https://github.com/go-gitea/gitea
synced 2024-09-15 16:26:07 +00:00
1790f01dd9
* Upgrade xorm to v1.2.2 (#16663) Backport #16663 Fix #16683 * Add test to ensure that dumping of login sources remains correct (#16847) #16831 has occurred because of a missed regression. This PR adds a simple test to try to prevent this occuring again. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
69 lines
1.2 KiB
Go
Vendored
69 lines
1.2 KiB
Go
Vendored
package json
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/goccy/go-json/internal/encoder"
|
|
)
|
|
|
|
type (
|
|
ColorFormat = encoder.ColorFormat
|
|
ColorScheme = encoder.ColorScheme
|
|
)
|
|
|
|
const escape = "\x1b"
|
|
|
|
type colorAttr int
|
|
|
|
//nolint:deadcode,varcheck
|
|
const (
|
|
fgBlackColor colorAttr = iota + 30
|
|
fgRedColor
|
|
fgGreenColor
|
|
fgYellowColor
|
|
fgBlueColor
|
|
fgMagentaColor
|
|
fgCyanColor
|
|
fgWhiteColor
|
|
)
|
|
|
|
//nolint:deadcode,varcheck
|
|
const (
|
|
fgHiBlackColor colorAttr = iota + 90
|
|
fgHiRedColor
|
|
fgHiGreenColor
|
|
fgHiYellowColor
|
|
fgHiBlueColor
|
|
fgHiMagentaColor
|
|
fgHiCyanColor
|
|
fgHiWhiteColor
|
|
)
|
|
|
|
func createColorFormat(attr colorAttr) ColorFormat {
|
|
return ColorFormat{
|
|
Header: wrapColor(attr),
|
|
Footer: resetColor(),
|
|
}
|
|
}
|
|
|
|
func wrapColor(attr colorAttr) string {
|
|
return fmt.Sprintf("%s[%dm", escape, attr)
|
|
}
|
|
|
|
func resetColor() string {
|
|
return wrapColor(colorAttr(0))
|
|
}
|
|
|
|
var (
|
|
DefaultColorScheme = &ColorScheme{
|
|
Int: createColorFormat(fgHiMagentaColor),
|
|
Uint: createColorFormat(fgHiMagentaColor),
|
|
Float: createColorFormat(fgHiMagentaColor),
|
|
Bool: createColorFormat(fgHiYellowColor),
|
|
String: createColorFormat(fgHiGreenColor),
|
|
Binary: createColorFormat(fgHiRedColor),
|
|
ObjectKey: createColorFormat(fgHiCyanColor),
|
|
Null: createColorFormat(fgBlueColor),
|
|
}
|
|
)
|