https://github.com/danielgatis/go-ansicode

go-ansicode is a package that interprets ANSI codes and allows you to register a handler to deal with the operations

https://github.com/danielgatis/go-ansicode

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.0%) to scientific vocabulary

Keywords

ansi-escape-codes ansicode go golang terminal terminal-emulator
Last synced: 6 months ago · JSON representation

Repository

go-ansicode is a package that interprets ANSI codes and allows you to register a handler to deal with the operations

Basic Info
  • Host: GitHub
  • Owner: danielgatis
  • License: mit
  • Language: Go
  • Default Branch: main
  • Homepage:
  • Size: 80.1 KB
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
ansi-escape-codes ansicode go golang terminal terminal-emulator
Created over 2 years ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

go-ansicode

Go Report Card License MIT Go Doc

go-ansicode is a package that interprets ANSI codes and allows you to register a handler to deal with the operations.

Supported Sequences

C0

| Operation | Description | | --------- | -------------------------------- | | NUL | Null (NUL) character. | | SOH | Start of Heading (SOH). | | STX | Start of Text (STX). | | ETX | End of Text (ETX). | | EOT | End of Transmission (EOT). | | ENQ | Enquiry (ENQ). | | ACK | Acknowledge (ACK). | | BEL | Bell (BEL). | | BS | Backspace (BS). | | HT | Horizontal Tab (HT). | | LF | Line Feed (LF). | | VT | Vertical Tab (VT). | | FF | Form Feed (FF). | | CR | Carriage Return (CR). | | SO | Shift Out (SO). | | SI | Shift In (SI). | | DLE | Data Link Escape (DLE). | | XON | Device Control 1 (XON). | | DC2 | Device Control 2 (DC2). | | XOFF | Device Control 3 (XOFF). | | DC4 | Device Control 4 (DC4). | | NAK | Negative Acknowledge (NAK). | | SYN | Synchronous Idle (SYN). | | ETB | End of Transmission Block (ETB). | | CAN | Cancel (CAN). | | EM | End of Medium (EM). | | SUB | Substitute (SUB). | | ESC | Escape (ESC). | | FS | File Separator (FS). | | GS | Group Separator (GS). | | RS | Record Separator (RS). |

C1

| Operation | Description | | --------- | --------------------------------------------------------- | | IND | Index - Move to the next line (Line Feed) | | NEL | Next Line - Line Feed followed by Carriage Return | | HTS | Horizontal Tab Set | | RI | Reverse Index - Move to the previous line | | DECID | Identify Terminal - Request for terminal identification | | RIS | Reset to Initial State - Reset all settings to defaults | | DECSC | Save Cursor - Save current cursor position and attributes | | DECRC | Restore Cursor - Restore cursor position and attributes | | DECALN | Alignment Test - Perform an alignment test | | DECKPAM | Keypad Application Mode - Enable Keypad Application Mode | | DECKPNM | Numeric Mode - Disable Keypad Application Mode |

CSI

| CSI Sequence | Description | | ----------------- | ---------------------------------------------------- | | CSI Ps ' | Single-character tabulation set (HTS) | | CSI Ps @ | Character tabulation with justification (CHA) | | CSI Ps A | Line tabulation set (VTS) | | CSI Ps B | Partial line forward (incomplete) | | CSI Ps b | Repeat character (REP) | | CSI Ps C | Cursor forward (CUF) | | CSI Ps c | Send device attributes (DA) | | CSI Ps a | Character position forward (CHA) | | CSI Ps D | Cursor backward (CUB) | | CSI Ps d | Vertical position absolute (VPA) | | CSI Ps E | Next line (NEL) | | CSI Ps e | Vertical position relative (VPR) | | CSI Ps F | Previous line (RI) | | CSI Ps G | Horizontal tab set (HTS) | | CSI Ps g | Tab clear (TBC) | | CSI Ps ; Ps H | Cursor position (CUP) | | CSI Ps ; Ps f | Horizontal and vertical position (HVP) | | CSI Ps I | Forward tabulation (HT) | | CSI Ps J | Erase in display (ED) | | CSI Ps K | Erase in line (EL) | | CSI Ps L | Insert line (IL) | | CSI Ps l | Reset mode (DEC) | | CSI ? Ps l | DEC private mode reset | | CSI Ps M | Delete line (DL) | | CSI Pm m | Character attribute (SGR) | | CSI > Pp ; Pv m | Select character protection attribute (DECSCPP) | | CSI ? Pp m | Select media character set and invoke macro (DECSEL) | | CSI Ps n | Device status report (DSR) | | CSI Ps P | Delete character (DCH) | | CSI Ps SP q | Select modifier and use bit combination (SMRM) | | CSI Ps ; Ps r | Set top and bottom margins (DECSTBM) | | CSI Ps S | Scroll up (SU) | | CSI s | Save cursor position (SCP) | | CSI Ps T | Scroll down (SD) | | CSI Ps t | Window manipulation (DECSWT) | | CSI u | Restore cursor position (RCP) | | CSI ? u | DEC private mode reset | | CSI = Ps ; Ps u | Set conformance level (DECSCL) | | CSI > Ps u | Set ANSI conformance level (DECSASD) | | CSI < Ps u | Set conformance level (DECSCL) | | CSI Ps X | Erase character (ECH) | | CSI Ps Z | Cursor back tabulation (CBT) |

OSC

| OSC Sequence | Description | | ----------------------------------------- | ------------------------------------- | | OSC 0 ; Pt BEL | Set icon name and window title | | OSC 2 ; Pt BEL | Set window title | | OSC 4 ; c ; spec BEL | Change color in palette (8/16 colors) | | OSC 8 ; params ; uri BEL | Set hyperlinks | | OSC 10 ; Ps BEL | Set foreground text color | | OSC 11 ; Ps BEL | Set background text color | | OSC 12 ; Ps BEL | Set cursor text color | | OSC 104 ; c BEL | Reset color in palette (8/16 colors) | | OSC 110 BEL | Reset icon name and window title | | OSC 111 BEL | Reset window title | | OSC 112 BEL | Reset color in palette (24-bit) |

Install

bash go get -u github.com/danielgatis/go-ansicode

And then import the package in your code:

go import "github.com/danielgatis/go-ansicode"

Example

Please look at: examples/ansilog/main.go

❯ echo -ne "\033[31;42mThis text is red on a green background\033[0m\nbye" | go run ./examples/ansilog/main.go SetTerminalCharAttribute {22 0x14000112018 <nil> <nil>} SetTerminalCharAttribute {23 0x14000112020 <nil> <nil>} Input 84 Input 104 Input 105 Input 115 Input 32 Input 116 Input 101 Input 120 Input 116 Input 32 Input 105 Input 115 Input 32 Input 114 Input 101 Input 100 Input 32 Input 111 Input 110 Input 32 Input 97 Input 32 Input 103 Input 114 Input 101 Input 101 Input 110 Input 32 Input 98 Input 97 Input 99 Input 107 Input 103 Input 114 Input 111 Input 117 Input 110 Input 100 SetTerminalCharAttribute {0 <nil> <nil> <nil>} LineFeed Input 98 Input 121 Input 101

License

Copyright (c) 2023-present Daniel Gatis

Licensed under MIT License

Owner

  • Name: Daniel Gatis
  • Login: danielgatis
  • Kind: user
  • Location: Recife - PE

GitHub Events

Total
  • Create event: 3
  • Release event: 3
  • Issues event: 2
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 5
  • Pull request event: 2
Last Year
  • Create event: 3
  • Release event: 3
  • Issues event: 2
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 5
  • Pull request event: 2

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 15
  • Total Committers: 2
  • Avg Commits per committer: 7.5
  • Development Distribution Score (DDS): 0.2
Past Year
  • Commits: 10
  • Committers: 2
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.3
Top Committers
Name Email Commits
Daniel Gatis d****s@g****m 12
Alex Suraci s****x@g****m 3

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 0
  • Total pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.33
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.33
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • djnalluri (1)
  • vito (1)
Pull Request Authors
  • vito (5)
  • danielgatis (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 11
proxy.golang.org: github.com/danielgatis/go-ansicode
  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 8.6%
Dependent repos count: 10.7%
Average: 14.3%
Forks count: 18.8%
Stargazers count: 19.3%
Last synced: 6 months ago