{"id":22559549,"url":"https://github.com/franck-gaspoz/ansivtconsole.netcore","last_synced_at":"2025-08-20T00:34:17.037Z","repository":{"id":64750701,"uuid":"576769292","full_name":"franck-gaspoz/AnsiVtConsole.NetCore","owner":"franck-gaspoz","description":"ANSI VT console library for .Net Core","archived":false,"fork":false,"pushed_at":"2024-02-15T23:53:19.000Z","size":7434,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-01T01:52:41.190Z","etag":null,"topics":["ansi","ansi-colors","bash","cli","command-line","command-line-tool","console","console-app","csharp","dotnet","dotnet-core","library","netcore","shell","terminal","vt100"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/franck-gaspoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-12-10T23:08:18.000Z","updated_at":"2025-07-24T22:39:18.000Z","dependencies_parsed_at":"2025-04-10T09:38:14.771Z","dependency_job_id":"b176208d-d118-4430-b7e1-1bfd85f61e30","html_url":"https://github.com/franck-gaspoz/AnsiVtConsole.NetCore","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/franck-gaspoz/AnsiVtConsole.NetCore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FAnsiVtConsole.NetCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FAnsiVtConsole.NetCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FAnsiVtConsole.NetCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FAnsiVtConsole.NetCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franck-gaspoz","download_url":"https://codeload.github.com/franck-gaspoz/AnsiVtConsole.NetCore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FAnsiVtConsole.NetCore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271246661,"owners_count":24725900,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","ansi-colors","bash","cli","command-line","command-line-tool","console","console-app","csharp","dotnet","dotnet-core","library","netcore","shell","terminal","vt100"],"created_at":"2024-12-07T21:07:23.153Z","updated_at":"2025-08-20T00:34:16.969Z","avatar_url":"https://github.com/franck-gaspoz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"___\n\n# ![AnsiVtConsole.NetCore](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/ascii-icon.png \"AnsiVtConsole.NetCore\") AnsiVtConsole.NetCore\n\n___\n\n**AnsiVtConsole.NetCore library** provides ANSI VT support (cursor,colors,screen size) for multi-plateform (windows, linux, osx, arm) console applications using C# and .NET Core 6\n\n[![licence mit](https://img.shields.io/badge/licence-MIT-blue.svg)](license.md) This project is licensed under the terms of the MIT license: [LICENSE.md](LICENSE.md)  \n![last commit](https://img.shields.io/github/last-commit/franck-gaspoz/AnsiVtConsole.NetCore?style=plastic)\n![version](https://img.shields.io/github/v/tag/franck-gaspoz/AnsiVtConsole.NetCore?style=plastic)\n___\n\n![title](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/title.png \"title\")  \n\n# Features\n\nThe library provides functionalities needed to build console applications running in a terminal (WSL/WSL2, cmd.exe, ConEmu, bash, ...) with text interface. That includes:\n- **a text printer engine** that supports **print directives** (markup) allowing to manage console functionalities from text itself, as html would do but with a simplest grammar (that can be configured). That makes possible colored outputs, cursor control, text scrolling and also dynamic C# execution (scripting), based on **System.Console** and **ANSI VT100 / VT52 (VT100 type Fp or 3Fp, Fs, CSI, SGR)** \n\n- A ANSI Parser that can identify/remove escape sequences in a text\n\n- **widgets** : visual elements with live update, animations, thread safe, combinables together \n    - raimbow text,bar\n    - animated text, text timer, type writer\n    - image (provided in a separate package: [AnsiVtConsole.NetCore.Imaging](https://www.nuget.org/packages/AnsiVtConsole.NetCore/))\n\n- The console output can be controlled by:\n    - tokens in a string (print directives)\n    - as string shortcuts (dynamic ansi vt strings) powered by **SkiaSharp**\n    - throught API methods\n\n# Index\n\n- [Usage](#usage)\n    - [using the markup](#using-the-markup)\n    - [using the string shortcuts](#using-the-string-shortcuts)\n    - [using the ANSI sequences](#using-the-ansi-sequences)\n    - [using the widgets](#using-the-widgets)\n- [Print directives (markup)](#print-directives-markup)\n    - [1. Colorization with SGR (Select Graphic Rendition)](#colorization-with-sgr-select-graphic-rendition)\n    - [2. Text decoration (vt100) with SGR (Select Graphic Rendition)](#text-decoration-vt100-with-sgr-select-graphic-rendition)\n    - [3. CSI (Control Sequence Introducer)](#csi-control-sequence-introducer)\n    - [4. Script engine](#script-engine)\n    - [5. Application control](#application-control)\n    - [6. ANSI Sequences](#ansi-sequences)\n    - [7. Unicode characters](#unicode-characters)\n- [Command line interface tool for your shells](#command-line-interface-tool-for-your-shells)\n- [Examples](#examples)\n    - [project AnsiConsole.NetCore.Examples.Widgets](#project-ansiconsole.netcore.examples.widgets) \n    - [project AnsiConsole.NetCore.Examples.ANSI](#project-ansiconsole.netcore.examples.ansi)\n        - [Colorisation](#colorisation)\n        - [AnsiVtConsole markup and Ansi/Vt parsing](#ansivtconsole-markup-and-ansivt-parsing)\n- [Version history](#versions-history)\n\n# Usage\n\ndownload the nuget from command line or add it from Visual Studio\n\n``` dos\n@rem version 1.0.21 or any new one\ndotnet add package AnsiVtConsole.NetCore --version 1.0.21\n```\n\n\u003e **Note**\n\u003e\n\u003e When installing the package, the following files are copied into your project:\n\u003e - LICENSE.md\n\u003e - README.md\n\u003e - Component/Parser/ANSI/ansi-seq-patterns.txt\n\u003e - assets/example1.png\n\u003e - assets/example2.png\n\u003e - assets/example3.png\n\u003e - assets/example4.png\n\u003e - assets/example5.png\n\u003e - assets/example6.png\n\u003e - assets/output.png\n\u003e - assets/ascii-icon.png\n\u003e\n\u003e you can delete these files **EXCEPT `ansi-seq-patterns.txt`** (ANSI grammar) that is required for the ANSI parser to work\n\u003e\n\u003e these files are set as `Content` and are copied to output folder on build\n\n\n``` csharp\n// get the ansi vt console\nvar console = new AnsiVtConsole.NetCore.AnsiVTConsole();\n```\n\n## 1. using the markup :\n\n``` csharp\nconsole.Write(\"(br,f=yellow,b=red)yellow text on red background(br)(f=cyan)current time is: (exec=System.DateTime.Now,br)\");\n```\n\n## 2. using the string shortcuts :\n\n``` csharp\nusing static AnsiVtConsole.NetCore.Component.EchoDirective;\n\nSystem.Console.Out.Writeline($\"{Br}{Yellow}{BRed}yellow text on red background{Br}{Cyan}current time is: {System.DateTime.Now}{Br}\");\n```\n\n## 3. using the ANSI sequences:\n\n``` csharp\nusing static AnsiVtConsole.NetCore.Component.Console.ANSI;\n\nSystem.Console.Out.Writeline($\"{CRLF}{SGRF(\"Yellow\")}{SGRB(\"Red\")}yellow text on red background{CRLF}{SGRF(\"Cyan\")}current time is: {System.DateTime.Now}{CRLF}\");\n```\n\n### all outputs:\n\n![output](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/output.png \"output\")\n\n## 4. using the widgets\n\n``` csharp\n/* type writer example\nthis adds a 'type writer' widget at current cursor location, \nmaintains it in place and produces an animation of the text until\nthe end of the animation\n*/\nusing AnsiVtConsole.NetCore.Component.Widgets.Texts.TypeWriting;\n\nTypeWriter(text)\n    .Add(console)   // add to a console and render the widget\n    .Wait();        // animated update until end of animation\n```\n\nexample output:\n\n![widget output](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/ansivtconsole.netcore.widget.gif \"output\")\n\n# Print directives (markup):\n\ntext can contains echo directives that changes the echo behavior. the echo directive syntax is formed according to this pattern: `(printDirective) or (printDirective=printDirectiveValue)`\n\n- multiple echo directives can be separated by a , that can be grouped in a single text in parentheses: `(echoDirective1,echoDirective2=..,echoDirective3)`\n- an echo directive value can be written inside a 'code' text block, depending on each echo directive, with the syntax: `[[...]]`\n- symbols of this grammar can be configured throught the class:\n    `AnsiVtConsole.NetCore.Component.Settings`\n- alternatively to the print directives you can use the strings shortcuts from the class: `AnsiVtConsole.NetCore.Component.EchoDirective`\n\nAvailable echo directives are defined in the class ``\n\n## 1. Colorization with SGR (Select Graphic Rendition)\n\n```yaml\nf=ConsoleColor      : set foreground color\nf8=Int32            : set foreground 8bit color index, where 0 \u003c= index \u003c= 255\nf24=Int32:Int32:Int32 : set foreground 24bit color red:green:blue, where 0 \u003c= red,green,blue \u003c= 255\nf=ConsoleColor      : set foreground color\nb=ConsoleColor      : set background color\nb8=Int32            : set background 8bit color index, where 0 \u003c= index \u003c= 255\nb24=Int32:Int32:Int32 : set background 24bit color red:green:blue, where 0 \u003c= red,green,blue \u003c= 255\ndf=ConsoleColor     : set default foreground\ndb=ConsoleColor     : set default background\nbkf                 : backup foreground color\nbkb                 : backup background color\nrsf                 : restore foreground color\nrsb                 : restore background color\nrdc                 : restore default colors```\n\nConsoleColor := darkblue|darkgreen|darkcyan|darkred|darkmagenta|darkyellow|gray|darkgray|blue|green|cyan|red|magenta|yellow|white (not case sensitive)\n```\n\n## 2. Text decoration (vt100) with SGR (Select Graphic Rendition)\n\n```yaml\nuon                 : underline on\ninvon               : inverted colors on\ntdoff               : text decoration off and reset default colors\nlion                : ligtht colors\nbon                 : bold on\nblon                : blink on\n```\n\n## 3. CSI (Control Sequence Introducer)\n\n```yaml\ncls                 : clear screen\nbr                  : jump begin of next line (line break)\nbkcr                : backup cursor position\nrscr                : restore cursor position\ncrx=Int32           : set cursor x (0\u003c=x\u003c=WindowWidth)\ncry=Int32           : set cursor y (0\u003c=y\u003c=WindowHeight)\ncrh                 : hide cursor\ncrs                 : show cursor\ncleft               : move cursor left\ncright              : move cursor right\ncup                 : move cursor up\ncdown               : move cursor down\ncnleft=Int32        : move cursor n characters left\ncnright=Int32       : move cursor n characters right\ncnup=Int32          : move cursor n lines up\ncndown=Int32        : move cursor n lines down\ncl                  : clear line\nclleft              : clear line from cursor left\nclright             : clear line from cursor right\nfillright           : fill line from cursor right\nchome               : move cursor to upper left corner\ntab                 : add a tab\n```\n\n## 4. Script engine\n\n```yaml\nexec=CodeBlock|[[CodeBlock]] : executes and echo result of a C# code block\n```\n\n```csharp\nusing static AnsiVtConsole.NetCore.Component.Parser.ANSI;\nusing cons=AnsiVtConsole.NetCore;\n// get the ansi vt console\nvar console = new cons.AnsiVTConsole();\n\nconsole.Out.WriteLine(\"current date is: (exec=System.DateTime.Now.Date)\");\n```\n\n## 5. Application control\n\n```yaml\ninfo                : output infos about the console\nexit                : exit the current process\n```\n\n## 6. ANSI Sequences\n\nANSI sequences are defined in `AnsiVtConsole.NetCore.Component.Console` and can be used directly to build ANSI strings\n\n```csharp\nusing static AnsiVtConsole.NetCore.Component.Parser.ANSI;\nusing cons=AnsiVtConsole.NetCore;\n// get the ansi vt console\nvar console = new cons.AnsiVTConsole();\n\nvar str = $\"{SGR_Underline}{SGR_CrossedOut}my text{SGR_SetBackgroundColor24bits(15,152,123)}in color\";\nSystem.Console.WriteLine(str);\n\n// is equivalent to:\n\ncons.Out.WriteLine(\"(SGR_Underline,SGR_SlowBlink)my text(SGRB24=15:152:123)in color\");\n\n// or to:\n\ncons.Out.WriteLine(\"(uon,blon)my text(f24=15:152:123)in color\");\n\n```\n\n## 7. Unicode characters\n\nUnicode characters are defined in the class `AnsiVtConsole.NetCore.Component.Console`.\n\n```csharp\n\nusing static AnsiVtConsole.NetCore.Component.Console.Unicode;\nusing cons=AnsiVtConsole.NetCore;\n// get the ansi vt console\nvar console = new cons.AnsiVTConsole();\n\nconsole.Out.WriteLine($\"it's the (bkf,f=red){Demi}(rsf) or the (bkf,f=yellow){Quar}(rsf) of it\");\n\nconsole.Out.WriteLine(\"(f=cyan,EdgeTopLeft,BarHorizontal,EdgeTopRight)\");\nconsole.Out.WriteLine(\"(f=cyan,BarVertical,f=blue,Box,f=cyan,BarVertical)\");\nconsole.Out.WriteLine(\"(f=cyan,EdgeBottomLeft,BarHorizontal,EdgeBottomRight)\");\n```\n![example6](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/example6.png \"example6\")\n\n# Command line interface tool for your shells\n\nThe project `AnsiVtConsole.NetCore.CommandLine` build a **command line tool** that calls the **AnsiVtConsole `WriteLine`** method.\nWith that you can add to you shell scripts the outputs provided by AnsiVtConsole:\n\n```dos\nout.exe \"(br,f=yellow,b=red)yellow text on red background(br)(f=cyan)current time is: (exec=System.DateTime.Now,br)\"\n```\n\noutputs:\n\n![output](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/output.png \"output\")\n\n```dos\nout.exe \"(br,f=yellow,b=red)yellow text on red background(br)(f=cyan)current time is: (exec=System.DateTime.Now,br)\" --raw\n```\n\noutputs:\n\n`\\e[4m\\e[0m\\e[0K\\r\\n\\e[4m\\e[0m\\e[37m\\e[93m\\e[101myellow text on red background\\e[4m\\e[0m\\e[0K\\r\\n\\e[4m\\e[0m\\e[37m\\e[96mcurrent time is: 13/06/2020 06:17:15\\e[4m\\e[0m\\e[0K\\r\\n\\e[4m\\e[0m\\e[37m`\n\nthis tool accepts these arguments:\n\n```dos\nout.exe \u003ctext\u003e [--raw [--esc-only] [--hexa] ] \n```\n\n- if `--err` outputs to standard error stream instead of standard output stream\n- if `--raw`, parse ANSI and non printable characters to show them by their names or representations\n- if `--raw` these options are avalaibles :\n    - `--esc-only` : disable only knowns non printable characters (from ASCII)\n    - `--hexa` : use the hexa unix format for non printable characters\n\n\u003e **Note**\n\u003e\n\u003e the command line tool is built upon the library **`CommandLine.NetCore`**. For more information for this, please refers to:\n\u003e - [CommandLine.NetCore nuget](https://www.nuget.org/packages/CommandLine.NetCore/#readme-body-tab)\n\u003e - [CommandLine.NetCore GitHub repository](https://github.com/franck-gaspoz/CommandLine.NetCore)\n\n# Examples\n\n## project `AnsiConsole.NetCore.Examples.Widgets`\n\nthis project once compiled provides a **live demo in the console** of **widgets** implemented in the current version of the library.\nTo try these examples, compile and run the project **AnsiVtConsole.NetCore.Examples.Widgets**:\n\n![title](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/title.png \"title\")  \n\nexample of an **Image** widget. This widget is delivered in the package: [AnsiVtConsole.NetCore.Imaging](https://www.nuget.org/packages/AnsiVtConsole.NetCore/)\n\n![example7](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/example7.png \"example7\")\n\n\n\n## project `AnsiConsole.NetCore.Examples.ANSI`\n\n### Colorization\n\nTo try these examples, compile and run the project **AnsiVtConsole.NetCore.Examples.ANSI**:\n\n![example1](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/example1.png \"example1\")\n![example2](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/example2.png \"example2\")\n\n### AnsiVtConsole markup and Ansi/Vt parsing\n\n![example5](https://raw.githubusercontent.com/franck-gaspoz/AnsiVtConsole.NetCore/main/AnsiVtConsole.NetCore/assets/example5.png \"example5\")\n\n# Versions history\n\n`1.0.21,1.0.22,1.0.23,1.0.24,1.0.25,1.0.26` - 2-16-2024\n- fix nuget content files\n\n`1.0.20` - 1-23-2023\n- animated widgets\n- properties animator\n- widgets: text,type writer,gradient,gradient bar,text timer\n- widget image in a separated project AnsiVtConsole.NetCore.Imaging using SkiaSharp\n- examples projects\n- fluent methods for ContextTextWriterWrapper\n- doc update\n\n`1.0.19` - 1-17-2023\n- add **widgets** feature + RaimbowText widget\n- add example\n- doc update\n\n`1.0.18` - 1-1-2023\n- add symbols and sources in package\n- new editorconfig and code clean up\n- command `out` for a shell available in `AnsiVtConsole.NetCore.CommandLine.Out` that compiles to `out.exe`\n- doc update\n\n`1.0.17` - 10-1-2023\n- add setting that make it possible to disable ansi/vt in console ouputs: `AnsiVtConsole.NetCore.Component.Settings` : `IsMarkupDisabled`,`IsRawOutputEnabled`,`ReplaceNonPrintableCharactersByTheirName`,`RemoveANSISequences`\n- add methods to get output text in various formats (without ansi,with unparsed markup,in shell escaped characters) : `GetText`,`GetRawText`,`ANSIParser.GetText` \n- add grammar file for ANSI parser\n- enable buffering mode for any print directive\n- update doc\n\n`1.0.16` - 5-1-2022\n- fix nupkg. add deployment of documentation files\n- update doc\n\n`1.0.14,1.0.15` - 12-17-2022\n- fix LogError,LogWarning\n\n`1.0.13` - 12-17-2022\n- fix refactoring Write,WriteLine\n- add default empty string to log methods\n\n`1.0.12` - 12-17-2022\n- rename Writeln methods by WriteLine\n- suppress Log,Logln \u0026amp; logger refactoring\n- add code documentation\n\n**AnsiVtConsole.NetCore.Imaging**\n\n`1.0.0` - 21-1-2023\n- inital version. provide widget image to AnsiConsole.NetCore (package [AnsiVtConsole.NetCore.Imaging](https://www.nuget.org/packages/AnsiVtConsole.NetCore/))\n\n___\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranck-gaspoz%2Fansivtconsole.netcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranck-gaspoz%2Fansivtconsole.netcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranck-gaspoz%2Fansivtconsole.netcore/lists"}