Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Refactor and enhance the external api of printer-ansi (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored Nov 29, 2023
1 parent ad68412 commit 124da70
Show file tree
Hide file tree
Showing 33 changed files with 2,481 additions and 754 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-coats-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/printer-ansi": minor
---

refactor and enhance the external api of printer-ansi
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
{
config: {
"indentWidth": 2,
"lineWidth": 120,
"lineWidth": 100,
"semiColons": "asi",
"quoteStyle": "alwaysDouble",
"trailingCommas": "never",
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

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

42 changes: 15 additions & 27 deletions packages/printer-ansi/examples/main.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import * as AnsiRender from "@effect/printer-ansi/AnsiRender"
import * as AnsiStyle from "@effect/printer-ansi/AnsiStyle"
import * as Color from "@effect/printer-ansi/Color"
import * as Doc from "@effect/printer/Doc"
import * as Ansi from "@effect/printer-ansi/Ansi"
import * as Doc from "@effect/printer-ansi/AnsiDoc"

const doc = Doc.annotate(
Doc.hsep([
Doc.text("red"),
Doc.align(
Doc.vsep([
Doc.annotate(
Doc.hsep([
Doc.text("blue+u"),
Doc.annotate(
Doc.text("bold"),
AnsiStyle.combine(AnsiStyle.color(Color.blue), AnsiStyle.bold)
),
Doc.text("blue+u")
]),
AnsiStyle.combine(AnsiStyle.color(Color.blue), AnsiStyle.underlined)
),
Doc.text("red")
])
)
]),
AnsiStyle.color(Color.red)
)
console.log(AnsiRender.prettyDefault(doc))
const doc = Doc.hsep([
Doc.text("red"),
Doc.align(Doc.vsep([
Doc.hsep([
Doc.text("blue+u"),
Doc.text("bold").pipe(Doc.annotate(Ansi.bold)),
Doc.text("blue+u")
]).pipe(Doc.annotate(Ansi.combine(Ansi.blue, Ansi.underlined))),
Doc.text("red")
]))
]).pipe(Doc.annotate(Ansi.red))

console.log(Doc.render(doc, { style: "pretty" }))
Loading

0 comments on commit 124da70

Please sign in to comment.