GithubHelp home page GithubHelp logo

spytheman / crayon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thecodrr/crayon

0.0 2.0 0.0 12 KB

πŸ–οΈ Paint your terminal output like Picasso 🎨

License: MIT License

V 98.32% Shell 1.11% AMPL 0.57%

crayon's Introduction

πŸ–οΈ Crayon

An extremely simple way to turn your bland terminal output into beautifully styled text.

Installation:

Install using vpkg or vpm (not available currently)

vpkg get https://github.com/thecodrr/crayon
vpm get https://github.com/thecodrr/crayon crayon

Install using git:

cd path/to/your/project
git clone https://github.com/thecodrr/crayon
# Or add it as a submodule
git submodule add https://github.com/thecodrr/crayon crayon && git submodule update --init --recursive

Then in the wherever you want to use it:

import crayon

And that's it!

Usage

crayon.new(texts ...string)

Initializes a new Crayon for the specified text. You can pass multiple strings in the texts argument. Nesting Crayons is supported (see example below).

crayon.new returns a Chalk by default. Turn it into a styled string using the .str() function

crayon.new("Hello", crayon.new("world").bold().str()).cyan().underline().str()

crayon.color(text string)

Use this to style the text using the template API.

crayon.color("{bold.underline I am bold and underlined} and I am not")

Each template starts with { and ends with }. All styles must come at the beginning without any spaces. This function returns a string by default. You can use rgb function as rgb(92,92,92) to use custom colors.

Nested templates are currently not supported (WIP) so keep in mind that.

crayon.strip_text(text string)

Strip a styled string of all the styles returning a pure & clean string

The Crayon struct

The template API uses these same names just without the () except for the rgb usage.

Styles:

bold()

italic()

reverse()

underline()

strikethrough()

dim()

slow_blink()

rapid_blink()

Colors:

For background colors just put bg_ before each method

black()

white()

red()

green()

yellow()

blue()

magenta()

cyan()

light_gray()

dark_gray()

light_red()

light_green()

light_yellow()

light_blue()

light_magenta()

light_cyan()

RGB Support

rbg(int,int,int)

Other Methods:

strip() Strip the Crayon of all styles. Returns a string

len() Get the actual length of the styled string. Same as doing strip().len()

print()Print the styled stringtoterminal.

print_with(...string)Print the styled string to terminal with some additional strings

Find this library useful? ❀️

Support it by joining stargazers for this repository. ⭐or [buy me a cup of coffee](https://ko-fi.com/thecodrr And follow me for my next creations! 🀩

License

Copyright 2019 thecodrr (Abdullah Atta)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.