Giter Site home page Giter Site logo

clucolor's Introduction

cluColor

Build Status Apache licensed crates.io Documentation

Methods for formatted recording of color output.

[DEPRECATED, please use https://github.com/clucompany/cluEscSequency]

Easy methods of formatted recording

#[macro_use]
extern crate clucolor;

let str_colored = color!(blue, "test");
println!("{}", str_colored);

let str_colored = color!(blue, bold, "test");
println!("{}", str_colored);


let str_colored = color!(bright_red, bold, "test");
println!("{}", str_colored);

Generating a string using color types

#[macro_use]
extern crate clucolor;

use clucolor::colors::cluColor;
use clucolor::colors::BrightRed;

let string = BrightRed::string_fmt( format_args!("[{:?}] {}", TEST, str) );
let string = BrightRed::stringn( "color str!" );

Recording macros in Write trait

#[macro_use]
extern crate clucolor;

use clucolor::colors::Blue;
use clucolor::colors::BrightBlue;


writen_color!(&mut ::std::io::stdout(), BrightBlue, "OutValueTest {}", 123);
writen_color!(&mut ::std::io::stdout(), BrightBlue, "OutValueTest2 {}", 12345);
writen_color!(&mut File::open("color_file.txt"), BrightBlue, "Color Str:)", 12345);

Recording using color types

#[macro_use]
extern crate clucolor;

use clucolor::colors::Blue;
use clucolor::colors::BrightBlue;


let mut vec: Vec<u8> = Vec::new(); // For Vec implemented Write!!


let _e = BrightBlue::write_str(&mut vec, "color str!" );

let _e = vec.write(b"TestValue"); // For Vec implemented Write!!
//Also this value will remain without color formatting.

let _e = BrightBlue::writen_str(&mut vec, "end str.." );

let _e = BrightRed::writen(&mut vec, b"end value.." );

Use move color arguments

#[macro_use]
extern crate clucolor;

use clucolor::colors::BrightBlue;

#[derive(Debug, Default)]
pub struct Items(usize, usize);

impl Items {
     #[inline]
     pub fn count(&self) -> usize {
	  self.0 + self.1
     }
}

let mut item = Items::default();

for a in 0..15 {
     BrightGreen::with_color_fmt(format_args!("NUM #{}", a), |fmt_num| {
	  BrightBlue::with_color_fmt(format_args!("ITEM #{:?}", item), |fmt_item| {
	       BrightRed::with_color_fmt(format_args!("ALL_COUNT {}", item.count()), |fmt_count| {
		    println!("{}, {}; {};", fmt_num, fmt_item, fmt_count);
	       });
	  });
     });

     item.0 += 1;
     item.1 += 2;
}

Use ColorWriter

#[macro_use]
extern crate clucolor;

use clucolor::colors::Blue;

let writer = Blue::writer();

let stdout = ::std::io::stdout();
let mut lock_stdio = stdout.lock();

writer.writen(&mut lock_stdio, b"TestWriten").unwrap();

All other functions are implemented in color mod with the help of cluColor!

License

Copyright 2018 #UlinProject Денис Котляров

Licensed under the Apache License, Version 2.0

clucolor's People

Contributors

denisandroid avatar

Watchers

 avatar  avatar

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.