Color-ANSI-Util-0.164/0000775000175000017500000000000013667647776011734 5ustar s1s1Color-ANSI-Util-0.164/META.json0000644000175000017500000005136313667647776013363 0ustar s1s1{ "abstract" : "Routines for dealing with ANSI colors", "author" : [ "perlancar " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Color-ANSI-Util", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Rinci" : "0.151" }, "x_spec" : { "Rinci" : "v1.1.90" } }, "runtime" : { "requires" : { "Color::RGB::Util" : "0.600", "Exporter" : "5.57", "perl" : "5.010001", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.98" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Color-ANSI-Util" }, "homepage" : "https://metacpan.org/release/Color-ANSI-Util", "repository" : { "type" : "git", "url" : "git://github.com/perlancar/perl-Color-ANSI-Util.git", "web" : "https://github.com/perlancar/perl-Color-ANSI-Util" } }, "version" : "0.164", "x_Dist_Zilla" : { "perl" : { "version" : "5.030002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Author::PERLANCAR/@Filter/GatherDir", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Author::PERLANCAR/@Filter/PruneCruft", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::PERLANCAR/@Filter/ManifestSkip", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::PERLANCAR/@Filter/MetaYAML", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::PERLANCAR/@Filter/License", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Author::PERLANCAR/@Filter/PodCoverageTests", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::PERLANCAR/@Filter/PodSyntaxTests", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Author::PERLANCAR/@Filter/ExtraTests", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/@Filter/ExecDir", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::PERLANCAR/@Filter/ShareDir", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Author::PERLANCAR/@Filter/MakeMaker", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::PERLANCAR/@Filter/Manifest", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::PERLANCAR/@Filter/ConfirmRelease", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/ExecDir script", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::BeforeBuild", "name" : "@Author::PERLANCAR/PERLANCAR::BeforeBuild", "version" : "0.600" }, { "class" : "Dist::Zilla::Plugin::Rinci::AbstractFromMeta", "name" : "@Author::PERLANCAR/Rinci::AbstractFromMeta", "version" : "0.10" }, { "class" : "Dist::Zilla::Plugin::PodnameFromFilename", "name" : "@Author::PERLANCAR/PodnameFromFilename", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec", "name" : "@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec", "version" : "0.061" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::MetaResources", "name" : "@Author::PERLANCAR/PERLANCAR::MetaResources", "version" : "0.040" }, { "class" : "Dist::Zilla::Plugin::CheckChangeLog", "name" : "@Author::PERLANCAR/CheckChangeLog", "version" : "0.05" }, { "class" : "Dist::Zilla::Plugin::CheckMetaResources", "name" : "@Author::PERLANCAR/CheckMetaResources", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::CheckSelfDependency", "config" : { "Dist::Zilla::Plugin::CheckSelfDependency" : { "finder" : [ ":InstallModules" ] }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000036", "version" : "0.006" } }, "name" : "@Author::PERLANCAR/CheckSelfDependency", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::CopyrightYearFromGit", "name" : "@Author::PERLANCAR/CopyrightYearFromGit", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::IfBuilt", "name" : "@Author::PERLANCAR/IfBuilt", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::PERLANCAR/MetaJSON", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::PERLANCAR/MetaConfig", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::PERLANCAR/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::OurDate", "name" : "@Author::PERLANCAR/OurDate", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::OurDist", "name" : "@Author::PERLANCAR/OurDist", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::OurPkgVersion", "name" : "@Author::PERLANCAR/OurPkgVersion", "version" : "0.21" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Author::PERLANCAR/Name", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Author::PERLANCAR/Version", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/prelude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Author::PERLANCAR/Leftovers", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/postlude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongComplete", "name" : "@Author::PERLANCAR/Completion::GetoptLongComplete", "version" : "0.08" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongSubcommand", "name" : "@Author::PERLANCAR/Completion::GetoptLongSubcommand", "version" : "0.04" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongMore", "name" : "@Author::PERLANCAR/Completion::GetoptLongMore", "version" : "0.001" }, { "class" : "Pod::Weaver::Section::Homepage::DefaultCPAN", "name" : "@Author::PERLANCAR/Homepage::DefaultCPAN", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::Source::DefaultGitHub", "name" : "@Author::PERLANCAR/Source::DefaultGitHub", "version" : "0.07" }, { "class" : "Pod::Weaver::Section::Bugs::DefaultRT", "name" : "@Author::PERLANCAR/Bugs::DefaultRT", "version" : "0.06" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Author::PERLANCAR/Authors", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Author::PERLANCAR/Legal", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::Rinci", "name" : "@Author::PERLANCAR/Rinci", "version" : "0.780" }, { "class" : "Pod::Weaver::Plugin::AppendPrepend", "name" : "@Author::PERLANCAR/AppendPrepend", "version" : "0.01" }, { "class" : "Pod::Weaver::Plugin::EnsureUniqueSections", "name" : "@Author::PERLANCAR/EnsureUniqueSections", "version" : "0.163250" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Author::PERLANCAR/SingleEncoding", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::PERLANCAR::SortSections", "name" : "@Author::PERLANCAR/PERLANCAR::SortSections", "version" : "0.082" } ] } }, "name" : "@Author::PERLANCAR/PodWeaver", "version" : "4.008" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "@Author::PERLANCAR/PruneFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::Pod2Readme", "name" : "@Author::PERLANCAR/Pod2Readme", "version" : "0.004" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddPrereqs", "name" : "@Author::PERLANCAR/Rinci::AddPrereqs", "version" : "0.144" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddToDb", "name" : "@Author::PERLANCAR/Rinci::AddToDb", "version" : "0.020" }, { "class" : "Dist::Zilla::Plugin::Rinci::EmbedValidator", "name" : "@Author::PERLANCAR/Rinci::EmbedValidator", "version" : "0.250" }, { "class" : "Dist::Zilla::Plugin::SetScriptShebang", "name" : "@Author::PERLANCAR/SetScriptShebang", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Author::PERLANCAR/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::Test::Perl::Critic::Subset", "config" : { "Dist::Zilla::Plugin::Test::Perl::Critic::Subset" : { "finder" : [ ":ExecFiles", ":InstallModules", ":TestFiles" ] } }, "name" : "@Author::PERLANCAR/Test::Perl::Critic::Subset", "version" : "3.001.005" }, { "class" : "Dist::Zilla::Plugin::Test::Rinci", "name" : "@Author::PERLANCAR/Test::Rinci", "version" : "0.040" }, { "class" : "Dist::Zilla::Plugin::StaticInstall", "config" : { "Dist::Zilla::Plugin::StaticInstall" : { "dry_run" : 0, "mode" : "on" } }, "name" : "@Author::PERLANCAR/StaticInstall", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest", "name" : "@Author::PERLANCAR/EnsureSQLSchemaVersionedTest", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::Acme::CPANModules::Blacklist", "name" : "@Author::PERLANCAR/Acme::CPANModules::Blacklist", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::Prereqs::EnsureVersion", "name" : "@Author::PERLANCAR/Prereqs::EnsureVersion", "version" : "0.050" }, { "class" : "Dist::Zilla::Plugin::Prereqs::CheckCircular", "name" : "@Author::PERLANCAR/Prereqs::CheckCircular", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple", "name" : "@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::Extras", "name" : "lint-prereqs / assume-provided", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "x_spec" } }, "name" : "DevelopX_spec", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.014" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.014" } }, "x_authority" : "cpan:PERLANCAR", "x_generated_by_perl" : "v5.30.2", "x_serialization_backend" : "Cpanel::JSON::XS version 4.19", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1 } Color-ANSI-Util-0.164/LICENSE0000644000175000017500000004407513667647776012751 0ustar s1s1This software is copyright (c) 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Color-ANSI-Util-0.164/Changes0000644000175000017500000000620013667647776013223 0ustar s1s10.164 2020-06-09 Released-By: PERLANCAR; Urgency: medium - Add option for ansi_reset() to conditionally return reset sequence when color is enabled. 0.163 2019-08-20 Released-By: PERLANCAR; Urgency: medium - Use rgb_diff() with hsv_hue1 algorithm to convert RGB 24bit to 256/16 color better, by retaining more hued colors instead of turning to white/gray 'prematurely'. 0.162 2018-12-02 Released-By: PERLANCAR - Observe NO_COLOR (see https://no-color.org). 0.161 2018-09-26 Released-By: PERLANCAR - Add function/constant: ansi_reset. 0.160 2017-12-03 Released-By: PERLANCAR - No functional changes. - Add Rinci metadata. 0.15 2016-10-04 Released-By: PERLANCAR - Observe COLOR=0 to mean disable color, disable color when COLOR_DEPTH < 16. 0.14 2015-01-03 Released-By: PERLANCAR - No functional changes. - Rebuild (Generate TODO.md). 0.13 2014-08-06 Released-By: SHARYANTO - No functional changes. - Expand Synopsis and description to make it clearer what this module does. 0.12 2014-04-08 Released-By: SHARYANTO - No functional changes. - [Bugfix] Forgot to remove 'use Term::Detect::Software' statement in test file [CT]. 0.11 2014-04-07 Released-By: SHARYANTO - Make dependency to Term::Detect::Software optional so this module is easier to install (on Win32). 0.10 2013-11-12 Released-By: SHARYANTO - No functional changes. Rebuild to fix t/00-compile.t generated by older DZP::Test::Compile (2.019 < x < 2.033). 0.09 2013-09-29 Released-By: SHARYANTO - Switch from using Term::Detect to Term::Detect::Software. [REMOVED FEATURES] - Remove detect_color_depth() because this functionality is already in Term::Detect::Software. 0.08 2013-09-25 Released-By: SHARYANTO - No functional changes. Simplify Synopsis and show only the most important functions. 0.07 2013-05-03 Released-By: SHARYANTO - No functional changes. Remove duplicate code. 0.06 2013-05-03 Released-By: SHARYANTO - Use Term::Detect to detect color depth. 0.05 2013-05-02 Released-By: SHARYANTO - No functional changes. Fix wrong test (RT#84991). 0.04 2013-04-28 Released-By: SHARYANTO - No functional changes. Add some POD text. 0.03 2013-04-28 Released-By: SHARYANTO [ENHANCEMENTS] - Add functions: detect_color_depth, rgb_to_ansi_{fg,bg}_code, ansi{fg,bg}. 0.02 2013-04-26 Released-By: SHARYANTO [INCOMPATIBLE CHANGES] - ansi16_to_rgb() now expects numbers from 0-15 instead of 30-37; it no longer supports accepting things like "31;1". - rgb_to_ansi16() now returns number from 0-15 instead of 30-37 or things like "31;1". [ENHANCEMENTS] - Add functions to generate ANSI escape codes: rgb_to_ansi{16,256}_{fg,bg}_code (with their short aliases). - Add functions to generate 24-bit ANSI escape codes (supported by Konsole and Yakuake). 0.01 2013-04-25 Released-By: SHARYANTO - First release. Color-ANSI-Util-0.164/META.yml0000644000175000017500000003337413667647776013215 0ustar s1s1--- abstract: 'Routines for dealing with ANSI colors' author: - 'perlancar ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0.98' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Color-ANSI-Util requires: Color::RGB::Util: '0.600' Exporter: '5.57' perl: '5.010001' strict: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Color-ANSI-Util homepage: https://metacpan.org/release/Color-ANSI-Util repository: git://github.com/perlancar/perl-Color-ANSI-Util.git version: '0.164' x_Dist_Zilla: perl: version: '5.030002' plugins: - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Author::PERLANCAR/@Filter/GatherDir' version: '6.014' - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::PERLANCAR/@Filter/PruneCruft' version: '6.014' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::PERLANCAR/@Filter/ManifestSkip' version: '6.014' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::PERLANCAR/@Filter/MetaYAML' version: '6.014' - class: Dist::Zilla::Plugin::License name: '@Author::PERLANCAR/@Filter/License' version: '6.014' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Author::PERLANCAR/@Filter/PodCoverageTests' version: '6.014' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::PERLANCAR/@Filter/PodSyntaxTests' version: '6.014' - class: Dist::Zilla::Plugin::ExtraTests name: '@Author::PERLANCAR/@Filter/ExtraTests' version: '6.014' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/@Filter/ExecDir' version: '6.014' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::PERLANCAR/@Filter/ShareDir' version: '6.014' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::PERLANCAR/@Filter/MakeMaker' version: '6.014' - class: Dist::Zilla::Plugin::Manifest name: '@Author::PERLANCAR/@Filter/Manifest' version: '6.014' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::PERLANCAR/@Filter/ConfirmRelease' version: '6.014' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/ExecDir script' version: '6.014' - class: Dist::Zilla::Plugin::PERLANCAR::BeforeBuild name: '@Author::PERLANCAR/PERLANCAR::BeforeBuild' version: '0.600' - class: Dist::Zilla::Plugin::Rinci::AbstractFromMeta name: '@Author::PERLANCAR/Rinci::AbstractFromMeta' version: '0.10' - class: Dist::Zilla::Plugin::PodnameFromFilename name: '@Author::PERLANCAR/PodnameFromFilename' version: '0.02' - class: Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec name: '@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec' version: '0.061' - class: Dist::Zilla::Plugin::PERLANCAR::MetaResources name: '@Author::PERLANCAR/PERLANCAR::MetaResources' version: '0.040' - class: Dist::Zilla::Plugin::CheckChangeLog name: '@Author::PERLANCAR/CheckChangeLog' version: '0.05' - class: Dist::Zilla::Plugin::CheckMetaResources name: '@Author::PERLANCAR/CheckMetaResources' version: '0.001' - class: Dist::Zilla::Plugin::CheckSelfDependency config: Dist::Zilla::Plugin::CheckSelfDependency: finder: - ':InstallModules' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000036' version: '0.006' name: '@Author::PERLANCAR/CheckSelfDependency' version: '0.011' - class: Dist::Zilla::Plugin::CopyrightYearFromGit name: '@Author::PERLANCAR/CopyrightYearFromGit' version: '0.006' - class: Dist::Zilla::Plugin::IfBuilt name: '@Author::PERLANCAR/IfBuilt' version: '0.03' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::PERLANCAR/MetaJSON' version: '6.014' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::PERLANCAR/MetaConfig' version: '6.014' - class: Dist::Zilla::Plugin::Authority name: '@Author::PERLANCAR/Authority' version: '1.009' - class: Dist::Zilla::Plugin::OurDate name: '@Author::PERLANCAR/OurDate' version: '0.03' - class: Dist::Zilla::Plugin::OurDist name: '@Author::PERLANCAR/OurDist' version: '0.02' - class: Dist::Zilla::Plugin::OurPkgVersion name: '@Author::PERLANCAR/OurPkgVersion' version: '0.21' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.015' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.015' - class: Pod::Weaver::Section::Name name: '@Author::PERLANCAR/Name' version: '4.015' - class: Pod::Weaver::Section::Version name: '@Author::PERLANCAR/Version' version: '4.015' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/prelude' version: '4.015' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.015' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.015' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.015' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.015' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.015' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.015' - class: Pod::Weaver::Section::Leftovers name: '@Author::PERLANCAR/Leftovers' version: '4.015' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/postlude' version: '4.015' - class: Pod::Weaver::Section::Completion::GetoptLongComplete name: '@Author::PERLANCAR/Completion::GetoptLongComplete' version: '0.08' - class: Pod::Weaver::Section::Completion::GetoptLongSubcommand name: '@Author::PERLANCAR/Completion::GetoptLongSubcommand' version: '0.04' - class: Pod::Weaver::Section::Completion::GetoptLongMore name: '@Author::PERLANCAR/Completion::GetoptLongMore' version: '0.001' - class: Pod::Weaver::Section::Homepage::DefaultCPAN name: '@Author::PERLANCAR/Homepage::DefaultCPAN' version: '0.05' - class: Pod::Weaver::Section::Source::DefaultGitHub name: '@Author::PERLANCAR/Source::DefaultGitHub' version: '0.07' - class: Pod::Weaver::Section::Bugs::DefaultRT name: '@Author::PERLANCAR/Bugs::DefaultRT' version: '0.06' - class: Pod::Weaver::Section::Authors name: '@Author::PERLANCAR/Authors' version: '4.015' - class: Pod::Weaver::Section::Legal name: '@Author::PERLANCAR/Legal' version: '4.015' - class: Pod::Weaver::Plugin::Rinci name: '@Author::PERLANCAR/Rinci' version: '0.780' - class: Pod::Weaver::Plugin::AppendPrepend name: '@Author::PERLANCAR/AppendPrepend' version: '0.01' - class: Pod::Weaver::Plugin::EnsureUniqueSections name: '@Author::PERLANCAR/EnsureUniqueSections' version: '0.163250' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Author::PERLANCAR/SingleEncoding' version: '4.015' - class: Pod::Weaver::Plugin::PERLANCAR::SortSections name: '@Author::PERLANCAR/PERLANCAR::SortSections' version: '0.082' name: '@Author::PERLANCAR/PodWeaver' version: '4.008' - class: Dist::Zilla::Plugin::PruneFiles name: '@Author::PERLANCAR/PruneFiles' version: '6.014' - class: Dist::Zilla::Plugin::Pod2Readme name: '@Author::PERLANCAR/Pod2Readme' version: '0.004' - class: Dist::Zilla::Plugin::Rinci::AddPrereqs name: '@Author::PERLANCAR/Rinci::AddPrereqs' version: '0.144' - class: Dist::Zilla::Plugin::Rinci::AddToDb name: '@Author::PERLANCAR/Rinci::AddToDb' version: '0.020' - class: Dist::Zilla::Plugin::Rinci::EmbedValidator name: '@Author::PERLANCAR/Rinci::EmbedValidator' version: '0.250' - class: Dist::Zilla::Plugin::SetScriptShebang name: '@Author::PERLANCAR/SetScriptShebang' version: '0.01' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Author::PERLANCAR/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::Test::Perl::Critic::Subset config: Dist::Zilla::Plugin::Test::Perl::Critic::Subset: finder: - ':ExecFiles' - ':InstallModules' - ':TestFiles' name: '@Author::PERLANCAR/Test::Perl::Critic::Subset' version: 3.001.005 - class: Dist::Zilla::Plugin::Test::Rinci name: '@Author::PERLANCAR/Test::Rinci' version: '0.040' - class: Dist::Zilla::Plugin::StaticInstall config: Dist::Zilla::Plugin::StaticInstall: dry_run: 0 mode: on name: '@Author::PERLANCAR/StaticInstall' version: '0.012' - class: Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest name: '@Author::PERLANCAR/EnsureSQLSchemaVersionedTest' version: '0.03' - class: Dist::Zilla::Plugin::Acme::CPANModules::Blacklist name: '@Author::PERLANCAR/Acme::CPANModules::Blacklist' version: '0.001' - class: Dist::Zilla::Plugin::Prereqs::EnsureVersion name: '@Author::PERLANCAR/Prereqs::EnsureVersion' version: '0.050' - class: Dist::Zilla::Plugin::Prereqs::CheckCircular name: '@Author::PERLANCAR/Prereqs::CheckCircular' version: '0.006' - class: Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple name: '@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple' version: '0.04' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: '6.014' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '6.014' - class: Dist::Zilla::Plugin::Extras name: 'lint-prereqs / assume-provided' version: '0.03' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: x_spec name: DevelopX_spec version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.014' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.014' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.014' x_authority: cpan:PERLANCAR x_generated_by_perl: v5.30.2 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_static_install: 1 Color-ANSI-Util-0.164/Makefile.PL0000644000175000017500000000247613667647776013715 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.014. use strict; use warnings; use 5.010001; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Routines for dealing with ANSI colors", "AUTHOR" => "perlancar ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Color-ANSI-Util", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010001", "NAME" => "Color::ANSI::Util", "PREREQ_PM" => { "Color::RGB::Util" => "0.600", "Exporter" => "5.57", "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98" }, "VERSION" => "0.164", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Color::RGB::Util" => "0.600", "Exporter" => "5.57", "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98", "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Color-ANSI-Util-0.164/t/0000775000175000017500000000000013667647776012177 5ustar s1s1Color-ANSI-Util-0.164/t/author-pod-coverage.t0000644000175000017500000000053613667647776016241 0ustar s1s1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Color-ANSI-Util-0.164/t/01-basics.t0000644000175000017500000000655613667647776014060 0ustar s1s1#!perl use 5.010001; use strict; use warnings; use Test::More 0.98; use Color::ANSI::Util qw( ansi16_to_rgb rgb_to_ansi16 rgb_to_ansi16_fg_code ansi16fg rgb_to_ansi16_bg_code ansi16bg ansi256_to_rgb rgb_to_ansi256 rgb_to_ansi256_fg_code ansi256fg rgb_to_ansi256_bg_code ansi256bg rgb_to_ansi24b_fg_code ansi24bfg rgb_to_ansi24b_bg_code ansi24bbg rgb_to_ansi_fg_code ansifg rgb_to_ansi_bg_code ansibg ansi_reset ); subtest "16 colors" => sub { is(ansi16_to_rgb(1), "800000"); is(ansi16_to_rgb(9), "ff0000"); is(ansi16_to_rgb("red"), "800000"); is(ansi16_to_rgb("bold red"), "ff0000"); is(rgb_to_ansi16("7e0000"), 1); is(rgb_to_ansi16("ee1111"), 9); is(rgb_to_ansi16_fg_code("7e0000"), "\e[31m"); is(ansi16fg ("fe0000"), "\e[31;1m"); is(rgb_to_ansi16_bg_code("7e0000"), "\e[41m"); is(ansi16bg ("fe0000"), "\e[41m"); }; subtest "256 colors" => sub { is(ansi256_to_rgb(156), "afff87"); is(rgb_to_ansi256("ff0000"), 9); is(rgb_to_ansi256("afff80"), 156); is(rgb_to_ansi256("afdf80"), 107); is(rgb_to_ansi256_fg_code("7e0000"), "\e[38;5;1m"); is(ansi256fg ("fe0000"), "\e[38;5;9m"); is(rgb_to_ansi256_bg_code("7e0000"), "\e[48;5;1m"); is(ansi256bg ("fe0000"), "\e[48;5;9m"); }; subtest "24bit colors" => sub { is(rgb_to_ansi24b_fg_code("7e0102"), "\e[38;2;126;1;2m"); is(ansi24bfg ("fe0102"), "\e[38;2;254;1;2m"); is(rgb_to_ansi24b_bg_code("7e0102"), "\e[48;2;126;1;2m"); is(ansi24bbg ("fe0102"), "\e[48;2;254;1;2m"); }; subtest "color detection (ENV)" => sub { local $Color::ANSI::Util::_use_termdetsw = 0; local $Color::ANSI::Util::_color_depth; local $ENV{COLOR_DEPTH}; $Color::ANSI::Util::_color_depth = undef; { local $ENV{COLOR} = 0; is(ansifg("7e0102"), ""); } $Color::ANSI::Util::_color_depth = undef; $ENV{COLOR_DEPTH} = 0; is(ansifg("7e0102"), ""); is(ansi_reset(1), ""); is(ansi_reset(), "\e[0m"); $Color::ANSI::Util::_color_depth = undef; $ENV{COLOR_DEPTH} = 16; is(ansifg("7e0102"), "\e[31m"); $Color::ANSI::Util::_color_depth = undef; $ENV{COLOR_DEPTH} = 256; is(ansifg("7e0102"), "\e[38;5;1m"); $Color::ANSI::Util::_color_depth = undef; $ENV{COLOR_DEPTH} = 2**24; is(ansifg("7e0102"), "\e[38;2;126;1;2m"); }; subtest "color detection (simple heuristic)" => sub { local $Color::ANSI::Util::_use_termdetsw = 0; local $Color::ANSI::Util::_color_depth; local $ENV{COLOR_DEPTH}; local $ENV{KONSOLE_DBUS_SERVICE}; $Color::ANSI::Util::_color_depth = undef; is(ansifg("7e0102"), "\e[31m"); $Color::ANSI::Util::_color_depth = undef; $ENV{KONSOLE_DBUS_SERVICE} = 1; is(ansifg("7e0102"), "\e[38;2;126;1;2m"); }; DONE_TESTING: done_testing(); Color-ANSI-Util-0.164/t/author-critic.t0000644000175000017500000000072413667647776015142 0ustar s1s1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.005 use Test::Perl::Critic (-profile => "") x!! -e ""; my $filenames = ['lib/Color/ANSI/Util.pm']; unless ($filenames && @$filenames) { $filenames = -d "blib" ? ["blib"] : ["lib"]; } all_critic_ok(@$filenames); Color-ANSI-Util-0.164/t/release-rinci.t0000644000175000017500000000057313667647776015111 0ustar s1s1#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::Test::Rinci. use Test::More; eval "use Test::Rinci 0.01"; plan skip_all => "Test::Rinci 0.01 required for testing Rinci metadata" if $@; metadata_in_all_modules_ok(); Color-ANSI-Util-0.164/t/author-pod-syntax.t0000644000175000017500000000045413667647776015773 0ustar s1s1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Color-ANSI-Util-0.164/t/00-compile.t0000644000175000017500000000264013667647776014231 0ustar s1s1use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Color/ANSI/Util.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; Color-ANSI-Util-0.164/README0000644000175000017500000002014513667647776012614 0ustar s1s1NAME Color::ANSI::Util - Routines for dealing with ANSI colors VERSION This document describes version 0.164 of Color::ANSI::Util (from Perl distribution Color-ANSI-Util), released on 2020-06-09. SYNOPSIS use Color::ANSI::Util qw( ansifg ansibg ); say ansifg("f0c010"); # => "\e[33;1m" (on 16-color terminal) # => "\e[38;5;11m" (on 256-color terminal) # => "\e[38;2;240;192;16m" (on 24-bit-color terminal) say ansibg("ff5f87"); # => "\e[47m" (on 16-color terminal) # => "\e[48;5;7m" (on 256-color terminal) # => "\e[48;2;255;95;135m" (on 24-bit-color terminal) There are a bunch of other exportable functions too, mostly for converting between RGB and ANSI color (16/256/24bit color depth). DESCRIPTION This module provides routines for dealing with ANSI colors. The two main functions are "ansifg" and "ansibg". With those functions, you can specify colors in RGB and let it output the correct ANSI color escape code according to the color depth support of the terminal (whether 16-color, 256-color, or 24bit). There are other functions to convert RGB to ANSI in specific color depths, or reverse functions to convert from ANSI to RGB codes. Keywords: xterm, xterm-256color, terminal BUGS/NOTES Algorithm for finding closest indexed color from RGB color currently not very efficient. Probably can add some threshold square distance, below which we can shortcut to the final answer. FUNCTIONS ansi16_to_rgb Usage: ansi16_to_rgb($color) -> color::rgb24 Convert ANSI-16 color to RGB. Returns 6-hexdigit, e.g. 'ff00cc'. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::ansi16* Return value: (color::rgb24) ansi256_to_rgb Usage: ansi256_to_rgb($color) -> color::rgb24 Convert ANSI-256 color to RGB. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::ansi256* Return value: (color::rgb24) rgb_to_ansi16 Usage: rgb_to_ansi16($color) -> color::ansi16 Convert RGB to ANSI-16 color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (color::ansi16) rgb_to_ansi16_bg_code Usage: rgb_to_ansi16_bg_code($color) -> str Convert RGB to ANSI-16 color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi16_fg_code Usage: rgb_to_ansi16_fg_code($color) -> str Convert RGB to ANSI-16 color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi24b_bg_code Usage: rgb_to_ansi24b_bg_code($color) -> str Convert RGB to ANSI 24bit-color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi24b_fg_code Usage: rgb_to_ansi24b_fg_code($color) -> str Convert RGB to ANSI 24bit-color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi256 Usage: rgb_to_ansi256($color) -> color::ansi256 Convert RGB to ANSI-256 color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (color::ansi256) rgb_to_ansi256_bg_code Usage: rgb_to_ansi256_bg_code($color) -> str Convert RGB to ANSI-256 color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi256_fg_code Usage: rgb_to_ansi256_fg_code($color) -> str Convert RGB to ANSI-256 color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi_bg_code Usage: rgb_to_ansi_bg_code($color) -> str Convert RGB to ANSI color escape sequence to change background color. Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Which color depth used is determined by "COLOR_DEPTH" environment setting or from Term::Detect::Software if that module is available). In other words, this function automatically chooses rgb_to_ansi{24b,256,16}*bg*code(). This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) rgb_to_ansi_fg_code Usage: rgb_to_ansi_fg_code($color) -> str Convert RGB to ANSI color escape sequence to change foreground color. Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Color depth used is determined by "COLOR_DEPTH" environment setting or from Term::Detect::Software if that module is available. In other words, this function automatically chooses rgb_to_ansi{24b,256,16}*fg*code(). This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * $color* => *color::rgb24* Return value: (str) ansi16fg($rgb) => STR Alias for rgb_to_ansi16_fg_code(). ansi16bg($rgb) => STR Alias for rgb_to_ansi16_bg_code(). ansi256fg($rgb) => STR Alias for rgb_to_ansi256_fg_code(). ansi256bg($rgb) => STR Alias for rgb_to_ansi256_bg_code(). ansi24bfg($rgb) => STR Alias for rgb_to_ansi24b_fg_code(). ansi24bbg($rgb) => STR Alias for rgb_to_ansi24b_bg_code(). rgb_to_ansi_fg_code($rgb) => STR ansifg($rgb) => STR Alias for rgb_to_ansi_fg_code(). ansibg($rgb) => STR Alias for rgb_to_ansi_bg_code(). ansi_reset( [ $conditional ]) Returns "\e[0m", which is the ANSI escape sequence to reset color. Normally you print this sequence after you print colored text. If $conditional is set to true, then ansi_reset() will return "" if color is disabled. ENVIRONMENT NO_COLOR Can be used to explicitly disable color. See for more details. Observed by: ansi{fg,bg}. COLOR => bool Can be used to explicitly disable color by setting it to 0. Observed by: ansi{fg,bg}. COLOR_DEPTH => INT Can be used to explicitly set color depth instead of trying to detect appropriate color depth. Observed by: ansi{fg,bg}. HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. SEE ALSO Term::ANSIColor AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Color-ANSI-Util-0.164/dist.ini0000644000175000017500000000054013667647776013375 0ustar s1s1version=0.164 name=Color-ANSI-Util [@Author::PERLANCAR] :version=0.59 [Prereqs / TestRequires] Test::More=0.98 [Prereqs] perl=5.010001 strict=0 warnings=0 Color::RGB::Util=0.600 Exporter=5.57 [Extras / lint-prereqs / assume-provided] ; optional Term::Detect::Software=0 [Prereqs / DevelopX_spec] -phase=develop -relationship=x_spec Rinci=1.1.90 Color-ANSI-Util-0.164/lib/0000775000175000017500000000000013667647776012502 5ustar s1s1Color-ANSI-Util-0.164/lib/Color/0000775000175000017500000000000013667647776013560 5ustar s1s1Color-ANSI-Util-0.164/lib/Color/ANSI/0000775000175000017500000000000013667647776014312 5ustar s1s1Color-ANSI-Util-0.164/lib/Color/ANSI/Util.pm0000644000175000017500000005745513667647776015603 0ustar s1s1package Color::ANSI::Util; our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY our $DATE = '2020-06-09'; # DATE our $DIST = 'Color-ANSI-Util'; # DIST our $VERSION = '0.164'; # VERSION use 5.010001; use strict; use warnings; use Color::RGB::Util qw(rgb_diff); require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw( ansi16_to_rgb rgb_to_ansi16 rgb_to_ansi16_fg_code ansi16fg rgb_to_ansi16_bg_code ansi16bg ansi256_to_rgb rgb_to_ansi256 rgb_to_ansi256_fg_code ansi256fg rgb_to_ansi256_bg_code ansi256bg rgb_to_ansi24b_fg_code ansi24bfg rgb_to_ansi24b_bg_code ansi24bbg rgb_to_ansi_fg_code ansifg rgb_to_ansi_bg_code ansibg ansi_reset ); our %SPEC; my %ansi16 = ( 0 => '000000', 1 => '800000', 2 => '008000', 3 => '808000', 4 => '000080', 5 => '800080', 6 => '008080', 7 => 'c0c0c0', 8 => '808080', 9 => 'ff0000', 10 => '00ff00', 11 => 'ffff00', 12 => '0000ff', 13 => 'ff00ff', 14 => '00ffff', 15 => 'ffffff', ); my @revansi16; for my $idx (sort {$a<=>$b} keys %ansi16) { push @revansi16, [$ansi16{$idx}, $idx]; } my %ansi256 = ( %ansi16, 16 => '000000', 17 => '00005f', 18 => '000087', 19 => '0000af', 20 => '0000d7', 21 => '0000ff', 22 => '005f00', 23 => '005f5f', 24 => '005f87', 25 => '005faf', 26 => '005fd7', 27 => '005fff', 28 => '008700', 29 => '00875f', 30 => '008787', 31 => '0087af', 32 => '0087d7', 33 => '0087ff', 34 => '00af00', 35 => '00af5f', 36 => '00af87', 37 => '00afaf', 38 => '00afd7', 39 => '00afff', 40 => '00d700', 41 => '00d75f', 42 => '00d787', 43 => '00d7af', 44 => '00d7d7', 45 => '00d7ff', 46 => '00ff00', 47 => '00ff5f', 48 => '00ff87', 49 => '00ffaf', 50 => '00ffd7', 51 => '00ffff', 52 => '5f0000', 53 => '5f005f', 54 => '5f0087', 55 => '5f00af', 56 => '5f00d7', 57 => '5f00ff', 58 => '5f5f00', 59 => '5f5f5f', 60 => '5f5f87', 61 => '5f5faf', 62 => '5f5fd7', 63 => '5f5fff', 64 => '5f8700', 65 => '5f875f', 66 => '5f8787', 67 => '5f87af', 68 => '5f87d7', 69 => '5f87ff', 70 => '5faf00', 71 => '5faf5f', 72 => '5faf87', 73 => '5fafaf', 74 => '5fafd7', 75 => '5fafff', 76 => '5fd700', 77 => '5fd75f', 78 => '5fd787', 79 => '5fd7af', 80 => '5fd7d7', 81 => '5fd7ff', 82 => '5fff00', 83 => '5fff5f', 84 => '5fff87', 85 => '5fffaf', 86 => '5fffd7', 87 => '5fffff', 88 => '870000', 89 => '87005f', 90 => '870087', 91 => '8700af', 92 => '8700d7', 93 => '8700ff', 94 => '875f00', 95 => '875f5f', 96 => '875f87', 97 => '875faf', 98 => '875fd7', 99 => '875fff', 100 => '878700', 101 => '87875f', 102 => '878787', 103 => '8787af', 104 => '8787d7', 105 => '8787ff', 106 => '87af00', 107 => '87af5f', 108 => '87af87', 109 => '87afaf', 110 => '87afd7', 111 => '87afff', 112 => '87d700', 113 => '87d75f', 114 => '87d787', 115 => '87d7af', 116 => '87d7d7', 117 => '87d7ff', 118 => '87ff00', 119 => '87ff5f', 120 => '87ff87', 121 => '87ffaf', 122 => '87ffd7', 123 => '87ffff', 124 => 'af0000', 125 => 'af005f', 126 => 'af0087', 127 => 'af00af', 128 => 'af00d7', 129 => 'af00ff', 130 => 'af5f00', 131 => 'af5f5f', 132 => 'af5f87', 133 => 'af5faf', 134 => 'af5fd7', 135 => 'af5fff', 136 => 'af8700', 137 => 'af875f', 138 => 'af8787', 139 => 'af87af', 140 => 'af87d7', 141 => 'af87ff', 142 => 'afaf00', 143 => 'afaf5f', 144 => 'afaf87', 145 => 'afafaf', 146 => 'afafd7', 147 => 'afafff', 148 => 'afd700', 149 => 'afd75f', 150 => 'afd787', 151 => 'afd7af', 152 => 'afd7d7', 153 => 'afd7ff', 154 => 'afff00', 155 => 'afff5f', 156 => 'afff87', 157 => 'afffaf', 158 => 'afffd7', 159 => 'afffff', 160 => 'd70000', 161 => 'd7005f', 162 => 'd70087', 163 => 'd700af', 164 => 'd700d7', 165 => 'd700ff', 166 => 'd75f00', 167 => 'd75f5f', 168 => 'd75f87', 169 => 'd75faf', 170 => 'd75fd7', 171 => 'd75fff', 172 => 'd78700', 173 => 'd7875f', 174 => 'd78787', 175 => 'd787af', 176 => 'd787d7', 177 => 'd787ff', 178 => 'd7af00', 179 => 'd7af5f', 180 => 'd7af87', 181 => 'd7afaf', 182 => 'd7afd7', 183 => 'd7afff', 184 => 'd7d700', 185 => 'd7d75f', 186 => 'd7d787', 187 => 'd7d7af', 188 => 'd7d7d7', 189 => 'd7d7ff', 190 => 'd7ff00', 191 => 'd7ff5f', 192 => 'd7ff87', 193 => 'd7ffaf', 194 => 'd7ffd7', 195 => 'd7ffff', 196 => 'ff0000', 197 => 'ff005f', 198 => 'ff0087', 199 => 'ff00af', 200 => 'ff00d7', 201 => 'ff00ff', 202 => 'ff5f00', 203 => 'ff5f5f', 204 => 'ff5f87', 205 => 'ff5faf', 206 => 'ff5fd7', 207 => 'ff5fff', 208 => 'ff8700', 209 => 'ff875f', 210 => 'ff8787', 211 => 'ff87af', 212 => 'ff87d7', 213 => 'ff87ff', 214 => 'ffaf00', 215 => 'ffaf5f', 216 => 'ffaf87', 217 => 'ffafaf', 218 => 'ffafd7', 219 => 'ffafff', 220 => 'ffd700', 221 => 'ffd75f', 222 => 'ffd787', 223 => 'ffd7af', 224 => 'ffd7d7', 225 => 'ffd7ff', 226 => 'ffff00', 227 => 'ffff5f', 228 => 'ffff87', 229 => 'ffffaf', 230 => 'ffffd7', 231 => 'ffffff', 232 => '080808', 233 => '121212', 234 => '1c1c1c', 235 => '262626', 236 => '303030', 237 => '3a3a3a', 238 => '444444', 239 => '4e4e4e', 240 => '585858', 241 => '606060', 242 => '666666', 243 => '767676', 244 => '808080', 245 => '8a8a8a', 246 => '949494', 247 => '9e9e9e', 248 => 'a8a8a8', 249 => 'b2b2b2', 250 => 'bcbcbc', 251 => 'c6c6c6', 252 => 'd0d0d0', 253 => 'dadada', 254 => 'e4e4e4', 255 => 'eeeeee', ); my @revansi256; for my $idx (sort {$a<=>$b} keys %ansi256) { push @revansi256, [$ansi256{$idx}, $idx]; } $SPEC{ansi16_to_rgb} = { v => 1.1, summary => 'Convert ANSI-16 color to RGB', description => <<'_', Returns 6-hexdigit, e.g. 'ff00cc'. _ args => { color => { schema => 'color::ansi16*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'color::rgb24*', }, result_naked => 1, }; sub ansi16_to_rgb { my ($input) = @_; if ($input =~ /^\d+$/) { if ($input >= 0 && $input <= 15) { return $ansi16{$input + 0}; # to remove prefix zero e.g. "06" } else { die "Invalid ANSI 16-color number '$input'"; } } elsif ($input =~ /^(?:(bold|bright) \s )?(black|red|green|yellow|blue|magenta|cyan|white)$/ix) { my ($bold, $col) = (lc($1 // ""), lc($2)); my $i; if ($col eq 'black') { $i = 0; } elsif ($col eq 'red') { $i = 1; } elsif ($col eq 'green') { $i = 2; } elsif ($col eq 'yellow') { $i = 3; } elsif ($col eq 'blue') { $i = 4; } elsif ($col eq 'magenta') { $i = 5; } elsif ($col eq 'cyan') { $i = 6; } elsif ($col eq 'white') { $i = 7; } $i += 8 if $bold; return $ansi16{$i}; } else { die "Invalid ANSI 16-color name '$input'"; } } sub _rgb_to_indexed { my ($rgb, $table) = @_; my ($smallest_diff, $res); for my $e (@$table) { my $diff = rgb_diff($rgb, $e->[0], 'hsv_hue1'); # exact match, return immediately return $e->[1] if $diff == 0; if (!defined($smallest_diff) || $smallest_diff > $diff) { $smallest_diff = $diff; $res = $e->[1]; } } return $res; } $SPEC{ansi256_to_rgb} = { v => 1.1, summary => 'Convert ANSI-256 color to RGB', args => { color => { schema => 'color::ansi256*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'color::rgb24', }, result_naked => 1, }; sub ansi256_to_rgb { my ($input) = @_; $input += 0; exists($ansi256{$input}) or die "Invalid ANSI 256-color index '$input'"; $ansi256{$input}; } $SPEC{rgb_to_ansi16} = { v => 1.1, summary => 'Convert RGB to ANSI-16 color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'color::ansi16*', }, result_naked => 1, }; sub rgb_to_ansi16 { my ($input) = @_; _rgb_to_indexed($input, \@revansi16); } $SPEC{rgb_to_ansi256} = { v => 1.1, summary => 'Convert RGB to ANSI-256 color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'color::ansi256*', }, result_naked => 1, }; sub rgb_to_ansi256 { my ($input) = @_; _rgb_to_indexed($input, \@revansi256); } $SPEC{rgb_to_ansi16_fg_code} = { v => 1.1, summary => 'Convert RGB to ANSI-16 color escape sequence to change foreground color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi16_fg_code { my ($input) = @_; my $res = _rgb_to_indexed($input, \@revansi16); return "\e[" . ($res >= 8 ? ($res+30-8) . ";1" : ($res+30)) . "m"; } sub ansi16fg { goto &rgb_to_ansi16_fg_code } $SPEC{rgb_to_ansi16_bg_code} = { v => 1.1, summary => 'Convert RGB to ANSI-16 color escape sequence to change background color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi16_bg_code { my ($input) = @_; my $res = _rgb_to_indexed($input, \@revansi16); return "\e[" . ($res >= 8 ? ($res+40-8) : ($res+40)) . "m"; } sub ansi16bg { goto &rgb_to_ansi16_bg_code } $SPEC{rgb_to_ansi256_fg_code} = { v => 1.1, summary => 'Convert RGB to ANSI-256 color escape sequence to change foreground color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi256_fg_code { my ($input) = @_; my $res = _rgb_to_indexed($input, \@revansi16); return "\e[38;5;${res}m"; } sub ansi256fg { goto &rgb_to_ansi256_fg_code } $SPEC{rgb_to_ansi256_bg_code} = { v => 1.1, summary => 'Convert RGB to ANSI-256 color escape sequence to change background color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi256_bg_code { my ($input) = @_; my $res = _rgb_to_indexed($input, \@revansi16); return "\e[48;5;${res}m"; } sub ansi256bg { goto &rgb_to_ansi256_bg_code } $SPEC{rgb_to_ansi24b_fg_code} = { v => 1.1, summary => 'Convert RGB to ANSI 24bit-color escape sequence to change foreground color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi24b_fg_code { my ($rgb) = @_; return sprintf("\e[38;2;%d;%d;%dm", hex(substr($rgb, 0, 2)), hex(substr($rgb, 2, 2)), hex(substr($rgb, 4, 2))); } sub ansi24bfg { goto &rgb_to_ansi24b_fg_code } $SPEC{rgb_to_ansi24b_bg_code} = { v => 1.1, summary => 'Convert RGB to ANSI 24bit-color escape sequence to change background color', args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi24b_bg_code { my ($rgb) = @_; return sprintf("\e[48;2;%d;%d;%dm", hex(substr($rgb, 0, 2)), hex(substr($rgb, 2, 2)), hex(substr($rgb, 4, 2))); } sub ansi24bbg { goto &rgb_to_ansi24b_bg_code } our $_use_termdetsw = 1; our $_color_depth; # cache, can be set during testing sub _color_depth { unless (defined $_color_depth) { { if (exists $ENV{NO_COLOR}) { $_color_depth = 0; last; } if (defined $ENV{COLOR} && !$ENV{COLOR}) { $_color_depth = 0; last; } if (defined $ENV{COLOR_DEPTH}) { $_color_depth = $ENV{COLOR_DEPTH}; last; } if ($_use_termdetsw) { eval { require Term::Detect::Software }; if (!$@) { $_color_depth = Term::Detect::Software::detect_terminal_cached()->{color_depth}; last; } } # simple heuristic if ($ENV{KONSOLE_DBUS_SERVICE}) { $_color_depth = 2**24; last; } # safe value $_color_depth = 16; } }; $_color_depth; } $SPEC{rgb_to_ansi_fg_code} = { v => 1.1, summary => 'Convert RGB to ANSI color escape sequence to change foreground color', description => <<'_', Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Color depth used is determined by `COLOR_DEPTH` environment setting or from if that module is available. In other words, this function automatically chooses rgb_to_ansi{24b,256,16}_fg_code(). _ args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi_fg_code { my ($rgb) = @_; my $cd = _color_depth(); if ($cd >= 2**24) { rgb_to_ansi24b_fg_code($rgb); } elsif ($cd >= 256) { rgb_to_ansi256_fg_code($rgb); } elsif ($cd >= 16) { rgb_to_ansi16_fg_code($rgb); } else { ""; } } sub ansifg { goto &rgb_to_ansi_fg_code } $SPEC{rgb_to_ansi_bg_code} = { v => 1.1, summary => 'Convert RGB to ANSI color escape sequence to change background color', description => <<'_', Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Which color depth used is determined by `COLOR_DEPTH` environment setting or from if that module is available). In other words, this function automatically chooses rgb_to_ansi{24b,256,16}_bg_code(). _ args => { color => { schema => 'color::rgb24*', req => 1, pos => 0, }, }, args_as => 'array', result => { schema => 'str*', }, result_naked => 1, }; sub rgb_to_ansi_bg_code { my ($rgb) = @_; my $cd = _color_depth(); if ($cd >= 2**24) { rgb_to_ansi24b_bg_code($rgb); } elsif ($cd >= 256) { rgb_to_ansi256_bg_code($rgb); } else { rgb_to_ansi16_bg_code($rgb); } } sub ansibg { goto &rgb_to_ansi_bg_code } sub ansi_reset { my $conditional = shift; if ($conditional) { my $cd = _color_depth(); return "" if $cd < 16; } "\e[0m"; } 1; # ABSTRACT: Routines for dealing with ANSI colors __END__ =pod =encoding UTF-8 =head1 NAME Color::ANSI::Util - Routines for dealing with ANSI colors =head1 VERSION This document describes version 0.164 of Color::ANSI::Util (from Perl distribution Color-ANSI-Util), released on 2020-06-09. =head1 SYNOPSIS use Color::ANSI::Util qw( ansifg ansibg ); say ansifg("f0c010"); # => "\e[33;1m" (on 16-color terminal) # => "\e[38;5;11m" (on 256-color terminal) # => "\e[38;2;240;192;16m" (on 24-bit-color terminal) say ansibg("ff5f87"); # => "\e[47m" (on 16-color terminal) # => "\e[48;5;7m" (on 256-color terminal) # => "\e[48;2;255;95;135m" (on 24-bit-color terminal) There are a bunch of other exportable functions too, mostly for converting between RGB and ANSI color (16/256/24bit color depth). =head1 DESCRIPTION This module provides routines for dealing with ANSI colors. The two main functions are C and C. With those functions, you can specify colors in RGB and let it output the correct ANSI color escape code according to the color depth support of the terminal (whether 16-color, 256-color, or 24bit). There are other functions to convert RGB to ANSI in specific color depths, or reverse functions to convert from ANSI to RGB codes. Keywords: xterm, xterm-256color, terminal =head1 BUGS/NOTES Algorithm for finding closest indexed color from RGB color currently not very efficient. Probably can add some threshold square distance, below which we can shortcut to the final answer. =head1 FUNCTIONS =head2 ansi16_to_rgb Usage: ansi16_to_rgb($color) -> color::rgb24 Convert ANSI-16 color to RGB. Returns 6-hexdigit, e.g. 'ff00cc'. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (color::rgb24) =head2 ansi256_to_rgb Usage: ansi256_to_rgb($color) -> color::rgb24 Convert ANSI-256 color to RGB. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (color::rgb24) =head2 rgb_to_ansi16 Usage: rgb_to_ansi16($color) -> color::ansi16 Convert RGB to ANSI-16 color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (color::ansi16) =head2 rgb_to_ansi16_bg_code Usage: rgb_to_ansi16_bg_code($color) -> str Convert RGB to ANSI-16 color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi16_fg_code Usage: rgb_to_ansi16_fg_code($color) -> str Convert RGB to ANSI-16 color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi24b_bg_code Usage: rgb_to_ansi24b_bg_code($color) -> str Convert RGB to ANSI 24bit-color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi24b_fg_code Usage: rgb_to_ansi24b_fg_code($color) -> str Convert RGB to ANSI 24bit-color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi256 Usage: rgb_to_ansi256($color) -> color::ansi256 Convert RGB to ANSI-256 color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (color::ansi256) =head2 rgb_to_ansi256_bg_code Usage: rgb_to_ansi256_bg_code($color) -> str Convert RGB to ANSI-256 color escape sequence to change background color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi256_fg_code Usage: rgb_to_ansi256_fg_code($color) -> str Convert RGB to ANSI-256 color escape sequence to change foreground color. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi_bg_code Usage: rgb_to_ansi_bg_code($color) -> str Convert RGB to ANSI color escape sequence to change background color. Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Which color depth used is determined by C environment setting or from L if that module is available). In other words, this function automatically chooses rgb_to_ansi{24b,256,16}Icode(). This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 rgb_to_ansi_fg_code Usage: rgb_to_ansi_fg_code($color) -> str Convert RGB to ANSI color escape sequence to change foreground color. Autodetect terminal capability and can return either empty string, 16-color, 256-color, or 24bit-code. Color depth used is determined by C environment setting or from L if that module is available. In other words, this function automatically chooses rgb_to_ansi{24b,256,16}Icode(). This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B<$color>* => I =back Return value: (str) =head2 ansi16fg($rgb) => STR Alias for rgb_to_ansi16_fg_code(). =head2 ansi16bg($rgb) => STR Alias for rgb_to_ansi16_bg_code(). =head2 ansi256fg($rgb) => STR Alias for rgb_to_ansi256_fg_code(). =head2 ansi256bg($rgb) => STR Alias for rgb_to_ansi256_bg_code(). =head2 ansi24bfg($rgb) => STR Alias for rgb_to_ansi24b_fg_code(). =head2 ansi24bbg($rgb) => STR Alias for rgb_to_ansi24b_bg_code(). =head2 rgb_to_ansi_fg_code($rgb) => STR =head2 ansifg($rgb) => STR Alias for rgb_to_ansi_fg_code(). =head2 ansibg($rgb) => STR Alias for rgb_to_ansi_bg_code(). =head2 ansi_reset( [ $conditional ]) Returns "\e[0m", which is the ANSI escape sequence to reset color. Normally you print this sequence after you print colored text. If C<$conditional> is set to true, then ansi_reset() will return "" if color is disabled. =head1 ENVIRONMENT =head2 NO_COLOR Can be used to explicitly disable color. See L for more details. Observed by: ansi{fg,bg}. =head2 COLOR => bool Can be used to explicitly disable color by setting it to 0. Observed by: ansi{fg,bg}. =head2 COLOR_DEPTH => INT Can be used to explicitly set color depth instead of trying to detect appropriate color depth. Observed by: ansi{fg,bg}. =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 SEE ALSO L L =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Color-ANSI-Util-0.164/MANIFEST0000644000175000017500000000045213667647776013064 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.014. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Color/ANSI/Util.pm t/00-compile.t t/01-basics.t t/author-critic.t t/author-pod-coverage.t t/author-pod-syntax.t t/release-rinci.t weaver.ini Color-ANSI-Util-0.164/weaver.ini0000644000175000017500000000002513667647776013721 0ustar s1s1[@Author::PERLANCAR]