buffer 3.3.1

dotnet add package buffer --version 3.3.1
                    
NuGet\Install-Package buffer -Version 3.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="buffer" Version="3.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="buffer" Version="3.3.1" />
                    
Directory.Packages.props
<PackageReference Include="buffer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add buffer --version 3.3.1
                    
#r "nuget: buffer, 3.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=buffer&version=3.3.1
                    
Install buffer as a Cake Addin
#tool nuget:?package=buffer&version=3.3.1
                    
Install buffer as a Cake Tool

⚡️ Better Input for C# with buffer

Buffer package in action

NuGet Downloads GitHub Actions Workflow Status NuGet Version

Ever wished Console.ReadLine() could give you real-time input? Want full control over what the user types as they type it?

Introducing buffer — a lightweight NuGet package that gives you real-time input handling and total buffer control in C#. Perfect for building interactive CLI tools, REPLs, or anything where ReadLine() just doesn’t cut it.


✨ Features

  • Real-time updates while users type
  • 📜 Real-time Syntax highlighting.
  • 🧠 Manual control over the input buffer
  • 🧵 Thread-safe & supports multithreading
  • 🔠 Access buffer as char[] or string
  • 💻 Compatible with a wide range of .NET Frameworks
  • 🎉 Emoji support for fun prompts
  • 🔒 Secure input handling
  • 🛠️ Easy to use and integrate
  • 📦 Lightweight and fast
  • 🔧 Customizable buffer size

🚀 Quick Start

🧩 Installation

Add it via CLI:

dotnet add package buffer

Or visit the NuGet page →


🔧 How It Works

  1. Initialize the input buffer
    • With a buffer size
    • Without a buffer size
  2. Start listening for input
  3. Read the buffer manually as char[] or string
  4. Clear the buffer when you’re done

🧪 Example

using Prad.Buffer;

...
PradBuffer InputBuffer = new PradBuffer();

// Start capturing input (does NOT return value)
InputBuffer.GetInput();

// Read it manually
string value = InputBuffer.GetBufferAsString();

// Clear when done
InputBuffer.ClearBuffer();

🧩 Manual Buffer Size Example

using Prad.Buffer;

...
PradBuffer InputBuffer = new PradBuffer(10);

// Start capturing input (does NOT return value)
InputBuffer.GetInput(); // Only 10 characters can be stored. (0 to 9)

// Read it manually
string value = InputBuffer.GetBufferAsString();

// Clear when done
InputBuffer.ClearBuffer();

Here is a demo of Limited Buffer Size of 10 characters

buffer-limit

🧩 Syntax Highlighting in Real-time

PradBuffer Buffer = new PradBuffer();

Console.WriteLine("Enter something to get started, ");

string s = "";

// Supports Console Colors
Buffer.SyntaxHighlights.Add("prad", ConsoleColor.Red);

// Supports Integers, color will be selected with respective to ConsoleColor enum.
Buffer.SyntaxHighlights.Add("static", 9);

// Directly supports ANSI Escape codes. **Beware any mistakes CAN and WILL break the input.**
Buffer.SyntaxHighlights.Add("public", "\x1b[32m"); // Green ANSI Escape code.

// ! Throws exception if any other data type is being used.
// Buffer.SyntaxHighlights.Add("=", 56.3d);

Buffer.EnableSyntaxHighlighting = true;

while(true){
    Buffer.GetInput("> ");

    s = Buffer.GetBufferAsString();

    Buffer.ClearBuffer();

    if(s == "exit") break;

    Console.WriteLine($"Value Entered : \"{s}\"");
}
Demo of Syntax Highlighting

Syntax Highlighting Demo

🚀 Using its maximum potential

Here is a code example which uses Multithreading to get the input buffer in real-time.

using Prad.Buffer;

class sample_program {
    static PradBuffer buffer = new PradBuffer();

    static void Main(string[] args) {
        Thread thread = new Thread(invoker);
        thread.Start();

        buffer.GetInput("command > ");

        string value = buffer.GetBufferAsString();

        buffer.ClearBuffer();

        Console.WriteLine(value);
    }

    static void invoker(){
        if(buffer.Length > 0)
            Console.WriteLine(buffer.GetBufferAsString());

        Thread.Sleep(1000);
        invoker();
    }
}

🛠️ Unlock the full power of buffer by using multi-threading to get realtime data even before the user has completed typing.


🛠 Overloaded Input Methods

Option 1 – No prompt

InputBuffer.GetInput();
<waits here for input>

Option 2 – With custom prompt

InputBuffer.GetInput("command > ");
command > <waits here for input>

🤝 Contributing

Contributions are always welcome!

Steps

# 1. Fork the repo
# 2. Create a branch
git checkout -b feature-name

# 3. Make changes & commit
git commit -m "Add feature-name"

# 4. Push and open PR
git push origin feature-name

Please:

  • Stick to the existing code style
  • Write helpful commit messages
  • Document new features
  • Add tests when possible ✅


Give it a ⭐ if you like it and share it with your fellow devs!

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.3.1 154 4/14/2025
3.3.0 149 4/14/2025
3.2.0 156 4/14/2025
3.1.0 152 4/14/2025
3.0.0 149 4/13/2025
2.1.3 95 4/13/2025
2.1.2 90 4/13/2025
2.1.1 131 4/9/2025
2.1.0 126 4/9/2025
2.0.1 125 4/8/2025
2.0.0 122 4/8/2025
1.2.0 126 4/7/2025
1.1.3 131 4/6/2025
1.1.2 128 4/6/2025
1.1.1 96 4/6/2025
1.1.0 97 4/6/2025
1.0.0 119 4/1/2025