Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments. #12

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions color.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const (

var terminalDetection = true

// Color is a color for output.
// Color is a color that handles ANSI escape sequences.
type Color int

// NewColor creates the Color.
// NewColor creates a Color.
func NewColor(name string) (Color, error) {
for i, v := range colorNames {
if strings.EqualFold(v, name) {
Expand All @@ -60,7 +60,7 @@ func (c Color) escapeSequence() string {
return strings.Join([]string{csi, c.parameter(), sgr_end_char}, "")
}

// Colorize colors the string with the foreground color.
// Colorize returns the string with the foreground color.
func (c Color) Colorize(str string) string {
if terminalDetection && !isatty.IsTerminal(os.Stdout.Fd()) {
return str
Expand All @@ -71,7 +71,7 @@ func (c Color) Colorize(str string) string {
// BackgroundColor is a background color for output.
type BackgroundColor int

// NewBackgroundColor creates the BackgroundColor.
// NewBackgroundColor creates a BackgroundColor.
func NewBackgroundColor(name string) (BackgroundColor, error) {
for i, v := range backgroundColorNames {
if strings.EqualFold(v, name) {
Expand All @@ -98,7 +98,7 @@ func (c BackgroundColor) escapeSequence() string {
return strings.Join([]string{csi, c.parameter(), sgr_end_char}, "")
}

// Colorize colors the string with the background color.
// Colorize returns the string with the background color.
func (c BackgroundColor) Colorize(str string) string {
if terminalDetection && !isatty.IsTerminal(os.Stdout.Fd()) {
return str
Expand All @@ -118,17 +118,17 @@ func SupportedColors() []Color {
return colors
}

// ColorizeForeground colors the string with the foreground color.
// ColorizeForeground returns the string with the foreground color.
func ColorizeForeground(str string, foreground Color) string {
return foreground.Colorize(str)
}

// ColorizeBackground colors the string with the background color.
// ColorizeBackground returns the string with the background color.
func ColorizeBackground(str string, background BackgroundColor) string {
return background.Colorize(str)
}

// Colorize colors the string with foreground and background colors.
// Colorize returns the string with foreground and background colors.
func Colorize(str string, foreground Color, background BackgroundColor) string {
if terminalDetection && !isatty.IsTerminal(os.Stdout.Fd()) {
return str
Expand Down
2 changes: 1 addition & 1 deletion gen_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var templateCode = `// Copyright 2021-2024 Takashi Takizawa. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Code generated by running \"go generate\" in github.com/ttkzw/go-color. DO NOT EDIT.
// Code generated by running go generate in github.com/ttkzw/go-color. DO NOT EDIT.

package color

Expand Down
2 changes: 1 addition & 1 deletion tables.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading