Skip to content

Commit

Permalink
Merge pull request #12 from ttkzw/comments
Browse files Browse the repository at this point in the history
Fix comments.
  • Loading branch information
ttkzw authored Mar 20, 2024
2 parents 1dde0bf + 0a59030 commit 7fe02f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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.

0 comments on commit 7fe02f6

Please sign in to comment.