Skip to content

Commit e410993

Browse files
committed
f
1 parent 48c1176 commit e410993

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,112 @@ You can customize the build with the following CMake options:
105105
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
106106
4. Push to the branch (`git push origin feature/AmazingFeature`)
107107
5. Open a Pull Request
108+
109+
# SinesBox Library Documentation
110+
111+
## Overview
112+
113+
SinesBox is a C++ library for creating colorful, customizable text boxes in terminal applications. It provides an easy-to-use interface for drawing text boxes with various styling options, including color selection, bold formatting, and rainbow-styled borders.
114+
115+
## Features
116+
117+
- Customizable text box drawing
118+
- Support for multiple text colors
119+
- Border styling (normal and bold)
120+
- Background color options
121+
- Automatic text wrapping
122+
- Rainbow border mode
123+
- UTF-8 compatible
124+
125+
## Installation
126+
127+
### Prerequisites
128+
- C++ compiler with C++11 support
129+
- Linux or macOS (uses `sys/ioctl.h` for terminal width detection)
130+
131+
### Basic Usage
132+
133+
```cpp
134+
#include "SinesBox.h"
135+
#include "SinesGlobalSettings.h"
136+
137+
int main() {
138+
// Initialize global settings (UTF-8 support)
139+
SinesBoxLib::SinesGlobalSettings::initialize();
140+
141+
// Create a SinesBox instance
142+
SinesBoxLib::SinesBox box;
143+
144+
// Set text and styling
145+
box.setText("Hello, World! This is a sample text box.");
146+
box.setTextColor("green");
147+
box.setBorderColor("blue");
148+
box.setBorderBold(true);
149+
150+
// Draw the box
151+
box.draw();
152+
153+
return 0;
154+
}
155+
```
156+
157+
## API Reference
158+
159+
### `SinesBox` Class Methods
160+
161+
#### Constructors
162+
- `SinesBox()`: Creates a new SinesBox instance with default settings
163+
164+
#### Text Methods
165+
- `void setText(const std::string& text)`: Sets the text to be displayed in the box
166+
- Automatically wraps text to fit terminal width
167+
168+
#### Color Methods
169+
- `void setBorderColor(const std::string& color)`: Sets the border color
170+
- `void setTextColor(const std::string& color)`: Sets the text color
171+
- `void setBackgroundColor(const std::string& color)`: Sets the background color
172+
173+
#### Style Methods
174+
- `void setBorderBold(bool bold)`: Enables/disables bold border
175+
- `void setTextBold(bool bold)`: Enables/disables bold text
176+
177+
#### Rendering Methods
178+
- `void draw()`: Draws the text box with current settings
179+
- `void drawRainbow()`: Draws the text box with rainbow-colored borders
180+
181+
### Supported Colors
182+
183+
The library supports the following colors:
184+
- Basic colors: black, red, green, yellow, blue, magenta, cyan, white
185+
- Bright colors: brightblack, brightred, brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, brightwhite
186+
187+
## Global Settings
188+
189+
`SinesGlobalSettings::initialize()` sets the locale to UTF-8, ensuring proper character rendering on Linux systems.
190+
191+
## Example Scenarios
192+
193+
### Rainbow Border Box
194+
```cpp
195+
SinesBoxLib::SinesBox rainbowBox;
196+
rainbowBox.setText("Colorful rainbow border with text!");
197+
rainbowBox.drawRainbow();
198+
```
199+
200+
### Styled Informational Box
201+
```cpp
202+
SinesBoxLib::SinesBox infoBox;
203+
infoBox.setText("Important message with green border and yellow text");
204+
infoBox.setBorderColor("green");
205+
infoBox.setTextColor("yellow");
206+
infoBox.setBorderBold(true);
207+
infoBox.draw();
208+
```
209+
210+
## Limitations
211+
- Requires terminal support for ANSI color codes
212+
- Works best on Unix-like systems (Linux, macOS)
213+
- Terminal width detection might not work perfectly on all systems
214+
215+
## Contributing
216+
Contributions are welcome! Please submit pull requests or open issues on the project repository.

0 commit comments

Comments
 (0)