Skip to content

Commit 6b1e5e6

Browse files
Fixed gif not showing in nuget website, Insanely improved readme. (version 2.1.2)
1 parent ac91102 commit 6b1e5e6

File tree

2 files changed

+129
-65
lines changed

2 files changed

+129
-65
lines changed

buffer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Nullable>enable</Nullable>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99

10-
<Version>2.1.1</Version>
10+
<Version>2.1.2</Version>
1111
<Authors>Pradosh (helloImPR)</Authors>
1212
<Description>A fast, completely controllable input method solution for C#.</Description>
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>

readme.md

Lines changed: 128 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,164 @@
1-
![Buffer package in action](./buffer.gif)
1+
# ⚡️ Better Input for C# with `buffer`
22

3-
## Better Input for C#
3+
![Buffer package in action](https://raw.githubusercontent.com/pradosh-arduino/buffer/ac911024b63e8a7f5b245be591859991fe23aec4/buffer.gif)
44

5-
Have you ever wondered if you could get the values of what users are typing in real time with `Console.ReadLine()` function? or do you want full control of input?
5+
Ever wished `Console.ReadLine()` could give you real-time input? Want full control over what the user types *as they type it*?
66

7-
Well don't worry! This `buffer` nuget package aims to solve the issues of `ReadLine()` and gives more control to the user!
7+
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.
88

9-
### Features
10-
- Data updates in real time.
11-
- Control of buffer when to clear and when to call next time.
12-
- Directly get the buffer as a character array.
13-
- Supports multithreading to have extra control.
14-
- Supports a wide range of .NET Frameworks.
9+
---
1510

16-
### Usage
11+
## ✨ Features
1712

18-
#### Process
19-
```md
20-
1. Initialize the object
21-
2. Get the input from the user (does **not** return the value)
22-
3. Read the buffer to get the values by using two methods
23-
1. Get the buffer as char[] itself.
24-
2. Get the buffer as a string.
25-
4. Clear the buffer (you have to do it **manually** by invoking a method)
13+
- ✅ Real-time updates while users type
14+
- 🧠 Manual control over the input buffer
15+
- 🧵 Thread-safe & supports multithreading
16+
- 🔠 Access buffer as `char[]` or `string`
17+
- 💻 Compatible with a wide range of .NET Frameworks
18+
19+
---
20+
21+
## 🚀 Quick Start
22+
23+
### 🧩 Installation
24+
25+
Add it via CLI:
26+
27+
```bash
28+
dotnet add package buffer
2629
```
2730

28-
#### Example Usage
31+
Or visit the [NuGet page →](https://www.nuget.org/packages/buffer)
32+
33+
---
34+
35+
## 🔧 How It Works
36+
37+
1. Initialize the input buffer
38+
- With a buffer size
39+
- Without a buffer size
40+
2. Start listening for input
41+
3. Read the buffer manually as `char[]` or `string`
42+
4. Clear the buffer when you’re done
43+
44+
### 🧪 Example
45+
2946
```cpp
3047
PradBuffer InputBuffer = new PradBuffer();
3148

49+
// Start capturing input (does NOT return value)
3250
InputBuffer.GetInput();
3351

52+
// Read it manually
3453
string value = InputBuffer.GetBufferAsString();
3554

55+
// Clear when done
3656
InputBuffer.ClearBuffer();
3757
```
3858

39-
### Input process
40-
The input function is overloaded so there are two different ways to use it.
59+
### 🧩 Manual Buffer Size Example
60+
61+
```csharp
62+
PradBuffer InputBuffer = new PradBuffer(10);
63+
64+
// Start capturing input (does NOT return value)
65+
InputBuffer.GetInput(); // Only 10 characters can be stored. (0 to 9)
66+
67+
// Read it manually
68+
string value = InputBuffer.GetBufferAsString();
69+
70+
// Clear when done
71+
InputBuffer.ClearBuffer();
72+
```
73+
74+
### 🚀 Using its maximum potential
75+
76+
Here is a code example which uses Multithreading to get the input buffer in real-time.
4177

42-
#### Method 1
43-
`code.cs`
4478
```cpp
45-
InputBuffer.GetInput();
79+
using prad;
80+
81+
class sample_program {
82+
static PradBuffer buffer = new PradBuffer();
83+
84+
static void Main(string[] args) {
85+
Thread thread = new Thread(invoker);
86+
thread.Start();
87+
88+
buffer.GetInput("command > ");
89+
90+
string value = buffer.GetBufferAsString();
91+
92+
buffer.ClearBuffer();
93+
94+
Console.WriteLine(value);
95+
}
96+
97+
static void invoker(){
98+
if(buffer.Length > 0)
99+
Console.WriteLine(buffer.GetBufferAsString());
100+
101+
Thread.Sleep(1000);
102+
invoker();
103+
}
104+
}
46105
```
47106

48-
`output:`
107+
🛠️ Unlock the full power of `buffer` by using multi-threading to get realtime data even before the user has completed typing.
108+
109+
---
110+
111+
## 🛠 Overloaded Input Methods
112+
113+
### Option 1 – No prompt
114+
```cpp
115+
InputBuffer.GetInput();
49116
```
117+
```txt
50118
<waits here for input>
51119
```
52120

53-
#### Method 2
54-
`code.cs`
121+
### Option 2 – With custom prompt
55122
```cpp
56123
InputBuffer.GetInput("command > ");
57124
```
58-
59-
`output:`
60-
```
125+
```txt
61126
command > <waits here for input>
62127
```
63128

64-
### Importing the package
65-
You can check out the [nuget.org](https://www.nuget.org/packages/buffer) site for extra detailed installation.
129+
---
130+
131+
## 🤝 Contributing
132+
133+
Contributions are always welcome!
66134

67-
For simply just dotnet :
135+
### Steps
68136
```bash
69-
dotnet add package buffer
137+
# 1. Fork the repo
138+
# 2. Create a branch
139+
git checkout -b feature-name
140+
141+
# 3. Make changes & commit
142+
git commit -m "Add feature-name"
143+
144+
# 4. Push and open PR
145+
git push origin feature-name
70146
```
71147

72-
### Contributing
73-
74-
Contributions are welcome! Please follow these steps:
75-
76-
1. Fork the repository.
77-
2. Create a new branch:
78-
```bash
79-
git checkout -b feature-name
80-
```
81-
3. Commit your changes:
82-
```bash
83-
git commit -m "Add feature-name"
84-
```
85-
4. Push to your branch:
86-
```bash
87-
git push origin feature-name
88-
```
89-
5. Open a pull request.
90-
91-
### Contribution guidelines
92-
- Follow the existing code style.
93-
- Write clear and concise commit messages.
94-
- Ensure that your code is well-documented.
95-
- Write tests for new features and ensure all tests pass before submitting a pull request.
96-
97-
### Links
98-
- [NuGet Package](https://www.nuget.org/packages/buffer)
99-
- [Github source code](https://github.com/pradosh-arduino/buffer)
100-
- [Blog Post](https://dev.to/pradcode/better-input-method-for-c-4hnb)
148+
### Please:
149+
- Stick to the existing code style
150+
- Write helpful commit messages
151+
- Document new features
152+
- Add tests when possible ✅
153+
154+
---
155+
156+
## 🔗 Links
157+
158+
- 📦 [NuGet Package](https://www.nuget.org/packages/buffer)
159+
- 🧑‍💻 [GitHub Source](https://github.com/pradosh-arduino/buffer)
160+
- 📝 [Blog Post](https://dev.to/pradcode/better-input-method-for-c-4hnb)
161+
162+
---
163+
164+
Give it a ⭐ if you like it and share it with your fellow devs!

0 commit comments

Comments
 (0)