diff options
Diffstat (limited to 'vendor/color-print')
-rw-r--r-- | vendor/color-print/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/color-print/Cargo.toml | 8 | ||||
-rw-r--r-- | vendor/color-print/LICENSE-APACHE | 176 | ||||
-rw-r--r-- | vendor/color-print/LICENSE-MIT | 23 | ||||
-rw-r--r-- | vendor/color-print/README.md | 85 | ||||
-rw-r--r-- | vendor/color-print/src/lib.rs | 91 |
6 files changed, 288 insertions, 97 deletions
diff --git a/vendor/color-print/.cargo-checksum.json b/vendor/color-print/.cargo-checksum.json index 871d737ec..61950cc41 100644 --- a/vendor/color-print/.cargo-checksum.json +++ b/vendor/color-print/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"97eb241a94d6f8a01f4d50ed811f69eef330ee6b6f03dd5d51d64f8efab2a229","README.md":"09328783ec3cb27264a3e680ce47ac2526ccb1d7f477660426c44ba4dee8dcf2","src/lib.rs":"f54df22e565638b204adf93385728cba2d4fa049b8ef4e92d03f7f02a5aafcf1","src/terminfo/color.rs":"2e107814075997bb2c5f62c35e0a2f2f13fdb2c971657147c7038878629b014a","src/terminfo/mod.rs":"928c664c0b8f034cde427eb99f534d810d11ddfb12c30930dabc8a3d3c0dd675","src/terminfo/style.rs":"5c664ed3b1f285796dfb57bca4f60e18224f235ede9b30ca4c8a949112b1f989"},"package":"f2a5e6504ed8648554968650feecea00557a3476bc040d0ffc33080e66b646d0"}
\ No newline at end of file +{"files":{"Cargo.toml":"2da886b5fa05f2a2e0137c8e0a537fefe4bd2a571a109a6f1c747fdb9b6ab641","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"53b1e4d8492a4cabff5baf358b304143da3276ef11e0d8880e12ef11904913aa","src/lib.rs":"d8bb0478b4e402ff9e56b1be5ad31cf8d402fdd46ff1d040ed1bb90a64079bf8","src/terminfo/color.rs":"2e107814075997bb2c5f62c35e0a2f2f13fdb2c971657147c7038878629b014a","src/terminfo/mod.rs":"928c664c0b8f034cde427eb99f534d810d11ddfb12c30930dabc8a3d3c0dd675","src/terminfo/style.rs":"5c664ed3b1f285796dfb57bca4f60e18224f235ede9b30ca4c8a949112b1f989"},"package":"7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d"}
\ No newline at end of file diff --git a/vendor/color-print/Cargo.toml b/vendor/color-print/Cargo.toml index 72a4386f7..0622b21c8 100644 --- a/vendor/color-print/Cargo.toml +++ b/vendor/color-print/Cargo.toml @@ -12,9 +12,9 @@ [package] edition = "2018" name = "color-print" -version = "0.3.4" +version = "0.3.5" authors = ["Johann David <johann.david.dev@protonmail.com>"] -description = "Colorize and stylize strings at compile-time, by using an HTML-like syntax" +description = "Colorize and stylize strings for terminal at compile-time, by using an HTML-like syntax" readme = "README.md" keywords = [ "color", @@ -23,10 +23,10 @@ keywords = [ "terminfo", ] license = "MIT OR Apache-2.0" -repository = "https://gitlab.com/yolenoyer/color-print" +repository = "https://gitlab.com/dajoha/color-print" [dependencies.color-print-proc-macro] -version = "0.3.4" +version = "0.3.5" [dependencies.lazy_static] version = "1.4" diff --git a/vendor/color-print/LICENSE-APACHE b/vendor/color-print/LICENSE-APACHE new file mode 100644 index 000000000..1b5ec8b78 --- /dev/null +++ b/vendor/color-print/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/vendor/color-print/LICENSE-MIT b/vendor/color-print/LICENSE-MIT new file mode 100644 index 000000000..31aa79387 --- /dev/null +++ b/vendor/color-print/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/vendor/color-print/README.md b/vendor/color-print/README.md index d721cff83..6b4417421 100644 --- a/vendor/color-print/README.md +++ b/vendor/color-print/README.md @@ -1,6 +1,6 @@ # color-print -Colorize and stylize strings at compile-time, by using an HTML-like syntax. +Colorize and stylize strings for terminal at compile-time, by using an HTML-like syntax. This library provides the following macros: @@ -12,22 +12,21 @@ This library provides the following macros: `cformat!()`, `cprint!()`, and `cprintln!()` have the same syntax as `format!()`, `print!()` and `println!()` respectively, but they accept an additional syntax inside the -format string: HTML-like tags which add terminal colors/styles at compile-time. - -*Note*: these tags are commonly named "*color tags*" in the documentation below. +format string: HTML-like tags which add ANSI colors/styles at compile-time. `cstr!()` only transforms the given string literal into another string literal, without formatting anything else than the colors tag. -`untagged!()` removes all the color tags found in the given string literal. +`untagged!()` removes all the tags found in the given string literal. ### What does it do ? -By default, the provided macros will replace the color tags found in the format string by ANSI +By default, the provided macros will replace the tags found in the format string by ANSI hexadecimal escape codes. E.g.: ```rust cprintln!("HELLO <green>WORLD</green>") +cprintln!("HELLO <green>WORLD</>"); // Alternative, shorter syntax ``` will be replaced by: @@ -44,7 +43,7 @@ each kind of styling/colorizing (see below for more detail). ### Pros -* Styling is processed at compile-time, so the runtime payload is quite inexistant (unless the +* Styling is processed at compile-time, so the runtime payload is inexistant (unless the feature `terminfo` is activated); * Nested tags are well handled, e.g. `"<green>...<blue>...</blue>...</green>"`; * Some optimizations are performed to avoid redundant ANSI sequences, because these @@ -52,16 +51,12 @@ each kind of styling/colorizing (see below for more detail). * Almost every tag has a short name, so colorizing can be done quickly: `"my <b>blue</> word"`; * Each provided macro can be used exactly in the same way as the standard `format!`-like macros; e.g., positional arguments and named arguments can be used as usual; -* Fine-grained error handling. +* Supports 16, 256 and 16M colors; +* Fine-grained error handling (errors will be given at compile-time). ### Cons -* Many CLI programs detect on runtime if they are actually piped to another command or not, and - decide to colorize their output based on this information. As `color-print` formats strings at - compile-time, this is not possible to do that easily; -* Not compatible with non-ANSI Windows terminals (and not tested at all on Windows, feedbacks - are welcome); -* Not tested on Mac, feedbacks are welcome. +* Not compatible with non-ANSI terminals. ## Introduction @@ -74,8 +69,9 @@ cprintln!("Hello <green>world</green>!"); ### Closing a tag more simply: the `</>` tag -Basically, tags must be closed by giving exactly the same colors/styles of the matching open -tag (with a slash `/` at the beginning). But it can be tedious! +Basically, tags must be closed by giving *exactly* the same colors/styles as their matching +open tag (with a slash `/` at the beginning), e.g: `<blue,bold>...</blue,bold>`. But it can be +tedious! So, it is also possible to close the last open tag simply with `</>`: @@ -85,7 +81,7 @@ cprintln!("Hello <green>world</>!"); ### Combining colors and styles -Multiple styles and color(s) can be combined into a single tag by separating them with the `,` +Multiple styles and colors can be combined into a single tag by separating them with the `,` comma character: ```rust @@ -94,13 +90,14 @@ cprintln!("This a <green,bold>green and bold text</green,bold>."); cprintln!("This a <green,bold>green and bold text</>."); ``` -Of course, combining multiple foreground colors or multiple background colors into the same tag -is useless (in such a case, only the last one is taken into account). - ### Nesting tags -Any tag can be nested with any other, as long as the closing tags match correctly (following -the basic rules of nesting for HTML tags): +Any tag can be nested with any other. + +*Note*: The closing tags must match correctly (following the basic rules of nesting for HTML +tags), but it can always be simplified by using the tag `</>`. + +Example of nested tags: ```rust cprintln!("<green>This is green, <bold>then green and bold</bold>, then green again</green>"); @@ -124,7 +121,8 @@ cprintln!("<green><bold>Hello</></>"); ### How to display the chars `<` and `>` verbatim -As for `{` and `}`, the chars `<` and `>` have to be doubled in order to display them verbatim: +As for `{` and `}` in standard format strings, the chars `<` and `>` have to be doubled in +order to display them verbatim: ```rust cprintln!("This is an angle bracket character: <<, and here is another one: >>"); @@ -133,22 +131,22 @@ cprintln!("This is an angle bracket character: <<, and here is another one: >>") ## Optimization: no redundant ANSI codes The expanded format string will only contain the *needed* ANSI codes. This is done by making a -diff of the different style attributes, each time a color tag is encountered, instead of -mechanically adding the ANSI codes. +diff of the different style attributes, each time a tag is encountered, instead of mechanically +adding the ANSI codes. E.g., several nested `<bold>` tags will only produce one bold ANSI sequence: ```rust -cprintln!("<bold><bold>A <bold,blue>B C D</> E</></>") +cprintln!("<bold><bold> A <bold,blue> B </> C </></>") ``` will be replaced by: ```rust -println!("\u{1b}[1mA \u{1b}[34mB C D\u{1b}[39m E\u{1b}[22m") -// ^-------^ ^--------^ ^--------^ ^--------^ -// bold blue color bold -// reset reset +println!("\u{1b}[1m A \u{1b}[34m B \u{1b}[39m C \u{1b}[22m") +// ^-------^ ^--------^ ^--------^ ^--------^ +// bold blue color bold +// reset reset ``` ## The feature `terminfo` @@ -175,38 +173,37 @@ This has one pro and several cons: `lazy_static`: https://crates.io/crates/lazy_static `terminfo`: https://crates.io/crates/terminfo -## Naming rules of the color tags: +## Naming rules of the tags: -Each color/style tag has at least a long name, like `<magenta>` or `<underline>`. +Each tag has at least a **long name**, like `<magenta>` or `<underline>`. The tags directly relative to *colors* (like `<red>`, `<bg:blue>`, `<bg:bright-green>`..., as opposed to *style* tags like `<bold>`, `<italics>`...) have some common naming rules: - * Each color tag has four variants: + * Each tag has four variants: - `<mycolor>`: the normal, foreground color; - `<bright-mycolor>` or `<mycolor!>`: the bright, foreground color; - - `<bg:mycolor>`: the normal, background color; + - `<bg:mycolor>`, `<MYCOLOR>`: the normal, background color; - `<bg:bright-mycolor>`, `<bg:mycolor!>`, `<BRIGHT-MYCOLOR>` or `<MYCOLOR!>`: the bright, background color; - * Each color tag has a *shortcut*, with a base letter for each color (example with the `x` - letter): + * Each tag has a *shortcut*, with a base letter for each color; example with the `x` letter: - `<x>`: the normal, foreground color; - `<x!>`: the bright, foreground color; - - `<bg:x>` or `<X>`: the normal, background color; - - `<bg:x!>` or `<X!>`: the bright, background color; - * Except for the color `<black>`, each color's shortcut letter is simply the first letter of - its name, e.g. `<y>` is the shortcut for `<yellow>`; - * Each color's tag which is uppercase is a background color; - * Each tag which has a trailing exclamation point `!` is a bright color; + - `<bg:x>`, `<X>`: the normal, background color; + - `<bg:x!>`, `<X!>`: the bright, background color; + * Each color's shortcut letter is simply the **first letter of its name** (excepted for `<k>` + which is the shortcut for `<black>`), e.g. `<y>` is the shortcut for `<yellow>`; + * Each color's tag which is uppercase is a **background color**; + * Each tag which has a trailing exclamation point `!` is a **bright color**; -## List of accepted color/style tags: +## List of accepted tags: The two first columns show which styles are supported, respectively with the default crate features (ANSI column), and with the feature `terminfo` being activated. | ANSI | Terminfo | Shortcuts | Long names | Aliases | | ---- | -------- | --------- | ----------------------- | ----------------------------------------------- | -| X | X | `<s>` | `<bold>` | `<em>` `<strong>` | +| X | X | `<s>` | `<strong>` | `<em>` `<bold>` | | X | X | | `<dim>` | | | X | X | `<u>` | `<underline>` | | | X | | | `<strike>` | | diff --git a/vendor/color-print/src/lib.rs b/vendor/color-print/src/lib.rs index 14535f5db..2a5c1d14a 100644 --- a/vendor/color-print/src/lib.rs +++ b/vendor/color-print/src/lib.rs @@ -1,4 +1,4 @@ -//! Colorize and stylize strings at compile-time, by using an HTML-like syntax. +//! Colorize and stylize strings for terminal at compile-time, by using an HTML-like syntax. //! //! This library provides the following macros: //! @@ -10,24 +10,23 @@ //! //! [`cformat!()`], [`cprint!()`], and [`cprintln!()`] have the same syntax as `format!()`, //! `print!()` and `println!()` respectively, but they accept an additional syntax inside the -//! format string: HTML-like tags which add terminal colors/styles at compile-time. -//! -//! *Note*: these tags are commonly named "*color tags*" in the documentation below. +//! format string: HTML-like tags which add ANSI colors/styles at compile-time. //! //! [`cstr!()`] only transforms the given string literal into another string literal, without //! formatting anything else than the colors tag. //! -//! [`untagged!()`] removes all the color tags found in the given string literal. +//! [`untagged!()`] removes all the tags found in the given string literal. //! //! ## What does it do ? //! -//! By default, the provided macros will replace the color tags found in the format string by ANSI +//! By default, the provided macros will replace the tags found in the format string by ANSI //! hexadecimal escape codes. E.g.: //! //! ``` //! # use color_print::cprintln; //! # fn main() { -//! cprintln!("HELLO <green>WORLD</green>") +//! cprintln!("HELLO <green>WORLD</green>"); +//! cprintln!("HELLO <green>WORLD</>"); // Alternative, shorter syntax //! # } //! ``` //! @@ -48,7 +47,7 @@ //! //! ## Pros //! -//! * Styling is processed at compile-time, so the runtime payload is quite inexistant (unless the +//! * Styling is processed at compile-time, so the runtime payload is inexistant (unless the //! feature `terminfo` is activated); //! * Nested tags are well handled, e.g. `"<green>...<blue>...</blue>...</green>"`; //! * Some optimizations are performed to avoid redundant ANSI sequences, because these @@ -56,16 +55,12 @@ //! * Almost every tag has a short name, so colorizing can be done quickly: `"my <b>blue</> word"`; //! * Each provided macro can be used exactly in the same way as the standard `format!`-like //! macros; e.g., positional arguments and named arguments can be used as usual; -//! * Fine-grained error handling. +//! * Supports 16, 256 and 16M colors; +//! * Fine-grained error handling (errors will be given at compile-time). //! //! ## Cons //! -//! * Many CLI programs detect on runtime if they are actually piped to another command or not, and -//! decide to colorize their output based on this information. As `color-print` formats strings at -//! compile-time, this is not possible to do that easily; -//! * Not compatible with non-ANSI Windows terminals (and not tested at all on Windows, feedbacks -//! are welcome); -//! * Not tested on Mac, feedbacks are welcome. +//! * Not compatible with non-ANSI terminals. //! //! # Introduction //! @@ -78,8 +73,9 @@ //! //! ## Closing a tag more simply: the `</>` tag //! -//! Basically, tags must be closed by giving exactly the same colors/styles of the matching open -//! tag (with a slash `/` at the beginning). But it can be tedious! +//! Basically, tags must be closed by giving *exactly* the same colors/styles as their matching +//! open tag (with a slash `/` at the beginning), e.g: `<blue,bold>...</blue,bold>`. But it can be +//! tedious! //! //! So, it is also possible to close the last open tag simply with `</>`: //! @@ -92,7 +88,7 @@ //! //! ## Combining colors and styles //! -//! Multiple styles and color(s) can be combined into a single tag by separating them with the `,` +//! Multiple styles and colors can be combined into a single tag by separating them with the `,` //! comma character: //! //! ``` @@ -104,13 +100,14 @@ //! # } //! ``` //! -//! Of course, combining multiple foreground colors or multiple background colors into the same tag -//! is useless (in such a case, only the last one is taken into account). -//! //! ## Nesting tags //! -//! Any tag can be nested with any other, as long as the closing tags match correctly (following -//! the basic rules of nesting for HTML tags): +//! Any tag can be nested with any other. +//! +//! *Note*: The closing tags must match correctly (following the basic rules of nesting for HTML +//! tags), but it can always be simplified by using the tag `</>`. +//! +//! Example of nested tags: //! //! ``` //! # use color_print::cprintln; @@ -140,7 +137,8 @@ //! //! ## How to display the chars `<` and `>` verbatim //! -//! As for `{` and `}`, the chars `<` and `>` have to be doubled in order to display them verbatim: +//! As for `{` and `}` in standard format strings, the chars `<` and `>` have to be doubled in +//! order to display them verbatim: //! //! ``` //! # use color_print::cprintln; @@ -152,15 +150,15 @@ //! # Optimization: no redundant ANSI codes //! //! The expanded format string will only contain the *needed* ANSI codes. This is done by making a -//! diff of the different style attributes, each time a color tag is encountered, instead of -//! mechanically adding the ANSI codes. +//! diff of the different style attributes, each time a tag is encountered, instead of mechanically +//! adding the ANSI codes. //! //! E.g., several nested `<bold>` tags will only produce one bold ANSI sequence: //! //! ``` //! # use color_print::cprintln; //! # fn main() { -//! cprintln!("<bold><bold>A <bold,blue>B C D</> E</></>") +//! cprintln!("<bold><bold> A <bold,blue> B </> C </></>") //! # } //! ``` //! @@ -169,10 +167,10 @@ //! ``` //! # use color_print::cprintln; //! # fn main() { -//! println!("\u{1b}[1mA \u{1b}[34mB C D\u{1b}[39m E\u{1b}[22m") -//! // ^-------^ ^--------^ ^--------^ ^--------^ -//! // bold blue color bold -//! // reset reset +//! println!("\u{1b}[1m A \u{1b}[34m B \u{1b}[39m C \u{1b}[22m") +//! // ^-------^ ^--------^ ^--------^ ^--------^ +//! // bold blue color bold +//! // reset reset //! # } //! ``` //! @@ -200,38 +198,37 @@ //! [`lazy_static`]: https://crates.io/crates/lazy_static //! [`terminfo`]: https://crates.io/crates/terminfo //! -//! # Naming rules of the color tags: +//! # Naming rules of the tags: //! -//! Each color/style tag has at least a long name, like `<magenta>` or `<underline>`. +//! Each tag has at least a **long name**, like `<magenta>` or `<underline>`. //! //! The tags directly relative to *colors* (like `<red>`, `<bg:blue>`, `<bg:bright-green>`..., as //! opposed to *style* tags like `<bold>`, `<italics>`...) have some common naming rules: //! -//! * Each color tag has four variants: +//! * Each tag has four variants: //! - `<mycolor>`: the normal, foreground color; //! - `<bright-mycolor>` or `<mycolor!>`: the bright, foreground color; -//! - `<bg:mycolor>`: the normal, background color; +//! - `<bg:mycolor>`, `<MYCOLOR>`: the normal, background color; //! - `<bg:bright-mycolor>`, `<bg:mycolor!>`, `<BRIGHT-MYCOLOR>` or `<MYCOLOR!>`: the bright, //! background color; -//! * Each color tag has a *shortcut*, with a base letter for each color (example with the `x` -//! letter): +//! * Each tag has a *shortcut*, with a base letter for each color; example with the `x` letter: //! - `<x>`: the normal, foreground color; //! - `<x!>`: the bright, foreground color; -//! - `<bg:x>` or `<X>`: the normal, background color; -//! - `<bg:x!>` or `<X!>`: the bright, background color; -//! * Except for the color `<black>`, each color's shortcut letter is simply the first letter of -//! its name, e.g. `<y>` is the shortcut for `<yellow>`; -//! * Each color's tag which is uppercase is a background color; -//! * Each tag which has a trailing exclamation point `!` is a bright color; +//! - `<bg:x>`, `<X>`: the normal, background color; +//! - `<bg:x!>`, `<X!>`: the bright, background color; +//! * Each color's shortcut letter is simply the **first letter of its name** (excepted for `<k>` +//! which is the shortcut for `<black>`), e.g. `<y>` is the shortcut for `<yellow>`; +//! * Each color's tag which is uppercase is a **background color**; +//! * Each tag which has a trailing exclamation point `!` is a **bright color**; //! -//! # List of accepted color/style tags: +//! # List of accepted tags: //! //! The two first columns show which styles are supported, respectively with the default crate //! features (ANSI column), and with the feature `terminfo` being activated. //! //! | ANSI | Terminfo | Shortcuts | Long names | Aliases | //! | ---- | -------- | --------- | ----------------------- | ----------------------------------------------- | -//! | X | X | `<s>` | `<bold>` | `<em>` `<strong>` | +//! | X | X | `<s>` | `<strong>` | `<em>` `<bold>` | //! | X | X | | `<dim>` | | //! | X | X | `<u>` | `<underline>` | | //! | X | | | `<strike>` | | @@ -276,9 +273,7 @@ //! | X | | `<0>`...`<255>` | `<palette(...)>` | `<p(...)>` `<pal(...)>` | //! | X | | `<P(...)>` | `<bg:palette(...)>` | `<PALETTE(...)>` `<PAL(...)>` `<bg:p(...)>` `<bg:pal(...)>` | -pub use color_print_proc_macro::{cformat, cprint, cprintln, untagged}; -#[cfg(not(feature = "terminfo"))] -pub use color_print_proc_macro::cstr; +pub use color_print_proc_macro::{cformat, cprint, cprintln, cstr, untagged}; #[cfg(feature = "terminfo")] mod terminfo; |