Skip to content

Feature: allow dev to display color without printers #33

@dialex

Description

@dialex

Just like Jansi, using system.out.println and passing the generated code from our Ansi class, the dev should be able to print color without our printers. This is less prescriptive.

// (this is pseudocode)

Ansi.Attribute.RED_TEXT
Ansi.Attribute.YELLOW_BACK
Ansi.Attribute.BRIGHT


// option 1: simple format
AnsiFormat fError = new AnsiFormat(Attribute.RED_TEXT);
System.out.println(fError.format("This text will be red"));

// option 2: composite format
AnsiFormat fWarning = new AnsiFormat(Attribute.RED_TEXT, Attribute.YELLOW_BACK, Attribute.BRIGHT);
System.out.println(fWarning.format("This text will be bright red with yellow background"));

// option 3: inline format
System.out.println(Ansi.colorize("This text will be cyan", Attribute.CYAN_TEXT));


AnsiFormat.format("message") -> calls Ansi.colorize() with internal state
Ansi.colorize("message", Ansi.Attribute[1 or more]) -> String with AnsiCodes, ready for Sys.out
Ansi.makeItFabulous() -> alias to .colorize()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions