Skip to content

feat: Function to set the printer features #14

Description

@chr45

Describe the feature request

You could add a function for Custom coloring

Example:

func CustomColoring(foreground string, background string, s any, bold bool, underline bool) string {
	b, u := "", ""
	if bold {
		b = Bold
	}
	if underline {
		u = Underline
	}
	return Colorize(b+u+foreground+background, s)
}

Usage:

log.Println(color.CustomColoring(color.White, color.Black, s, false, false))
log.Println(color.CustomColoring(color.White, color.Black, s, true, false))
log.Println(color.CustomColoring(color.White, color.Black, s, false, true))
log.Println(color.CustomColoring(color.Black, color.White, s, true, true))

or

func CustomColoring(foreground string, background string, s any, bold string, underline string) string {
	return Colorize(bold+underline+foreground+background, s)
}

Usage:

log.Println(color.CustomColoring(color.White, color.Black, s, "", ""))
log.Println(color.CustomColoring(color.White, color.Black, s, color.Bold, ""))
log.Println(color.CustomColoring(color.White, color.Black, s, "", color.Underline))
log.Println(color.CustomColoring(color.Black, color.White, s, color.Bold, color.Underline))

Result:

Screenshot from 2023-01-06 14-14-16

Why do you personally want this feature to be implemented?

I already implemented

How long have you been using this project?

one year

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions