lolcat-100.0.1/0000755000004100000410000000000013631454240013161 5ustar www-datawww-datalolcat-100.0.1/README.md0000644000004100000410000000043313631454240014440 0ustar www-datawww-data# What? ![](https://github.com/busyloop/lolcat/raw/master/ass/nom.jpg) ## Screenshot ![](https://github.com/busyloop/lolcat/raw/master/ass/screenshot.png) ## Installation ```bash $ gem install lolcat ``` Or using [homebrew](https://brew.sh): ```bash $ brew install lolcat ``` lolcat-100.0.1/bin/0000755000004100000410000000000013631454240013731 5ustar www-datawww-datalolcat-100.0.1/bin/lolcat0000755000004100000410000000314613631454240015141 0ustar www-datawww-data#!/usr/bin/env ruby # Copyright (c) 2016, moe@busyloop.net # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the lolcat nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require "rubygems" require "lolcat/version" require "lolcat/cat" Lol.cat! lolcat-100.0.1/.gitignore0000644000004100000410000000004113631454240015144 0ustar www-datawww-data*.gem .bundle Gemfile.lock pkg/* lolcat-100.0.1/man/0000755000004100000410000000000013631454240013734 5ustar www-datawww-datalolcat-100.0.1/man/lolcat.60000644000004100000410000000440013631454240015277 0ustar www-datawww-data.TH LOLCAT 6 "April 4, 2019" .\" Please adjust this date whenever revising the manpage. .SH NAME lolcat \- rainbow coloring effect for text console display .SH SYNOPSIS .B lolcat .RI [ options ] " " [ files ] " " ... .SH DESCRIPTION This manual page documents briefly the .B lolcat command. .PP \fBlolcat\fP is a program that concatenates files, or standard input, to standard output (like the generic \fBcat\fP), and adds rainbow coloring to it. .SH OPTIONS .TP \fB\-p\fP \fIX\fP, \fB\-\-spread=\fIX\fP Inclination of the rainbow stripes .br (character widths per line hight; high values (>1000) give almost horizonal stripes, low values (0.1) almost vertical ones; default: 3.0). .TP \fB\-F\fP \fIX\fP, \fB\-\-freq=\fIX\fP Frequency of the rainbow effect. .br (low values around 0.0001 give almost monochromous screens; default: 0.1). .TP \fB\-S\fP \fIX\fP, \fB\-\-seed=\fIX\fP Initial value for the random number generator; 0 means automatic. .br (default: 0). .TP \fB\-a\fP, \fB\-\-animate\fP Fade every line through an animation before printing the next one. .TP \fB\-d\fP \fIX\fP, \fB\-\-duration=\fIX\fP Duration of the animation. .br (number of steps before showing next line; default: 12) .TP \fB\-s\fP \fIX\fP, \fB\-\-speed=\fIX\fP Speed of the animation. .br (frame rate, ie. number of steps per second; default: 20) .TP \fB\-i\fP, \fB\-\-invert\fP Inverts the background and foreground colors. .TP \fB\-t\fP, \fB\-\-truecolor\fP Enables 24-bit truecolor mode. .TP \fB\-f\fP, \fB\-\-force\fP Force color even when stdout is not a tty. .TP .B \-v, \-\-version Shows lolcat version. .TP .B \-h, \-\-help Shows options summary. .SH EXAMPLES Typical combinations of \fBlolcat\fP include other programs that generate text: .br .br Large colorful words can be written like this: .IP .EX echo "KTHXBAI" | toilet | lolcat .EE . .P Cows are popular, come in all colors, and tell random epigrams: .IP .EX fortune | cowsay | lolcat \-a .EE . .P .SH SEE ALSO .BR cat (1), .BR toilet (1), .BR fortune (6), .BR cowsay (6) .br .SH AUTHOR lolcat was written by Moe . .PP This manual page was originally written by chrysn , for the Debian project. .br Very quickly revamped by Mathieu Aubin to include as part of official code repository. lolcat-100.0.1/LICENSE0000644000004100000410000000273013631454240014170 0ustar www-datawww-dataCopyright (c) 2016, moe@busyloop.net All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the lolcat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lolcat-100.0.1/Rakefile0000644000004100000410000000003413631454240014623 0ustar www-datawww-datarequire 'bundler/gem_tasks' lolcat-100.0.1/lib/0000755000004100000410000000000013631454240013727 5ustar www-datawww-datalolcat-100.0.1/lib/lolcat.rb0000644000004100000410000000311113631454240015526 0ustar www-datawww-data# Copyright (c) 2016, moe@busyloop.net # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the lolcat nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require "lolcat/version" require "lolcat/lol" require "lolcat/cat" lolcat-100.0.1/lib/lolcat/0000755000004100000410000000000013631454240015205 5ustar www-datawww-datalolcat-100.0.1/lib/lolcat/version.rb0000644000004100000410000000005013631454240017212 0ustar www-datawww-datamodule Lolcat VERSION = "100.0.1" end lolcat-100.0.1/lib/lolcat/lol.rb0000644000004100000410000001021113631454240016313 0ustar www-datawww-data# Copyright (c) 2016, moe@busyloop.net # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the lolcat nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require "lolcat/version" require 'paint' module Lol ANSI_ESCAPE = /((?:\e(?:[ -\/]+.|[\]PX^_][^\a\e]*|\[[0-?]*.|.))*)(.?)/m INCOMPLETE_ESCAPE = /\e(?:[ -\/]*|[\]PX^_][^\a\e]*|\[[0-?]*)$/ @os = 0 @paint_init = false def self.rainbow(freq, i) red = Math.sin(freq*i + 0) * 127 + 128 green = Math.sin(freq*i + 2*Math::PI/3) * 127 + 128 blue = Math.sin(freq*i + 4*Math::PI/3) * 127 + 128 "#%02X%02X%02X" % [ red, green, blue ] end def self.cat(fd, opts={}) @os = opts[:os] print "\e[?25l" if opts[:animate] while true do buf = '' begin begin buf += fd.sysread(4096) invalid_encoding = !buf.dup.force_encoding(fd.external_encoding).valid_encoding? end while invalid_encoding or buf.match(INCOMPLETE_ESCAPE) rescue EOFError break end buf.force_encoding(fd.external_encoding) buf.lines.each do |line| @os += 1 println(line, opts) end end ensure if STDOUT.tty? then print "\e[m\e[?25h\e[?1;5;2004l" # system("stty sane -istrip <&1"); end end def self.println(str, defaults={}, opts={}) opts.merge!(defaults) chomped = str.sub!(/\n$/, "") str.gsub! "\t", " " opts[:animate] ? println_ani(str, opts, chomped) : println_plain(str, opts, chomped) puts if chomped end private def self.println_plain(str, defaults={}, opts={}, chomped) opts.merge!(defaults) set_mode(opts[:truecolor]) unless @paint_init filtered = str.scan(ANSI_ESCAPE) filtered.each_with_index do |c, i| color = rainbow(opts[:freq], @os+i/opts[:spread]) if opts[:invert] then print c[0], Paint.color(nil, color), c[1], "\e[49m" else print c[0], Paint.color(color), c[1], "\e[39m" end end if chomped == nil @old_os = @os @os = @os + filtered.length/opts[:spread] elsif @old_os @os = @old_os @old_os = nil end end def self.println_ani(str, opts={}, chomped) return if str.empty? print "\e7" @real_os = @os (1..opts[:duration]).each do |i| print "\e8" @os += opts[:spread] println_plain(str, opts, chomped) str.gsub!(/\e\[[0-?]*[@JKPX]/, "") sleep 1.0/opts[:speed] end @os = @real_os end def self.set_mode(truecolor) # @paint_mode_detected = Paint.mode @paint_mode_detected = %w[truecolor 24bit].include?(ENV['COLORTERM']) ? 0xffffff : 256 Paint.mode = truecolor ? 0xffffff : @paint_mode_detected STDERR.puts "DEBUG: Paint.mode = #{Paint.mode} (detected: #{@paint_mode_detected})" if ENV['LOLCAT_DEBUG'] @paint_init = true end end lolcat-100.0.1/lib/lolcat/cat.rb0000644000004100000410000001126513631454240016306 0ustar www-datawww-data# Copyright (c) 2016, moe@busyloop.net # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the lolcat nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require "lolcat/version" require "lolcat/lol" require 'stringio' require 'optimist' module Lol def self.cat! p = Optimist::Parser.new do version "lolcat #{Lolcat::VERSION} (c)2011 moe@busyloop.net" banner <
'p', :default => 3.0 opt :freq, "Rainbow frequency", :short => 'F', :default => 0.1 opt :seed, "Rainbow seed, 0 = random", :short => 'S', :default => 0 opt :animate, "Enable psychedelics", :short => 'a', :default => false opt :duration, "Animation duration", :short => 'd', :default => 12 opt :speed, "Animation speed", :short => 's', :default => 20.0 opt :invert, "Invert fg and bg", :short => 'i', :default => false opt :truecolor, "24-bit (truecolor)", :short => 't', :default => false opt :force, "Force color even when stdout is not a tty", :short => 'f', :default => false opt :version, "Print version and exit", :short => 'v' opt :help, "Show this message", :short => 'h' banner <