Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomlm/consolescreenbuffer
Library to use alternative console screen buffers on Windows with Console class.
https://github.com/tomlm/consolescreenbuffer
Last synced: 5 days ago
JSON representation
Library to use alternative console screen buffers on Windows with Console class.
- Host: GitHub
- URL: https://github.com/tomlm/consolescreenbuffer
- Owner: tomlm
- License: mit
- Created: 2025-01-02T18:34:51.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2025-01-02T23:33:39.000Z (24 days ago)
- Last Synced: 2025-01-02T23:46:36.003Z (24 days ago)
- Language: C#
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConsoleScreenBuffer
Class which makes dotnet Console API on windows work with an alternate screen buffer.# Install
```dotnet add package ConsoleScreenBuffer```
# Usage
The **ConsoleScreenBuffer** class gives you the ability to create console screen buffers, and switch between them easily.
* **To Capture Current Buffer**
* ```ConsoleScreenBuffer.GetCurrent()```
* **To Create an alternate buffer**
* ```ConsoleScreenBuffer.Create()```
* **To Activate a buffer** -
* ```buffer.SetAsActiveBuffer()``` All of the Console API's will use the new screen buffer seamlessly.![secondaryBuffer](https://github.com/tomlm/ConsoleScreenBuffer/blob/main/assets/secondaryBuffer.gif)
# Example
```csharp
Console.WriteLine("Hello, World!");
// capture the original screen buffer
var originalBuffer = ConsoleScreenBuffer.GetCurrent();// create an alternate screen buffer
var buffer = ConsoleScreenBuffer.Create(true);// make it active
buffer.SetAsActiveBuffer();// use Console API.
Console.SetCursorPosition(10, 2);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Hello secondary buffer!");
Console.ReadKey(true); // wait for a keypress// restore original screen
originalBuffer.SetAsActiveBuffer();
Console.WriteLine("All done");```