Swiftpack.co - Package - jdhealy/PrettyColors

PrettyColors

Carthage Compatibility Swift Package Manager Compatibility CocoaPods Version License Platform

Description

PrettyColors is a Swift library for styling and coloring text in the Terminal. The library outputs ANSI escape codes and conforms to ECMA Standard 48.

Example

import PrettyColors

let redText: String = Color.Wrap(foreground: .red).wrap("A red piece of text.")
println(redText)

Color.Wrap(foreground: .yellow, style: .bold)
Color.Wrap(foreground: .green, background: .black, style: .bold, .underlined)

// 8-bit (256) color support
Color.Wrap(foreground: 114)
Color.Wrap(foreground: 114, style: .bold)

More examples can be found in the tests.

Installation

Carthage

Add the following to your Cartfile:

github "jdhealy/PrettyColors"

CocoaPods

Add the following to your Podfile:

pod 'PrettyColors', :git => 'https://github.com/jdhealy/PrettyColors'

You will also need to make sure you're opting into using frameworks:

use_frameworks!

Then run pod install with CocoaPods 0.36 or newer.

Inspiration

License

PrettyColors is released under the MIT license. See LICENSE.md for details.

Github

link
Stars: 165

Dependencies

Used By

Total: 0

Releases

- 2019-03-25 06:02:12

Changelog · No Source Changes

  • Swift Package Manager: Additionally specify tools version of 4.0.

    Allows for compilation from Swift 5.0’s Package Manager, which has support stretching back accommodating this.

  • For CocoaPods, specify supported Swift versions.

Changes between 5.0.1 and 5.0.2.

v4.0.0: Swift 2.3 · Reduce to single framework target and single scheme · Support tvOS and watchOS - 2016-08-24 03:45:04

Notice: No breaking API changes! In fact, no Swift source file changes whatsoever!

This semantic versioning major version bump indicates the breaking — not of source compatibility API — but of project build setting API:

Changes between v3.0.2 and v4.0.0.

v3.0.2: Build Less Tests - 2016-04-03 13:16:11

Tests: Stop building test target for Run and Analyze actions.

Avoid unnecessary test builds and more closely match Xcode 7.3.0 new project build actions for test targets.

Changes between v3.0.1 and v3.0.2.

v3.0.1: Swift 2.2 Updates for Tests Only - 2016-04-01 18:00:43

v3.0.0: Swift 2.0 Support - 2015-09-16 18:47:16

v2.0.0: Swift 1.2 Support - 2015-04-14 18:27:17

Swift 1.2 support.

Notice: No breaking API changes!

While semantic versioning major changes usually indicate the breaking of public API, this major version increment is only intended to denote that the syntactical changes required by Swift 1.2 are backwards-incompatible with Swift 1.1 and earlier.

Changes between v1.0.0 and v2.0.0.

- 2015-02-02 22:24:28

Changelog

Conform Color.Wrap to MutableCollectionType.

Conform Color.Wrap to ArrayLiteralConvertable.

Conform Color.Wrap to Equality.

let one: Color.Wrap = [StyleParameter.Bold]
let two: [StyleParameter.Bold] as Color.Wrap
XCTAssert( one == two )

Remove Color.Wrap.add and SelectGraphicRenditionWrapType.add.

Previously:

Color.Wrap.add and SelectGraphicRenditionWrapType.add do not mutate their struct. They return a SelectGraphicRenditionWrapType value.

let red = Color.Wrap(foreground: .Red)
red.add(parameters: .Bold) // => SelectGraphicRenditionWrapType value
XCTAssert( red == Color.Wrap(foreground: .Red) )
XCTAssert( red != Color.Wrap(foreground: .Red, style: .Bold) )
var red = Color.Wrap(foreground: .Red)
red.add(parameters: .Bold) // => SelectGraphicRenditionWrapType value
XCTAssert( red == Color.Wrap(foreground: .Red) )
XCTAssert( red != Color.Wrap(foreground: .Red, style: .Bold) )

As of 1.0.0:

let red = Color.Wrap(foreground: .Red)
red + Color.Wrap(styles: .Bold) // => Color.Wrap value
// red.append(style: .Bold) /* prevented by compiler… */
XCTAssert( red == Color.Wrap(foreground: .Red) )
XCTAssert( red != Color.Wrap(foreground: .Red, style: .Bold) )
var red = Color.Wrap(foreground: .Red)
red.append(style: .Bold) // => ()
XCTAssert( red != Color.Wrap(foreground: .Red) )
XCTAssert( red == Color.Wrap(foreground: .Red, style: .Bold) )

More examples of the new syntax can be found in the tests….

Conform Color.Wrap to Equality.

Default to Array Equality, but add option of Set Equality.

Example

let one = Color.Wrap(styles: .Bold, .Italic)
let two = Color.Wrap(styles: .Italic, .Bold)
XCTAssert( !(one == two) )
XCTAssert( one != two )
XCTAssert( one.isEqual(to: two, equality: .Set) )
XCTAssert( !one.isEqual(to: two, equality: .Array) )

Semantic Versioning

Going forward, PrettyColors will follow Semantic Versioning: http://semver.org.

Thanks

MutableCollectionType conformance based off code from brynbellomy/SwiftDataStructures and brynbellomy/Funky.

Thanks to @brynbellomy