Skip to content

mmng-a/swift-ansi-term

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Ansi Term

Usage

Color and Style

Like Object Oriented Programming

import AnsiTerm

let style = Style(foreground: .red, bold: true, blink: true)
let name = ANSIString("AnsiTerm!", style: style)
var style2 = style
style2.isBlinked = false
style2.foregroundColor = .blue
let hello = ANSIString("Hello, ", style: style2)
let strings: ANSIStrings = [hello, name]
print(strings)

Like Functional Programming

import AnsiTerm

let yellowBoldText = "You can use modifier"
	.foreground(.yellow)
	.bold()
print(yellowBoldText)

Cursor and Console

import AnsiTerm
import Foundation

print("Hello")
sleep(2)
Cursor.move(up: 1)
Cursor.move(backward: 5)
print("World")
sleep(2)
Cursor.move(up: 1)
Console.clearLine()

Example

Demo/main.swift is minimam example. I'll add more example.

Install

To use the AnsiTerm in a SwiftPM project, add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/masasam-shi/swift-ansi-term", from: "0.0.1"),

and include "AnsyTirm" as a dependency for your executable target:

.product(name: "AnsiTerm", package: "swift-ansi-term"),

About

Easy way to write color and styled text for Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages