https://github.com/iskaa02/qalam
an easy to use terminal styling library
https://github.com/iskaa02/qalam
ansi go golang
Last synced: 5 months ago
JSON representation
an easy to use terminal styling library
- Host: GitHub
- URL: https://github.com/iskaa02/qalam
- Owner: iskaa02
- License: mit
- Created: 2022-01-17T13:11:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-11T12:35:26.000Z (about 4 years ago)
- Last Synced: 2024-06-19T01:11:54.594Z (about 2 years ago)
- Topics: ansi, go, golang
- Language: Go
- Homepage:
- Size: 244 KB
- Stars: 42
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE.txt
Awesome Lists containing this project
README
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
Table of Contents
## About The Project

Qalam is A terminal Styling library built for Go to make building cool-looking CLIs easier
### IMPORTANT
The project still in early state it might have breaking changes in the future
## Getting Started
There is Two Ways to use Qalam
1. Using [Styler](#with-styler)
2. Using [BBcode format](#with-bbcode-format)
### Installation
```bash
go get github.com/iskaa02/qalam
```
## Usage
### With Styler
```go
import "github.com/iskaa02/qalam"
func main(){
s:=qalam.NewStyler().
Bold().
Italic().
Red()
// This will print bold italic red text to the terminal
s.Print("Hello world")
// Change background color
s.YellowBackground()
// use hex color as foreground color
s.Hex("#e28421")
// use hex color as background color
s.BackgroundHex("#e28421")
// Flip Foreground and background colors
s.Invert()
// Make Text blink
s.Blink()
}
```
Removing Styles
```go
// You can remove any style added previously
s.Remove("bold","blink","bg#e28421")
```
reference [code table](#code-table) below
### With BBcode Format
```go
import "github.com/iskaa02/qalam/bbcode"
func main(){
// this will output "a red text" with red in terminal
// you can use bbcode.Sprintf() if you don't want to print yet
bbcode.Printf("[red]a red %s[/red]","text")
}
```
## BBcode Examples
### Multiple styles
```go
bbcode.Printf("[b s]bold and strikethrough[/b s]")
```
outputs:
~~**bold and strikethrough**~~
### Composing styles
```go
bbcode.Printf("[b]bold only [i]bold and italic[/i][/b]")
```
outputs:
**bold only** **_bold and italic_**
## Code Table
| Code | Style |
| --------------- | -------------------------------------------------------- |
| b/bold | **bold text** |
| i/italic | _italic text_ |
| u/underline | underline text |
| s/strikethrough | ~~strikethrough text~~ |
| #hexcode | change the color |
| bg#hexcode | change the background color |
| red | change the color to red |
| yellow | change the color to yellow |
| magenta | change the color to magenta |
| white | change the color to white |
| black | change the color to black |
| green | change the color to green |
| cyan | change the color to cyan |
| bg.(color) | change the background color to any color mentioned above |
## Gradient
### Import
```go
import "github.com/iskaa02/qalam/gradient"
```
### Usage
```go
g,err:=gradient.NewGradient("cyan","red")
// if the passed colors are not valid an error is returned
// supports all css valid colors
if err != nil{
}
g.Print("Example gradient from Cyan to Red")
```
outputs the following

For more examples [checkout gradient Readme](https://github.com/iskaa02/qalam/blob/main/gradient/README.MD)
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
Distributed under the MIT License. See `LICENSE.txt` for more information.
## Notes
### Windows Support
If you're on Windows, use [Windows Terminal](https://github.com/microsoft/terminal) instead of cmd.exe.
#
### What does the Qalam mean
Qalam in Arabic means pencil
# Contact
Ismael Karim - ismael.karim000@gmail.com
Project Link: [https://github.com/iskaa02/qalam](https://github.com/iskaa02/qalam)
[contributors-shield]: https://img.shields.io/github/contributors/iskaa02/qalam.svg?style=for-the-badge
[contributors-url]: https://github.com/iskaa02/qalam/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/iskaa02/qalam.svg?style=for-the-badge
[forks-url]: https://github.com/iskaa02/qalam/network/members
[stars-shield]: https://img.shields.io/github/stars/iskaa02/qalam.svg?style=for-the-badge
[stars-url]: https://github.com/iskaa02/qalam/stargazers
[issues-shield]: https://img.shields.io/github/issues/iskaa02/qalam.svg?style=for-the-badge
[issues-url]: https://github.com/iskaa02/qalam/issues
[license-shield]: https://img.shields.io/github/license/iskaa02/qalam.svg?style=for-the-badge
[license-url]: https://github.com/iskaa02/qalam/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/linkedin_username
[product-screenshot]: images/screenshot.png