Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
version 1.2.1
- Loading branch information
1 parent
5c8d737
commit 72b56a0
Showing
7 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 1.2.1 | ||
|
||
* Fix detecting number of colors when `tput` exists, but | ||
fails with an error and/or does not return anything useful. | ||
(@jimhester, #18, #19) | ||
|
||
# 1.2.0 | ||
|
||
* Fix detection of number of colors, it was cached from | ||
installation time (#17). | ||
|
||
* Color aware string operations. They are slow and experimental | ||
currently. | ||
|
||
# 1.1.0 | ||
|
||
* `show_ansi_colors()` prints all supported colors on the screen. | ||
|
||
* 256 colors, on terminals that support it. | ||
|
||
* Disable colors on Windows, they are not supported in the default setup. | ||
|
||
# 1.0.0 | ||
|
||
* First released version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
|
||
# Crayon - stylish terminal output in R | ||
|
||
[](https://travis-ci.org/gaborcsardi/crayon) | ||
[](https://ci.appveyor.com/project/gaborcsardi/crayon) | ||
[](http://cran.rstudio.com/web/packages/crayon/index.html) | ||
[](http://cran.r-project.org/web/packages/crayon/index.html) | ||
|
||
With crayon it is easy to add color to terminal output, create styles | ||
for notes, warnings, errors; and combine styles. | ||
|
||
ANSI color support is automatically detected and used. Crayon was largely | ||
inspired by [chalk](https://github.com/sindresorhus/chalk). | ||
|
||
## Installation | ||
|
||
```r | ||
devtools::install_github("gaborcsardi/crayon") | ||
library(crayon) | ||
``` | ||
|
||
## Styles | ||
|
||
Crayon defines several styles, that can be combined. Each style in the list | ||
has a corresponding function with the same name. | ||
|
||
### General styles | ||
|
||
* `reset` | ||
* `bold` | ||
* `blurred` (usually called `dim`, renamed to avoid name clash) | ||
* `italic` (not widely supported) | ||
* `underline` | ||
* `inverse` | ||
* `hidden` | ||
* `strikethrough` (not widely supported) | ||
|
||
### Text colors | ||
|
||
* `black` | ||
* `red` | ||
* `green` | ||
* `yellow` | ||
* `blue` | ||
* `magenta` | ||
* `cyan` | ||
* `white` | ||
* `silver` (usually called `gray`, renamed to avoid name clash) | ||
|
||
### Background colors | ||
|
||
* `bgBlack` | ||
* `bgRed` | ||
* `bgGreen` | ||
* `bgYellow` | ||
* `bgBlue` | ||
* `bgMagenta` | ||
* `bgCyan` | ||
* `bgWhite` | ||
|
||
### Screenshot on OSX | ||
|
||
 | ||
|
||
## Usage | ||
|
||
The styling functions take any number of character vectors as arguments, | ||
and they concatenate and style them: | ||
|
||
```r | ||
library(crayon) | ||
cat(blue("Hello", "world!\n")) | ||
``` | ||
|
||
Crayon defines the `%+%` string concatenation operator, to make it easy | ||
to assemble stings with different styles. | ||
|
||
```r | ||
cat("... to highlight the " %+% red("search term") %+% " in a block of text\n") | ||
``` | ||
|
||
Styles can be combined using the `$` operator: | ||
|
||
```r | ||
cat(yellow$bgMagenta$bold('Hello world!\n')) | ||
``` | ||
|
||
Styles can also be nested, and then inner style takes precedence: | ||
|
||
```r | ||
cat(green( | ||
'I am a green line ' %+% | ||
blue$underline$bold('with a blue substring') %+% | ||
' that becomes green again!\n' | ||
)) | ||
``` | ||
|
||
It is easy to define your own themes: | ||
|
||
```r | ||
error <- red $ bold | ||
warn <- magenta $ underline | ||
note <- cyan | ||
cat(error("Error: subscript out of bounds!\n")) | ||
cat(warn("Warning: shorter argument was recycled.\n")) | ||
cat(note("Note: no such directory.\n")) | ||
``` | ||
|
||
## 256 colors | ||
|
||
Most modern terminals support the ANSI standard for 256 colors, | ||
and you can define new styles that make use of them. The `make_style` | ||
function defines a new style. It can handle R's built in color names | ||
(see the output of `colors()`), and also RGB specifications, via the | ||
`rbg()` function. It automatically chooses the ANSI colors that | ||
are closest to the specified R and RGB colors, and it also has | ||
a fallback to terminals with 8 ANSI colors only. | ||
|
||
```r | ||
ivory <- make_style("ivory") | ||
bgMaroon <- make_style("maroon", bg = TRUE) | ||
fancy <- combine_styles(ivory, bgMaroon) | ||
cat(fancy("This will have some fancy colors"), "\n") | ||
``` | ||
|
||
 |