glhd/ansipants

0.0.2 2024-04-18 19:03 UTC

This package is auto-updated.

Last update: 2024-11-18 20:35:26 UTC


README

Build Status Coverage Status Latest Stable Release MIT Licensed Follow @inxilpro on Twitter

ANSI Pants 👖💫

Installation

composer require glhd/ansipants

Usage

You can instantiate a new ANSI string using the ansi() helper, with new AnsiString(), or with AnsiString::make(). All string manipulation functions can be chained, just like the Laravel Stringable class. Where appropriate, you can pass an additional ignore_style: true argument into a function to make that function ignore the ANSI styles that are applied (like color or font style).

An example:

ansi("\e[1mHello💥 \e[3mwo\e[0mrld")
  ->append(" 🥸🥸🥸")
  ->padLeft(100)
  ->wordwrap();

Stringable Macro

You can also create an ANSI string from any Stringable object:

Str::of("\e[1mHello💥 \e[3mwo\e[0mrld")->ansi();
// Or
str("\e[1mHello💥 \e[3mwo\e[0mrld")->ansi();

Resources