An open API service indexing awesome lists of open source software.

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

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]





✏️


Qalam



Easy Terminal styling using go




Report Bug
·
Request Feature


Table of Contents



  1. About The Project

  2. Getting Started


  3. Usage


  4. BBcode Exmaples

  5. Gradient

  6. Contributing

  7. License

  8. Notes

  9. Contact

## About The Project

![Example for what qalam can do](./doc/images/qalam_example.png)

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

(back to top)

## 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")
}
```

(back to top)

## 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 |

(back to top)

## 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

![gradient Example](./doc/images/gradient_example1.png)

For more examples [checkout gradient Readme](https://github.com/iskaa02/qalam/blob/main/gradient/README.MD)

(back to top)

## 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

(back to top)

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

(back to top)

## 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)

(back to top)

[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