Rusty-tui 0.1.0

A simple TUI library for making CLI applications with ease.
Documentation
# InputBox Documentation

Welcome to the `InputBox` section of our TUI library! This document will guide you through the features and functionalities of the `InputBox` struct, which allows users to input text in a console application.

## Overview

The `InputBox` struct provides a simple interface for users to enter text, complete with a placeholder for guidance. It's perfect for scenarios where user input is required, like forms or search boxes in terminal applications.

### Struct Definition

```rust
pub struct InputBox {
    pub input: String,   // The text entered by the user
    placeholder: String, // A placeholder text to display when input is empty
    x: u16,              // The x-coordinate (horizontal position) where the input box will be drawn
    y: u16,              // The y-coordinate (vertical position) where the input box will be drawn
}
```

### Creating an InputBox

To create a new input box, use the `new` method. This method initializes the input box with optional placeholder text.

```rust
pub fn new(input: &str, placeholder: &str, x: u16, y: u16) -> Self {
```

#### Arguments

- `input`: A string slice that holds the initial text of the input box.
- `placeholder`: A string slice that holds the placeholder text to display when the input box is empty.
- `x`: The horizontal position (x-coordinate) where the input box will be drawn.
- `y`: The vertical position (y-coordinate) where the input box will be drawn.

#### Returns

- A new instance of `InputBox`.

### Retrieving Input

To get input from the user, call the `get_input` method. This method displays the input box at the specified position and handles user input, including character input and backspace.

```rust
pub fn get_input(&mut self) -> io::Result<String> {
```

#### Returns

- An `io::Result<String>` containing the input entered by the user or an error if the read operation fails.

#### Example

```rust
let mut input_box = InputBox::new("", "Enter text here", 5, 10);
let user_input = input_box.get_input().unwrap(); // Gets user input
```

### Handling User Input

The `get_input` method handles several scenarios:

- **Displaying Placeholder**: When the input is empty, the placeholder text is displayed.
- **Character Input**: Characters are appended to the input string and displayed immediately.
- **Backspace Handling**: The backspace key allows users to delete the last character in the input.
- **Finalizing Input**: Pressing the Enter key finalizes the input and exits the loop.