{"id":20544158,"url":"https://github.com/flintprocessor/ansiescapecode","last_synced_at":"2025-04-14T09:52:40.765Z","repository":{"id":63910094,"uuid":"133406910","full_name":"flintprocessor/ANSIEscapeCode","owner":"flintprocessor","description":"ANSI Escape Code. Build modern, interactive command line tool with colorful and dynamic output strings.","archived":false,"fork":false,"pushed_at":"2022-03-30T09:00:20.000Z","size":63,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T11:55:37.976Z","etag":null,"topics":["cli","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flintprocessor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-14T18:46:25.000Z","updated_at":"2024-07-17T06:51:52.000Z","dependencies_parsed_at":"2022-11-29T07:09:30.192Z","dependency_job_id":null,"html_url":"https://github.com/flintprocessor/ANSIEscapeCode","commit_stats":null,"previous_names":["flintbox/ansiescapecode"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FANSIEscapeCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FANSIEscapeCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FANSIEscapeCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FANSIEscapeCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flintprocessor","download_url":"https://codeload.github.com/flintprocessor/ANSIEscapeCode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860020,"owners_count":21173339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","swift","swift-package-manager"],"created_at":"2024-11-16T01:42:43.934Z","updated_at":"2025-04-14T09:52:40.741Z","avatar_url":"https://github.com/flintprocessor.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"/Assets/logo.png\" width=\"600\" /\u003e\u003c/div\u003e\n\u003ch1 align=\"center\"\u003e\n  \u003cb\u003eANSIEscapeCode\u003c/b\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/flintbox/ANSIEscapeCode/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/flintbox/ANSIEscapeCode.svg\" alt=\"GitHub release\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://swift.org/package-manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift%20PM-compatible-orange.svg\" alt=\"Swift Package Manager\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/flintbox/ANSIEscapeCode/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\" alt=\"license\" /\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n*Control terminal **cursor** and **font** or **erase content**. Build modern, interactive command line tool with **colorful** and **dynamic** output strings.*\n\n*https://en.wikipedia.org/wiki/ANSI_escape_code*\n\n**Table of Contents**\n- [Installation](#installation)\n- [Cursor](#cursor)\n  - [Up](#up)\n  - [Down](#down)\n  - [Forward](#forward)\n  - [Backward](#backward)\n  - [Next Line](#next-line)\n  - [Previous Line](#previous-line)\n  - [Column](#column)\n  - [Position](#position)\n  - [Save Position](#save-position)\n  - [Restore Position](#restore-position)\n  - [Hide](#hide)\n  - [Show](#show)\n- [Erase](#erase)\n  - [Erase in Display](#erase-in-display)\n  - [Erase in Line](#erase-in-line)\n- [Scroll](#scroll)\n  - [Scroll Up](#scroll-up)\n  - [Scroll Down](#scroll-down)\n- [Decoration](#decoration)\n  - [Reset](#reset)\n  - [Reset Background Color](#reset-background-color)\n  - [Bold](#bold)\n  - [Italic](#italic)\n  - [Underline](#underline)\n  - [Blink](#blink)\n  - [Text Color](#text-color)\n  - [Text Color 8 bits](#text-color-8-bits)\n  - [Text RGB Color](#text-rgb-color)\n  - [Background Color](#background-color)\n  - [Background Color 8 bits](#background-color-8-bits)\n  - [Background RGB Color](#background-rgb-color)\n- [Contribute](#contribute)\n\n## Installation\n\nAdd ANSIEscapeCode to `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/flintbox/ANSIEscapeCode\", from: \"0.1.1\")\n]\n```\n\n## Cursor\n\n### Up\n\n`\\u{001B}[(n)A`: Move cursor up `n` (default 1) cells.\n\n```swift\nANSIEscapeCode.Cursor.up(3) // \\u{001B}[3A\nmoveCursorUp() /// Move cursor up 1 cell.\n```\n\n### Down\n\n`\\u{001B}[(n)B`: Move cursor down `n` (default 1) cells.\n\n```swift\nANSIEscapeCode.Cursor.down() // \\u{001B}[1B\nmoveCursorDown(5) /// Move cursor down 5 cells.\n```\n\n### Forward\n\n`\\u{001B}[(n)C`: Move cursor forward `n` (default 1) cells.\n\n```swift\nANSIEscapeCode.Cursor.forward(9) // \\u{001B}[9C\nmoveCursorForward(4) // Move cursor forward 4 cells.\n```\n\n### Backward\n\n`\\u{001B}[(n)D`: Move cursor backward `n` (default 1) cells.\n\n```swift\nANSIEscapeCode.Cursor.backward() // \\u{001B}[1D\nmoveCursorBackward(2) // Move cursor backward 2 cells.\n```\n\n### Next Line\n\n`\\u{001B}[(n)E`: Move cursor to beginning of the line `n` (default 1) lines down.\n\n```swift\nANSIEscapeCode.Cursor.nextLine(2) // \\u{001B}[2E\nmoveCursorNextLine() // Move cursor to next line.\n```\n\n### Previous Line\n\n`\\u{001B}[(n)F`: Move cursor to beginning of the line `n` (default 1) lines up.\n\n```swift\nANSIEscapeCode.Cursor.previousLine(3) // \\u{001B}[3F\nmoveCursorPreviousLine(5) // Move cursor to next line 5 times.\n```\n\n### Column\n\n`\\u{001B}[(n)G`: Move cursor to column `n`.\n\n```swift\nANSIEscapeCode.Cursor.column(2) // \\u{001B}[2G\nmoveCursorToColumn(2) // Move cursor to second column.\n```\n\n### Position\n\n`\\u{001B}[(n);(m)1H`: Move cursor to row `n`, column `m`.\n\n```swift\nANSIEscapeCode.Cursor.position(row: 1, column: 1) // \\u{001B}[1;1H\nmoveCursorToPosition(row: 5, column: 10) // Move cursor to position row 5 and column 10.\n```\n\n### Save Position\n\n`\\u{001B}[s`: Save cursor position.\n\n```swift\nANSIEscapeCode.Cursor.saveCursorPosition // \\u{001B}[s\nsaveCursorPosition() // Save cursor position.\n```\n\n### Restore Position\n\n`\\u{001B}[u`: Restore cursor position.\n\n```swift\nANSIEscapeCode.Cursor.restoreCursorPosition // \\u{001B}[u\nrestoreCursorPosition() // Restore cursor position.\n```\n\n### Hide\n\n`\\u{001B}[?25l`: Hide cursor.\n\n```swift\nANSIEscapeCode.Cursor.hideCursor // \\u{001B}[?25l\nhideCursor() // Hide cursor.\n```\n\n### Show\n\n`\\u{001B}[?25h`: Show cursor.\n\n```swift\nANSIEscapeCode.Cursor.showCursor // \\u{001B}[?25h\nshowCursor() // Show cursor.\n```\n\n## Erase\n\n### Erase in Display\n\n`\\u{001B}[(n)J`: Clear part of the screen. If `n` is 0 (or missing), clear from cursor to end of screen. If `n` is 1, clear from cursor to beginning of the screen. If `n` is 2, clear entire screen.\n\n```swift\nANSIEscapeCode.Erase.eraseInDisplay(.entireScreen) // \\u{001B}[2J\neraseInDisplay(.fromCursorToBeginningOfScreen) // Erase content from cursor to beginning of screen.\n```\n\n### Erase in Line\n\n`\\u{001B}[(n)K`: Erase part of the line. If `n` is zero (or missing), clear from cursor to the end of the line. If `n` is 1, clear from cursor to beginning of the line. If `n` is 2, clear entire line. Cursor position does not change.\n\n```swift\nANSIEscapeCode.Erase.eraseInLine(.fromCursorToEndOfLine) // \\u{001B}[0K\neraseInLine(.entireLine) // Erase entire line.\n```\n\n## Scroll\n\n### Scroll Up\n\n`\\u{001B}[(n)S`: Scroll whole page up by `n` (default 1) lines. New lines are added at the bottom.\n\n```swift\nANSIEscapeCode.Scroll.up() // \\u{001B}[1S\nscrollUp(3) // Scroll up screen 3 lines.\n```\n\n### Scroll Down\n\n`\\u{001B}[(n)T`: Scroll whole page down by `n` (default 1) lines. New lines are added at the top.\n\n```swift\nANSIEscapeCode.Scroll.down(5) // \\u{001B}[5T\nscrollDown() // Scroll down screen 1 line.\n```\n\n## Decoration\n\n### Reset\n\n`\\u{001B}[0m`: Reset all decoration attributes.\n\n```swift\nANSIEscapeCode.Decoration.reset // \\u{001B}[0m\n```\n\n### Reset Background Color\n\n`\\u{001B}[39m`: Reset background decoration attributes.\n\n```swift\nANSIEscapeCode.Decoration.resetBackgroundColor // \\u{001B}[39m\n```\n\n### Bold\n\n`\\u{001B}[1m`: Make output bold.\n\n```swift\nANSIEscapeCode.Decoration.bold // \\u{001B}[1m\nprint(\"bold text\".boldOutput) // Print bold text.\n```\n\n### Italic\n\n`\\u{001B}[3m`: Make output italic.\n\n```swift\nANSIEscapeCode.Decoration.italic // \\u{001B}[3m\nprint(\"italic text\".italicOutput) // Print italic text.\n```\n\n### Underline\n\n`\\u{001B}[4m`: Make output have underline.\n\n```swift\nANSIEscapeCode.Decoration.underline // \\u{001B}[4m\nprint(\"underline text\".underlineOutput) // Print underline text.\n```\n\n### Blink\n\n`\\u{001B}[5m`: Make output blink.\n\n```swift\nANSIEscapeCode.Decoration.blink // \\u{001B}[5m\nprint(\"blinking text\".blinkOutput) // Print blinking text.\n```\n\n### Text Color\n\n`\\u{001B}[(COLOR)m` Set text color on terminal. Check [`TextColor.swift`](https://github.com/flintbox/ANSIEscapeCode/tree/master/Sources/ANSIEscapeCode/TextColor.swift) for available colors.\n\n```swift\nANSIEscapeCode.Decoration.textColor(.red) // \\u{001B}[31m\nprint(\"red text\".color(.red)) // Print red text.\n```\n\n### Text 8 Bits Color\n\n`\\u{001B}[38;5;(COLOR)m` Set text 8 bits color on terminal. Check [here](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for available colors.\n\n```swift\nANSIEscapeCode.Decoration.text8BitsColor(200) // \\u{001B}[38;5;200m\nprint(\"orange text\".colorFrom8BitsColorSet(208)) // Print orange text.\n```\n\n### Text RGB Color\n\n`\\u{001B}[38;2;(RED);(GREEN);(BLUE)m` Set text RGB color on terminal. Check [here](https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit) for more.\n\n```swift\nANSIEscapeCode.Decoration.textRGBColor(red: 30, green: 20, blue: 10) // \\u{001B}[38;2;30;20;10m\nprint(\"mint text\".colorFromRGBColorSet(red: 170, green: 240, blue: 209)) // Print mint text.\n```\n\n### Background Color\n\n`\\u{001B}[(COLOR)m` Set text background color on terminal. Check [`BackgroundColor.swift`](https://github.com/flintbox/ANSIEscapeCode/tree/master/Sources/ANSIEscapeCode/BackgroundColor.swift) for available colors.\n\n```swift\nANSIEscapeCode.Decoration.backgroundColor(.red) // \\u{001B}[41m\nprint(\"red background\".backgroundColor(.red)) // Print text with red background.\n```\n\n### Background 8 Bits Color\n\n`\\u{001B}[38;5;(COLOR)m` Set text background 8 bits color on terminal. Check [here](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for available colors.\n\n```swift\nANSIEscapeCode.Decoration.background8BitsColor(200) // \\u{001B}[48;5;200m\nprint(\"orange background\".backgroundColorFrom8BitsColorSet(208)) // Print text with orange background.\n```\n\n### Background RGB Color\n\n`\\u{001B}[48;2;(RED);(GREEN);(BLUE)m` Set text background RGB color on terminal. Check [here](https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit) for more.\n\n```swift\nANSIEscapeCode.Decoration.backgroundRGBColor(red: 30, green: 20, blue: 10) // \\u{001B}[48;2;30;20;10m\nprint(\"mint background\".backgroundColorFromRGBColorSet(red: 170, green: 240, blue: 209)) // Print text with mint background.\n```\n\n## Contribute\n\nIf you have good idea or suggestion? Please, don't hesitate to open a pull request or send me an [email](mailto:contact@jasonnam.com).\n\nHope you enjoy building command line tool with ANSIEscapeCode!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflintprocessor%2Fansiescapecode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflintprocessor%2Fansiescapecode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflintprocessor%2Fansiescapecode/lists"}