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

Feature: refactor ANSI formatting into single class #28

Closed
dialex opened this issue Dec 20, 2019 · 1 comment · Fixed by #49
Closed

Feature: refactor ANSI formatting into single class #28

dialex opened this issue Dec 20, 2019 · 1 comment · Fixed by #49

Comments

@dialex
Copy link
Owner

dialex commented Dec 20, 2019

class AnsiCode {
  PREFIX
  SUFFIX
  SEPARATOR

  //builder pattern
  constructor().withTextColor(...).withBackColor(...).build()

  String generateCode() {
    //returns ansi escape code (for printing)
  }

  String generateEscapedCode() {
    //returns escaped ansi escape code (for unit tests and debugging)
  }
}

// NEW - creation
AnsiCode format = new AnsiCode().withTextColor(FColor.Red).build()
ColoredPrinter cp = new ColoredPrinter().withFormat(format).build()

// OLD - usage
//ColoredPrinter.println("message", Attr.Bold, FColor.Blue, BColor.Red)
// NEW
AnsiCode warning = new AnsiCode().withTextColor(FColor.Yellow).build()
ColoredPrinter.println("message", warning)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant