{"id":17912641,"url":"https://github.com/danielgatis/go-ansicode","last_synced_at":"2025-12-25T22:40:36.019Z","repository":{"id":200219039,"uuid":"705061946","full_name":"danielgatis/go-ansicode","owner":"danielgatis","description":"go-ansicode is a package that interprets ANSI codes and allows you to register a handler to deal with the operations","archived":false,"fork":false,"pushed_at":"2025-01-03T20:14:59.000Z","size":82,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T19:06:55.916Z","etag":null,"topics":["ansi-escape-codes","ansicode","go","golang","terminal","terminal-emulator"],"latest_commit_sha":null,"homepage":"","language":"Go","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/danielgatis.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-14T23:22:49.000Z","updated_at":"2025-01-03T20:14:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"35c26ad7-97f5-4324-9432-42d6477dcbd7","html_url":"https://github.com/danielgatis/go-ansicode","commit_stats":null,"previous_names":["danielgatis/go-ansicode"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/danielgatis/go-ansicode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ansicode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ansicode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ansicode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ansicode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgatis","download_url":"https://codeload.github.com/danielgatis/go-ansicode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ansicode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135682,"owners_count":23881802,"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":["ansi-escape-codes","ansicode","go","golang","terminal","terminal-emulator"],"created_at":"2024-10-28T19:46:19.413Z","updated_at":"2025-12-25T22:40:36.012Z","avatar_url":"https://github.com/danielgatis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-ansicode\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/danielgatis/go-ansicode?style=flat-square)](https://goreportcard.com/report/github.com/danielgatis/go-ansicode)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/danielgatis/go-ansicode/master/LICENSE)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/danielgatis/go-ansicode)\n\ngo-ansicode is a package that interprets ANSI codes and allows you to register a handler to deal with the operations.\n\n## Supported Sequences\n\n### C0\n\n| Operation | Description                      |\n|-----------|----------------------------------|\n| NUL       | Null (NUL) character.            |\n| SOH       | Start of Heading (SOH).          |\n| STX       | Start of Text (STX).             |\n| ETX       | End of Text (ETX).               |\n| EOT       | End of Transmission (EOT).       |\n| ENQ       | Enquiry (ENQ).                   |\n| ACK       | Acknowledge (ACK).               |\n| BEL       | Bell (BEL).                      |\n| BS        | Backspace (BS).                  |\n| HT        | Horizontal Tab (HT).             |\n| LF        | Line Feed (LF).                  |\n| VT        | Vertical Tab (VT).               |\n| FF        | Form Feed (FF).                  |\n| CR        | Carriage Return (CR).            |\n| SO        | Shift Out (SO).                  |\n| SI        | Shift In (SI).                   |\n| DLE       | Data Link Escape (DLE).          |\n| XON       | Device Control 1 (XON).          |\n| DC2       | Device Control 2 (DC2).          |\n| XOFF      | Device Control 3 (XOFF).         |\n| DC4       | Device Control 4 (DC4).          |\n| NAK       | Negative Acknowledge (NAK).      |\n| SYN       | Synchronous Idle (SYN).          |\n| ETB       | End of Transmission Block (ETB). |\n| CAN       | Cancel (CAN).                    |\n| EM        | End of Medium (EM).              |\n| SUB       | Substitute (SUB).                |\n| ESC       | Escape (ESC).                    |\n| FS        | File Separator (FS).             |\n| GS        | Group Separator (GS).            |\n| RS        | Record Separator (RS).           |\n\n\n### C1\n\n| Operation | Description                                               |\n|-----------|-----------------------------------------------------------|\n| IND       | Index - Move to the next line (Line Feed)                 |\n| NEL       | Next Line - Line Feed followed by Carriage Return         |\n| HTS       | Horizontal Tab Set                                        |\n| RI        | Reverse Index - Move to the previous line                 |\n| DECID     | Identify Terminal - Request for terminal identification   |\n| RIS       | Reset to Initial State - Reset all settings to defaults   |\n| DECSC     | Save Cursor - Save current cursor position and attributes |\n| DECRC     | Restore Cursor - Restore cursor position and attributes   |\n| DECALN    | Alignment Test - Perform an alignment test                |\n| DECKPAM   | Keypad Application Mode - Enable Keypad Application Mode  |\n| DECKPNM   | Numeric Mode - Disable Keypad Application Mode            |\n\n\n### CSI\n\n| CSI Sequence      | Description                                          |\n|-------------------|------------------------------------------------------|\n| `CSI Ps '`        | Single-character tabulation set (HTS)                |\n| `CSI Ps @`        | Character tabulation with justification (CHA)        |\n| `CSI Ps A`        | Line tabulation set (VTS)                            |\n| `CSI Ps B`        | Partial line forward (incomplete)                    |\n| `CSI Ps b`        | Repeat character (REP)                               |\n| `CSI Ps C`        | Cursor forward (CUF)                                 |\n| `CSI Ps c`        | Send device attributes (DA)                          |\n| `CSI Ps a`        | Character position forward (CHA)                     |\n| `CSI Ps D`        | Cursor backward (CUB)                                |\n| `CSI Ps d`        | Vertical position absolute (VPA)                     |\n| `CSI Ps E`        | Next line (NEL)                                      |\n| `CSI Ps e`        | Vertical position relative (VPR)                     |\n| `CSI Ps F`        | Previous line (RI)                                   |\n| `CSI Ps G`        | Horizontal tab set (HTS)                             |\n| `CSI Ps g`        | Tab clear (TBC)                                      |\n| `CSI Ps ; Ps H`   | Cursor position (CUP)                                |\n| `CSI Ps ; Ps f`   | Horizontal and vertical position (HVP)               |\n| `CSI Ps I`        | Forward tabulation (HT)                              |\n| `CSI Ps J`        | Erase in display (ED)                                |\n| `CSI Ps K`        | Erase in line (EL)                                   |\n| `CSI Ps L`        | Insert line (IL)                                     |\n| `CSI Ps l`        | Reset mode (DEC)                                     |\n| `CSI ? Ps l`      | DEC private mode reset                               |\n| `CSI Ps M`        | Delete line (DL)                                     |\n| `CSI Pm m`        | Character attribute (SGR)                            |\n| `CSI \u003e Pp ; Pv m` | Select character protection attribute (DECSCPP)      |\n| `CSI ? Pp m`      | Select media character set and invoke macro (DECSEL) |\n| `CSI Ps n`        | Device status report (DSR)                           |\n| `CSI Ps P`        | Delete character (DCH)                               |\n| `CSI Ps SP q`     | Select modifier and use bit combination (SMRM)       |\n| `CSI Ps ; Ps r`   | Set top and bottom margins (DECSTBM)                 |\n| `CSI Ps S`        | Scroll up (SU)                                       |\n| `CSI s`           | Save cursor position (SCP)                           |\n| `CSI Ps T`        | Scroll down (SD)                                     |\n| `CSI Ps t`        | Window manipulation (DECSWT)                         |\n| `CSI u`           | Restore cursor position (RCP)                        |\n| `CSI ? u`         | DEC private mode reset                               |\n| `CSI = Ps ; Ps u` | Set conformance level (DECSCL)                       |\n| `CSI \u003e Ps u`      | Set ANSI conformance level (DECSASD)                 |\n| `CSI \u003c Ps u`      | Set conformance level (DECSCL)                       |\n| `CSI Ps X`        | Erase character (ECH)                                |\n| `CSI Ps Z`        | Cursor back tabulation (CBT)                         |\n\n\n### OSC\n\n| OSC Sequence               | Description                           |\n|----------------------------|---------------------------------------|\n| `OSC 0 ; Pt BEL`           | Set icon name and window title        |\n| `OSC 2 ; Pt BEL`           | Set window title                      |\n| `OSC 4 ; c ; spec BEL`     | Change color in palette (8/16 colors) |\n| `OSC 8 ; params ; uri BEL` | Set hyperlinks                        |\n| `OSC 10 ; Ps BEL`          | Set foreground text color             |\n| `OSC 11 ; Ps BEL`          | Set background text color             |\n| `OSC 12 ; Ps BEL`          | Set cursor text color                 |\n| `OSC 104 ; c BEL`          | Reset color in palette (8/16 colors)  |\n| `OSC 110 BEL`              | Reset icon name and window title      |\n| `OSC 111 BEL`              | Reset window title                    |\n| `OSC 112 BEL`              | Reset color in palette (24-bit)       |\n\n\n### SOS/PM/APC\n\n| Sequence       | Description                                                               |\n|----------------|---------------------------------------------------------------------------|\n| `ESC X ... ST` | Start of String (SOS) - Application-specific string data                  |\n| `ESC ^ ... ST` | Privacy Message (PM) - Private message for terminal                       |\n| `ESC _ ... ST` | Application Program Command (APC) - Used by protocols like Kitty Graphics |\n\nThese sequences can also be terminated by BEL (0x07) instead of ST (ESC \\).\n\n\n## Install\n\n```bash\ngo get -u github.com/danielgatis/go-ansicode\n```\n\nAnd then import the package in your code:\n\n```go\nimport \"github.com/danielgatis/go-ansicode\"\n```\n\n### Example\n\nPlease look at: [examples/ansilog/main.go](examples/ansilog/main.go)\n\n```\n❯ echo -ne \"\\033[31;42mThis text is red on a green background\\033[0m\\nbye\" | go run ./examples/ansilog/main.go\nSetTerminalCharAttribute {22 0x14000112018 \u003cnil\u003e \u003cnil\u003e}\nSetTerminalCharAttribute {23 0x14000112020 \u003cnil\u003e \u003cnil\u003e}\nInput 84\nInput 104\nInput 105\nInput 115\nInput 32\nInput 116\nInput 101\nInput 120\nInput 116\nInput 32\nInput 105\nInput 115\nInput 32\nInput 114\nInput 101\nInput 100\nInput 32\nInput 111\nInput 110\nInput 32\nInput 97\nInput 32\nInput 103\nInput 114\nInput 101\nInput 101\nInput 110\nInput 32\nInput 98\nInput 97\nInput 99\nInput 107\nInput 103\nInput 114\nInput 111\nInput 117\nInput 110\nInput 100\nSetTerminalCharAttribute {0 \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e}\nLineFeed\nInput 98\nInput 121\nInput 101\n```\n\n## License\n\nCopyright (c) 2023-present [Daniel Gatis](https://github.com/danielgatis)\n\nLicensed under [MIT License](./LICENSE)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ansicode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgatis%2Fgo-ansicode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ansicode/lists"}