1a5ae21e4Smrg#!/usr/bin/env perl 204b94745Smrg# $XTermId: palettes.pl,v 1.26 2020/07/01 20:13:58 tom Exp $ 3a5ae21e4Smrg# ----------------------------------------------------------------------------- 4a5ae21e4Smrg# this file is part of xterm 5a5ae21e4Smrg# 6a5ae21e4Smrg# Copyright 2020 by Thomas E. Dickey 7a5ae21e4Smrg# 8a5ae21e4Smrg# All Rights Reserved 9a5ae21e4Smrg# 10a5ae21e4Smrg# Permission is hereby granted, free of charge, to any person obtaining a 11a5ae21e4Smrg# copy of this software and associated documentation files (the 12a5ae21e4Smrg# "Software"), to deal in the Software without restriction, including 13a5ae21e4Smrg# without limitation the rights to use, copy, modify, merge, publish, 14a5ae21e4Smrg# distribute, sublicense, and/or sell copies of the Software, and to 15a5ae21e4Smrg# permit persons to whom the Software is furnished to do so, subject to 16a5ae21e4Smrg# the following conditions: 17a5ae21e4Smrg# 18a5ae21e4Smrg# The above copyright notice and this permission notice shall be included 19a5ae21e4Smrg# in all copies or substantial portions of the Software. 20a5ae21e4Smrg# 21a5ae21e4Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22a5ae21e4Smrg# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23a5ae21e4Smrg# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24a5ae21e4Smrg# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 25a5ae21e4Smrg# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26a5ae21e4Smrg# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27a5ae21e4Smrg# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28a5ae21e4Smrg# 29a5ae21e4Smrg# Except as contained in this notice, the name(s) of the above copyright 30a5ae21e4Smrg# holders shall not be used in advertising or otherwise to promote the 31a5ae21e4Smrg# sale, use or other dealings in this Software without prior written 32a5ae21e4Smrg# authorization. 33a5ae21e4Smrg# ----------------------------------------------------------------------------- 34a5ae21e4Smrg# Demonstrate how to set palette colors using xterm's control sequences. 35a5ae21e4Smrg 36a5ae21e4Smrg# TODO: add "-n" option, to show tput in dry-run mode 37a5ae21e4Smrg# TODO: make some way to optimize-out the Tcolors resets, to focus on tput vs hardcoded 38a5ae21e4Smrg 39a5ae21e4Smrguse strict; 40a5ae21e4Smrguse warnings; 41a5ae21e4Smrg 42a5ae21e4Smrguse Getopt::Std; 43a5ae21e4Smrguse Term::ReadKey; 44a5ae21e4Smrguse FileHandle; 45a5ae21e4Smrg 46a5ae21e4Smrgselect(STDERR); 47a5ae21e4Smrg$| = 1; 48a5ae21e4Smrgselect(STDOUT); 49a5ae21e4Smrg$| = 1; 50a5ae21e4Smrg 51a5ae21e4Smrgour ( 52a5ae21e4Smrg $opt_a, $opt_b, $opt_d, $opt_g, $opt_i, 53a5ae21e4Smrg $opt_s, $opt_T, $opt_v, $opt_x, $opt_8 54a5ae21e4Smrg); 55a5ae21e4Smrg 56a5ae21e4Smrgour ( $CSI, $OSC, $ST ); 57a5ae21e4Smrg 58a5ae21e4Smrgour %colors; 59a5ae21e4Smrgour @Acolors; 60a5ae21e4Smrgour %Tcolors; 61a5ae21e4Smrgour $dump; 62a5ae21e4Smrg 63a5ae21e4Smrgour %Tcolor_names = qw( 64a5ae21e4Smrg 0 foreground 65a5ae21e4Smrg 1 background 66a5ae21e4Smrg 2 cursorColor 67a5ae21e4Smrg 3 pointerForegroundColor 68a5ae21e4Smrg 4 pointerBackgroundColor 69a5ae21e4Smrg 5 tektronixForegroundColor 70a5ae21e4Smrg 6 tektronixBackgroundColor 71a5ae21e4Smrg 7 highlightColor 72a5ae21e4Smrg 8 tektronixCursorColor 73a5ae21e4Smrg 9 highlightForegroundColor 74a5ae21e4Smrg); 75a5ae21e4Smrg 76a5ae21e4Smrgour $DARK; 77a5ae21e4Smrg 78a5ae21e4Smrgsub isatty() { 79a5ae21e4Smrg my $result = 0; 80a5ae21e4Smrg $result = 1 if ( -t 0 and -t 1 and -t 2 ); 81a5ae21e4Smrg return $result; 82a5ae21e4Smrg} 83a5ae21e4Smrg 84a5ae21e4Smrg# Adapted from 85a5ae21e4Smrg# https://github.com/altercation/solarized (xresources/solarized) 86a5ae21e4Smrgsub init_solarized() { 87a5ae21e4Smrg $colors{S_yellow} = 0xb58900; 88a5ae21e4Smrg $colors{S_orange} = 0xcb4b16; 89a5ae21e4Smrg $colors{S_red} = 0xdc322f; 90a5ae21e4Smrg $colors{S_magenta} = 0xd33682; 91a5ae21e4Smrg $colors{S_violet} = 0x6c71c4; 92a5ae21e4Smrg $colors{S_blue} = 0x268bd2; 93a5ae21e4Smrg $colors{S_cyan} = 0x2aa198; 94a5ae21e4Smrg $colors{S_green} = 0x859900; 95a5ae21e4Smrg 96a5ae21e4Smrg if ($DARK) { 97a5ae21e4Smrg $colors{S_base03} = 0x002b36; 98a5ae21e4Smrg $colors{S_base02} = 0x073642; 99a5ae21e4Smrg $colors{S_base01} = 0x586e75; 100a5ae21e4Smrg $colors{S_base00} = 0x657b83; 101a5ae21e4Smrg $colors{S_base0} = 0x839496; 102a5ae21e4Smrg $colors{S_base1} = 0x93a1a1; 103a5ae21e4Smrg $colors{S_base2} = 0xeee8d5; 104a5ae21e4Smrg $colors{S_base3} = 0xfdf6e3; 105a5ae21e4Smrg } 106a5ae21e4Smrg else { 107a5ae21e4Smrg $colors{S_base03} = 0xfdf6e3; 108a5ae21e4Smrg $colors{S_base02} = 0xeee8d5; 109a5ae21e4Smrg $colors{S_base01} = 0x93a1a1; 110a5ae21e4Smrg $colors{S_base00} = 0x839496; 111a5ae21e4Smrg $colors{S_base0} = 0x657b83; 112a5ae21e4Smrg $colors{S_base1} = 0x586e75; 113a5ae21e4Smrg $colors{S_base2} = 0x073642; 114a5ae21e4Smrg $colors{S_base3} = 0x002b36; 115a5ae21e4Smrg } 116a5ae21e4Smrg 117a5ae21e4Smrg $Acolors[0] = $colors{S_base02}; 118a5ae21e4Smrg $Acolors[1] = $colors{S_red}; 119a5ae21e4Smrg $Acolors[2] = $colors{S_green}; 120a5ae21e4Smrg $Acolors[3] = $colors{S_yellow}; 121a5ae21e4Smrg $Acolors[4] = $colors{S_blue}; 122a5ae21e4Smrg $Acolors[5] = $colors{S_magenta}; 123a5ae21e4Smrg $Acolors[6] = $colors{S_cyan}; 124a5ae21e4Smrg $Acolors[7] = $colors{S_base2}; 125a5ae21e4Smrg $Acolors[9] = $colors{S_orange}; 126a5ae21e4Smrg $Acolors[8] = $colors{S_base03}; 127a5ae21e4Smrg $Acolors[10] = $colors{S_base01}; 128a5ae21e4Smrg $Acolors[11] = $colors{S_base00}; 129a5ae21e4Smrg $Acolors[12] = $colors{S_base0}; 130a5ae21e4Smrg $Acolors[13] = $colors{S_violet}; 131a5ae21e4Smrg $Acolors[14] = $colors{S_base1}; 132a5ae21e4Smrg $Acolors[15] = $colors{S_base3}; 133a5ae21e4Smrg 134a5ae21e4Smrg $Tcolors{background} = $colors{S_base03}; 135a5ae21e4Smrg $Tcolors{foreground} = $colors{S_base0}; 136a5ae21e4Smrg $Tcolors{cursorColor} = $colors{S_base1}; 137a5ae21e4Smrg $Tcolors{pointerColorBackground} = $colors{S_base01}; 138a5ae21e4Smrg $Tcolors{pointerColorForeground} = $colors{S_base1}; 139a5ae21e4Smrg} 140a5ae21e4Smrg 141a5ae21e4Smrg# Most of the "themes" are from this source: 142a5ae21e4Smrg# http://web.archive.org/web/20100329130515/http://phraktured.net:80/terminal-colors 143a5ae21e4Smrg# in turn, that cites Aaron Griffin (2007) and uses colortheme.sh, referring to 144a5ae21e4Smrg# https://github.com/Rydgel/archlinux/blob/master/scripts/colortheme.sh 145a5ae21e4Smrg# https://web.archive.org/web/20060630201817/http://frexx.de/xterm-256-notes/ 146a5ae21e4Smrgsub init_1() { 147a5ae21e4Smrg $Tcolors{background} = 0x000000; 148a5ae21e4Smrg $Tcolors{foreground} = 0xa8a8a8; 149a5ae21e4Smrg 150a5ae21e4Smrg $Acolors[0] = 0x000000; 151a5ae21e4Smrg $Acolors[1] = 0xa80000; 152a5ae21e4Smrg $Acolors[2] = 0x00a800; 153a5ae21e4Smrg $Acolors[3] = 0xa85400; 154a5ae21e4Smrg $Acolors[4] = 0x0000a8; 155a5ae21e4Smrg $Acolors[5] = 0xa800a8; 156a5ae21e4Smrg $Acolors[6] = 0x00a8a8; 157a5ae21e4Smrg $Acolors[7] = 0xa8a8a8; 158a5ae21e4Smrg $Acolors[8] = 0x545054; 159a5ae21e4Smrg $Acolors[9] = 0xf85450; 160a5ae21e4Smrg $Acolors[10] = 0x50fc50; 161a5ae21e4Smrg $Acolors[11] = 0xf8fc50; 162a5ae21e4Smrg $Acolors[12] = 0x5054f8; 163a5ae21e4Smrg $Acolors[13] = 0xf854f8; 164a5ae21e4Smrg $Acolors[14] = 0x50fcf8; 165a5ae21e4Smrg $Acolors[15] = 0xf8fcf8; 166a5ae21e4Smrg} 167a5ae21e4Smrg 168a5ae21e4Smrgsub init_2() { 169a5ae21e4Smrg $Tcolors{background} = 0x000000; 170a5ae21e4Smrg $Tcolors{foreground} = 0x7f7f7f; 171a5ae21e4Smrg 172a5ae21e4Smrg $Acolors[0] = 0x000000; 173a5ae21e4Smrg $Acolors[1] = 0x9e1828; 174a5ae21e4Smrg $Acolors[2] = 0xaece92; 175a5ae21e4Smrg $Acolors[3] = 0x968a38; 176a5ae21e4Smrg $Acolors[4] = 0x414171; 177a5ae21e4Smrg $Acolors[5] = 0x963c59; 178a5ae21e4Smrg $Acolors[6] = 0x418179; 179a5ae21e4Smrg $Acolors[7] = 0xbebebe; 180a5ae21e4Smrg $Acolors[8] = 0x666666; 181a5ae21e4Smrg $Acolors[9] = 0xcf6171; 182a5ae21e4Smrg $Acolors[10] = 0xc5f779; 183a5ae21e4Smrg $Acolors[11] = 0xfff796; 184a5ae21e4Smrg $Acolors[12] = 0x4186be; 185a5ae21e4Smrg $Acolors[13] = 0xcf9ebe; 186a5ae21e4Smrg $Acolors[14] = 0x71bebe; 187a5ae21e4Smrg $Acolors[15] = 0xffffff; 188a5ae21e4Smrg} 189a5ae21e4Smrg 190a5ae21e4Smrgsub init_3() { 191a5ae21e4Smrg $Tcolors{background} = 0x000000; 192a5ae21e4Smrg $Tcolors{foreground} = 0xcfcfcf; 193a5ae21e4Smrg 194a5ae21e4Smrg $Acolors[0] = 0x000000; 195a5ae21e4Smrg $Acolors[1] = 0xe01010; 196a5ae21e4Smrg $Acolors[2] = 0x20ad20; 197a5ae21e4Smrg $Acolors[3] = 0xd4c24f; 198a5ae21e4Smrg $Acolors[4] = 0x231bb8; 199a5ae21e4Smrg $Acolors[5] = 0x9c3885; 200a5ae21e4Smrg $Acolors[6] = 0x1dbdb8; 201a5ae21e4Smrg $Acolors[7] = 0xfefefe; 202a5ae21e4Smrg $Acolors[8] = 0x6a6a6a; 203a5ae21e4Smrg $Acolors[9] = 0xe83a3d; 204a5ae21e4Smrg $Acolors[10] = 0x35e956; 205a5ae21e4Smrg $Acolors[11] = 0xffff2f; 206a5ae21e4Smrg $Acolors[12] = 0x3a53f0; 207a5ae21e4Smrg $Acolors[13] = 0xe628ba; 208a5ae21e4Smrg $Acolors[14] = 0x1cf5f5; 209a5ae21e4Smrg $Acolors[15] = 0xffffff; 210a5ae21e4Smrg} 211a5ae21e4Smrg 212a5ae21e4Smrgsub init_4() { 213a5ae21e4Smrg $Tcolors{background} = 0x000000; 214a5ae21e4Smrg $Tcolors{foreground} = 0xffffff; 215a5ae21e4Smrg 216a5ae21e4Smrg $Acolors[0] = 0x000000; 217a5ae21e4Smrg $Acolors[1] = 0xd36265; 218a5ae21e4Smrg $Acolors[2] = 0xaece91; 219a5ae21e4Smrg $Acolors[3] = 0xe7e18c; 220a5ae21e4Smrg $Acolors[4] = 0x7a7ab0; 221a5ae21e4Smrg $Acolors[5] = 0x963c59; 222a5ae21e4Smrg $Acolors[6] = 0x418179; 223a5ae21e4Smrg $Acolors[7] = 0xbebebe; 224a5ae21e4Smrg $Acolors[8] = 0x666666; 225a5ae21e4Smrg $Acolors[9] = 0xef8171; 226a5ae21e4Smrg $Acolors[10] = 0xe5f779; 227a5ae21e4Smrg $Acolors[11] = 0xfff796; 228a5ae21e4Smrg $Acolors[12] = 0x4186be; 229a5ae21e4Smrg $Acolors[13] = 0xef9ebe; 230a5ae21e4Smrg $Acolors[14] = 0x71bebe; 231a5ae21e4Smrg $Acolors[15] = 0xffffff; 232a5ae21e4Smrg} 233a5ae21e4Smrg 234a5ae21e4Smrgsub init_5() { 235a5ae21e4Smrg $Tcolors{background} = 0xadaaad; 236a5ae21e4Smrg $Tcolors{foreground} = 0x000000; 237a5ae21e4Smrg 238a5ae21e4Smrg $Acolors[0] = 0x000000; 239a5ae21e4Smrg $Acolors[1] = 0x640f19; 240a5ae21e4Smrg $Acolors[2] = 0x63796b; 241a5ae21e4Smrg $Acolors[3] = 0xad7142; 242a5ae21e4Smrg $Acolors[4] = 0x4f4f89; 243a5ae21e4Smrg $Acolors[5] = 0xb25c7c; 244a5ae21e4Smrg $Acolors[6] = 0x52756b; 245a5ae21e4Smrg $Acolors[7] = 0xadaaad; 246a5ae21e4Smrg $Acolors[8] = 0x525552; 247a5ae21e4Smrg $Acolors[9] = 0xa56163; 248a5ae21e4Smrg $Acolors[10] = 0xcec263; 249a5ae21e4Smrg $Acolors[11] = 0x73ae70; 250a5ae21e4Smrg $Acolors[12] = 0x36709f; 251a5ae21e4Smrg $Acolors[13] = 0xaa829c; 252a5ae21e4Smrg $Acolors[14] = 0x518989; 253a5ae21e4Smrg $Acolors[15] = 0xffffef; 254a5ae21e4Smrg} 255a5ae21e4Smrg 256a5ae21e4Smrgsub init_6() { 257a5ae21e4Smrg $Tcolors{background} = 0xbebebe; 258a5ae21e4Smrg $Tcolors{foreground} = 0x212121; 259a5ae21e4Smrg 260a5ae21e4Smrg $Acolors[0] = 0x000000; 261a5ae21e4Smrg $Acolors[1] = 0xbf7276; 262a5ae21e4Smrg $Acolors[2] = 0x86af80; 263a5ae21e4Smrg $Acolors[3] = 0x968a38; 264a5ae21e4Smrg $Acolors[4] = 0x3673b5; 265a5ae21e4Smrg $Acolors[5] = 0x9a70b2; 266a5ae21e4Smrg $Acolors[6] = 0x7abecc; 267a5ae21e4Smrg $Acolors[7] = 0xdbdbdb; 268a5ae21e4Smrg $Acolors[8] = 0x6692af; 269a5ae21e4Smrg $Acolors[9] = 0xe5505f; 270a5ae21e4Smrg $Acolors[10] = 0x87bc87; 271a5ae21e4Smrg $Acolors[11] = 0xe0d95c; 272a5ae21e4Smrg $Acolors[12] = 0x1b85d6; 273a5ae21e4Smrg $Acolors[13] = 0xad73ba; 274a5ae21e4Smrg $Acolors[14] = 0x338eaa; 275a5ae21e4Smrg $Acolors[15] = 0xf4f4f4; 276a5ae21e4Smrg} 277a5ae21e4Smrg 278a5ae21e4Smrgsub init_7() { 279a5ae21e4Smrg $Tcolors{background} = 0x676767; 280a5ae21e4Smrg $Tcolors{foreground} = 0xffffff; 281a5ae21e4Smrg 282a5ae21e4Smrg $Acolors[0] = 0x000000; 283a5ae21e4Smrg $Acolors[1] = 0xbf4646; 284a5ae21e4Smrg $Acolors[2] = 0x67b25f; 285a5ae21e4Smrg $Acolors[3] = 0xcfc44e; 286a5ae21e4Smrg $Acolors[4] = 0x516083; 287a5ae21e4Smrg $Acolors[5] = 0xca6eff; 288a5ae21e4Smrg $Acolors[6] = 0x92b2f8; 289a5ae21e4Smrg $Acolors[7] = 0xd5d5d5; 290a5ae21e4Smrg $Acolors[8] = 0x000000; 291a5ae21e4Smrg $Acolors[9] = 0xf48a8a; 292a5ae21e4Smrg $Acolors[10] = 0xa5d79f; 293a5ae21e4Smrg $Acolors[11] = 0xe1da84; 294a5ae21e4Smrg $Acolors[12] = 0xa2bbff; 295a5ae21e4Smrg $Acolors[13] = 0xe2b0ff; 296a5ae21e4Smrg $Acolors[14] = 0xbacdf8; 297a5ae21e4Smrg $Acolors[15] = 0xd5d5d5; 298a5ae21e4Smrg} 299a5ae21e4Smrg 300a5ae21e4Smrgsub init_8() { 301a5ae21e4Smrg $Tcolors{background} = 0x101010; 302a5ae21e4Smrg $Tcolors{foreground} = 0xd3d3d3; 303a5ae21e4Smrg 304a5ae21e4Smrg $Acolors[0] = 0x101010; 305a5ae21e4Smrg $Acolors[1] = 0xcd5c5c; 306a5ae21e4Smrg $Acolors[2] = 0x2e8b57; 307a5ae21e4Smrg $Acolors[3] = 0xf0e68c; 308a5ae21e4Smrg $Acolors[4] = 0xb0c4de; 309a5ae21e4Smrg $Acolors[5] = 0xba55d3; 310a5ae21e4Smrg $Acolors[6] = 0x4682b4; 311a5ae21e4Smrg $Acolors[7] = 0xd3d3d3; 312a5ae21e4Smrg $Acolors[8] = 0x4d4d4d; 313a5ae21e4Smrg $Acolors[9] = 0xff6a6a; 314a5ae21e4Smrg $Acolors[10] = 0x8fbc8f; 315a5ae21e4Smrg $Acolors[11] = 0xfffacd; 316a5ae21e4Smrg $Acolors[12] = 0x1e90ff; 317a5ae21e4Smrg $Acolors[13] = 0xdb7093; 318a5ae21e4Smrg $Acolors[14] = 0x5f9ea0; 319a5ae21e4Smrg $Acolors[15] = 0xffffff; 320a5ae21e4Smrg} 321a5ae21e4Smrg 322a5ae21e4Smrgsub init_9() { 323a5ae21e4Smrg $Tcolors{background} = 0x1a1a1a; 324a5ae21e4Smrg $Tcolors{foreground} = 0xd6d6d6; 325a5ae21e4Smrg 326a5ae21e4Smrg $Acolors[0] = 0x000000; 327a5ae21e4Smrg $Acolors[1] = 0x9e1828; 328a5ae21e4Smrg $Acolors[2] = 0x008800; 329a5ae21e4Smrg $Acolors[3] = 0x968a38; 330a5ae21e4Smrg $Acolors[4] = 0x414171; 331a5ae21e4Smrg $Acolors[5] = 0x963c59; 332a5ae21e4Smrg $Acolors[6] = 0x418179; 333a5ae21e4Smrg $Acolors[7] = 0xbebebe; 334a5ae21e4Smrg $Acolors[8] = 0x666666; 335a5ae21e4Smrg $Acolors[9] = 0xcf6171; 336a5ae21e4Smrg $Acolors[10] = 0x7cbc8c; 337a5ae21e4Smrg $Acolors[11] = 0xfff796; 338a5ae21e4Smrg $Acolors[12] = 0x4186be; 339a5ae21e4Smrg $Acolors[13] = 0xcf9ebe; 340a5ae21e4Smrg $Acolors[14] = 0x71bebe; 341a5ae21e4Smrg $Acolors[15] = 0xffffff; 342a5ae21e4Smrg} 343a5ae21e4Smrg 344a5ae21e4Smrgsub init_10() { 345a5ae21e4Smrg $Tcolors{background} = 0x1a1a1a; 346a5ae21e4Smrg $Tcolors{foreground} = 0xd6d6d6; 347a5ae21e4Smrg 348a5ae21e4Smrg $Acolors[0] = 0x000000; 349a5ae21e4Smrg $Acolors[1] = 0x98565e; 350a5ae21e4Smrg $Acolors[2] = 0x66825d; 351a5ae21e4Smrg $Acolors[3] = 0x969176; 352a5ae21e4Smrg $Acolors[4] = 0x4d6585; 353a5ae21e4Smrg $Acolors[5] = 0x967395; 354a5ae21e4Smrg $Acolors[6] = 0x5f7f7b; 355a5ae21e4Smrg $Acolors[7] = 0xb3b3b3; 356a5ae21e4Smrg $Acolors[8] = 0x737373; 357a5ae21e4Smrg $Acolors[9] = 0xcfa3a9; 358a5ae21e4Smrg $Acolors[10] = 0xcaf7bb; 359a5ae21e4Smrg $Acolors[11] = 0xfff8bc; 360a5ae21e4Smrg $Acolors[12] = 0x83a3be; 361a5ae21e4Smrg $Acolors[13] = 0xbba9cf; 362a5ae21e4Smrg $Acolors[14] = 0x96cccc; 363a5ae21e4Smrg $Acolors[15] = 0xffffff; 364a5ae21e4Smrg} 365a5ae21e4Smrg 366a5ae21e4Smrgsub init_11() { 367a5ae21e4Smrg $Tcolors{background} = 0x333333; 368a5ae21e4Smrg $Tcolors{foreground} = 0xffffff; 369a5ae21e4Smrg 370a5ae21e4Smrg $Acolors[0] = 0x333333; 371a5ae21e4Smrg $Acolors[1] = 0xffa0a0; 372a5ae21e4Smrg $Acolors[2] = 0x98fb98; 373a5ae21e4Smrg $Acolors[3] = 0xf0e68c; 374a5ae21e4Smrg $Acolors[4] = 0x87ceeb; 375a5ae21e4Smrg $Acolors[5] = 0xffa0a0; 376a5ae21e4Smrg $Acolors[6] = 0x87ceeb; 377a5ae21e4Smrg $Acolors[7] = 0xffffff; 378a5ae21e4Smrg $Acolors[8] = 0x333333; 379a5ae21e4Smrg $Acolors[9] = 0xffa0a0; 380a5ae21e4Smrg $Acolors[10] = 0x9acd32; 381a5ae21e4Smrg $Acolors[11] = 0xf0e68c; 382a5ae21e4Smrg $Acolors[12] = 0x87ceeb; 383a5ae21e4Smrg $Acolors[13] = 0xffa0a0; 384a5ae21e4Smrg $Acolors[14] = 0x87ceeb; 385a5ae21e4Smrg $Acolors[15] = 0xffffff; 386a5ae21e4Smrg} 387a5ae21e4Smrg 388a5ae21e4Smrgsub init_12() { 389a5ae21e4Smrg $Tcolors{foreground} = 0xffffff; 390a5ae21e4Smrg $Tcolors{background} = 0x000000; 391a5ae21e4Smrg 392a5ae21e4Smrg $Acolors[0] = 0x000000; 393a5ae21e4Smrg $Acolors[1] = 0xbf7276; 394a5ae21e4Smrg $Acolors[2] = 0x86af80; 395a5ae21e4Smrg $Acolors[3] = 0x968a38; 396a5ae21e4Smrg $Acolors[4] = 0x3673b5; 397a5ae21e4Smrg $Acolors[5] = 0x9a70b2; 398a5ae21e4Smrg $Acolors[6] = 0x7abecc; 399a5ae21e4Smrg $Acolors[7] = 0xdbdbdb; 400a5ae21e4Smrg $Acolors[8] = 0x6692af; 401a5ae21e4Smrg $Acolors[9] = 0xe5505f; 402a5ae21e4Smrg $Acolors[10] = 0x87bc87; 403a5ae21e4Smrg $Acolors[11] = 0xe0d95c; 404a5ae21e4Smrg $Acolors[12] = 0x1b85d6; 405a5ae21e4Smrg $Acolors[13] = 0xad73ba; 406a5ae21e4Smrg $Acolors[14] = 0x338eaa; 407a5ae21e4Smrg $Acolors[15] = 0xf4f4f4; 408a5ae21e4Smrg} 409a5ae21e4Smrg 410a5ae21e4Smrgsub init_13() { 411a5ae21e4Smrg $Tcolors{background} = 0x000000; 412a5ae21e4Smrg $Tcolors{foreground} = 0xaaaaaa; 413a5ae21e4Smrg 414a5ae21e4Smrg $Acolors[0] = 0x000000; 415a5ae21e4Smrg $Acolors[1] = 0x9e1828; 416a5ae21e4Smrg $Acolors[2] = 0xaece92; 417a5ae21e4Smrg $Acolors[3] = 0x968a38; 418a5ae21e4Smrg $Acolors[4] = 0x414171; 419a5ae21e4Smrg $Acolors[5] = 0x963c59; 420a5ae21e4Smrg $Acolors[6] = 0x7f9f7f; 421a5ae21e4Smrg $Acolors[7] = 0xbebebe; 422a5ae21e4Smrg $Acolors[8] = 0x666666; 423a5ae21e4Smrg $Acolors[9] = 0xcf6171; 424a5ae21e4Smrg $Acolors[10] = 0xafc5af; 425a5ae21e4Smrg $Acolors[11] = 0xf0dfaf; 426a5ae21e4Smrg $Acolors[12] = 0x8e9fbc; 427a5ae21e4Smrg $Acolors[13] = 0xdca3a3; 428a5ae21e4Smrg $Acolors[14] = 0x95c1c5; 429a5ae21e4Smrg $Acolors[15] = 0xffffff; 430a5ae21e4Smrg} 431a5ae21e4Smrg 432a5ae21e4Smrgsub init_14() { 433a5ae21e4Smrg $Tcolors{background} = 0x959595; 434a5ae21e4Smrg $Tcolors{foreground} = 0x000000; 435a5ae21e4Smrg 436a5ae21e4Smrg $Acolors[0] = 0x7f7f7f; 437a5ae21e4Smrg $Acolors[1] = 0xcd0000; 438a5ae21e4Smrg $Acolors[2] = 0x008b00; 439a5ae21e4Smrg $Acolors[3] = 0xeeee00; 440a5ae21e4Smrg $Acolors[4] = 0x0000cd; 441a5ae21e4Smrg $Acolors[5] = 0xcd00cd; 442a5ae21e4Smrg $Acolors[6] = 0x00eeee; 443a5ae21e4Smrg $Acolors[7] = 0xfaebd7; 444a5ae21e4Smrg $Acolors[8] = 0xe5e5e5; 445a5ae21e4Smrg $Acolors[9] = 0x800000; 446a5ae21e4Smrg $Acolors[10] = 0x005020; 447a5ae21e4Smrg $Acolors[11] = 0x995500; 448a5ae21e4Smrg $Acolors[12] = 0x004080; 449a5ae21e4Smrg $Acolors[13] = 0x443300; 450a5ae21e4Smrg $Acolors[14] = 0x306080; 451a5ae21e4Smrg $Acolors[15] = 0xffffff; 452a5ae21e4Smrg} 453a5ae21e4Smrg 454a5ae21e4Smrgsub init_15() { 455a5ae21e4Smrg $Tcolors{background} = 0x1d2b3a; 456a5ae21e4Smrg $Tcolors{foreground} = 0xbebebe; 457a5ae21e4Smrg 458a5ae21e4Smrg $Acolors[0] = 0x000000; 459a5ae21e4Smrg $Acolors[1] = 0xd36265; 460a5ae21e4Smrg $Acolors[2] = 0xaece91; 461a5ae21e4Smrg $Acolors[3] = 0xe7e18c; 462a5ae21e4Smrg $Acolors[4] = 0x7a7ab0; 463a5ae21e4Smrg $Acolors[5] = 0x963c59; 464a5ae21e4Smrg $Acolors[6] = 0x418179; 465a5ae21e4Smrg $Acolors[7] = 0xbebebe; 466a5ae21e4Smrg $Acolors[8] = 0x666666; 467a5ae21e4Smrg $Acolors[9] = 0xef8171; 468a5ae21e4Smrg $Acolors[10] = 0xe5f779; 469a5ae21e4Smrg $Acolors[11] = 0xfff799; 470a5ae21e4Smrg $Acolors[12] = 0x4186be; 471a5ae21e4Smrg $Acolors[13] = 0xef9ebe; 472a5ae21e4Smrg $Acolors[14] = 0x71bebe; 473a5ae21e4Smrg $Acolors[15] = 0xffffff; 474a5ae21e4Smrg} 475a5ae21e4Smrg 476a5ae21e4Smrgsub init_16() { 477a5ae21e4Smrg $Tcolors{background} = 0x000000; 478a5ae21e4Smrg $Tcolors{foreground} = 0xbebebe; 479a5ae21e4Smrg 480a5ae21e4Smrg $Acolors[0] = 0x000000; 481a5ae21e4Smrg $Acolors[1] = 0x9e1828; 482a5ae21e4Smrg $Acolors[2] = 0xaece92; 483a5ae21e4Smrg $Acolors[3] = 0x968a38; 484a5ae21e4Smrg $Acolors[4] = 0x414171; 485a5ae21e4Smrg $Acolors[5] = 0x963c59; 486a5ae21e4Smrg $Acolors[6] = 0x418179; 487a5ae21e4Smrg $Acolors[7] = 0xbebebe; 488a5ae21e4Smrg $Acolors[8] = 0x666666; 489a5ae21e4Smrg $Acolors[9] = 0xcf6171; 490a5ae21e4Smrg $Acolors[10] = 0xc5f779; 491a5ae21e4Smrg $Acolors[11] = 0xfff796; 492a5ae21e4Smrg $Acolors[12] = 0x4186be; 493a5ae21e4Smrg $Acolors[13] = 0xcf9ebe; 494a5ae21e4Smrg $Acolors[14] = 0x71bebe; 495a5ae21e4Smrg $Acolors[15] = 0xffffff; 496a5ae21e4Smrg} 497a5ae21e4Smrg 498a5ae21e4Smrgsub init_17() { 499a5ae21e4Smrg $Tcolors{background} = 0x000000; 500a5ae21e4Smrg $Tcolors{foreground} = 0xe5e5e5; 501a5ae21e4Smrg 502a5ae21e4Smrg $Acolors[0] = 0x000000; 503a5ae21e4Smrg $Acolors[1] = 0xff0000; 504a5ae21e4Smrg $Acolors[2] = 0x00ff00; 505a5ae21e4Smrg $Acolors[3] = 0xffff00; 506a5ae21e4Smrg $Acolors[4] = 0x0000ff; 507a5ae21e4Smrg $Acolors[5] = 0xff00ff; 508a5ae21e4Smrg $Acolors[6] = 0x00ffff; 509a5ae21e4Smrg $Acolors[7] = 0xffffff; 510a5ae21e4Smrg $Acolors[8] = 0xffd39b; 511a5ae21e4Smrg $Acolors[9] = 0xff8247; 512a5ae21e4Smrg $Acolors[10] = 0xff82ab; 513a5ae21e4Smrg $Acolors[11] = 0x87cefa; 514a5ae21e4Smrg $Acolors[12] = 0xffffff; 515a5ae21e4Smrg $Acolors[13] = 0xffffff; 516a5ae21e4Smrg $Acolors[14] = 0xffffff; 517a5ae21e4Smrg $Acolors[15] = 0xffffff; 518a5ae21e4Smrg} 519a5ae21e4Smrg 520a5ae21e4Smrgsub init_18() { 521a5ae21e4Smrg $Acolors[0] = 0x000000; 522a5ae21e4Smrg $Acolors[1] = 0x9e1828; 523a5ae21e4Smrg $Acolors[2] = 0x5cb247; 524a5ae21e4Smrg $Acolors[3] = 0x968a38; 525a5ae21e4Smrg $Acolors[4] = 0x4161a0; 526a5ae21e4Smrg $Acolors[5] = 0x9b768e; 527a5ae21e4Smrg $Acolors[6] = 0x419189; 528a5ae21e4Smrg $Acolors[7] = 0xbebebe; 529a5ae21e4Smrg $Acolors[8] = 0x666666; 530a5ae21e4Smrg $Acolors[9] = 0xcf6171; 531a5ae21e4Smrg $Acolors[10] = 0xc5f779; 532a5ae21e4Smrg $Acolors[11] = 0xfff796; 533a5ae21e4Smrg $Acolors[12] = 0x4186be; 534a5ae21e4Smrg $Acolors[13] = 0xcf9ebe; 535a5ae21e4Smrg $Acolors[14] = 0x71bebe; 536a5ae21e4Smrg $Acolors[15] = 0xdddddd; 537a5ae21e4Smrg} 538a5ae21e4Smrg 539a5ae21e4Smrgsub init_19() { 540a5ae21e4Smrg $Acolors[0] = 0x000000; 541a5ae21e4Smrg $Acolors[1] = 0xb07050; 542a5ae21e4Smrg $Acolors[2] = 0x12914e; 543a5ae21e4Smrg $Acolors[3] = 0xa0a070; 544a5ae21e4Smrg $Acolors[4] = 0x3e4581; 545a5ae21e4Smrg $Acolors[5] = 0xa070a0; 546a5ae21e4Smrg $Acolors[6] = 0x70a0a0; 547a5ae21e4Smrg $Acolors[7] = 0xa0a0a0; 548a5ae21e4Smrg $Acolors[8] = 0x606060; 549a5ae21e4Smrg $Acolors[9] = 0xb07050; 550a5ae21e4Smrg $Acolors[10] = 0x12914e; 551a5ae21e4Smrg $Acolors[11] = 0xc0c090; 552a5ae21e4Smrg $Acolors[12] = 0x3e4581; 553a5ae21e4Smrg $Acolors[13] = 0xc090c0; 554a5ae21e4Smrg $Acolors[14] = 0x90c0c0; 555a5ae21e4Smrg $Acolors[15] = 0xffffff; 556a5ae21e4Smrg} 557a5ae21e4Smrg 558a5ae21e4Smrgsub init_20() { 559a5ae21e4Smrg $Tcolors{foreground} = 0xaaaaaa; 560a5ae21e4Smrg $Tcolors{background} = 0x000000; 561a5ae21e4Smrg 562a5ae21e4Smrg $Acolors[0] = 0x303430; 563a5ae21e4Smrg $Acolors[1] = 0xbf7979; 564a5ae21e4Smrg $Acolors[2] = 0x97b26b; 565a5ae21e4Smrg $Acolors[3] = 0xcdcdc1; 566a5ae21e4Smrg $Acolors[4] = 0x86a2be; 567a5ae21e4Smrg $Acolors[5] = 0xd9b798; 568a5ae21e4Smrg $Acolors[6] = 0xa1b5cd; 569a5ae21e4Smrg $Acolors[7] = 0xffffff; 570a5ae21e4Smrg $Acolors[8] = 0xcdb5cd; 571a5ae21e4Smrg $Acolors[9] = 0xf4a45f; 572a5ae21e4Smrg $Acolors[10] = 0xc5f779; 573a5ae21e4Smrg $Acolors[11] = 0xffffef; 574a5ae21e4Smrg $Acolors[12] = 0x98afd9; 575a5ae21e4Smrg $Acolors[13] = 0xd7d998; 576a5ae21e4Smrg $Acolors[14] = 0xa1b5cd; 577a5ae21e4Smrg $Acolors[15] = 0xdedede; 578a5ae21e4Smrg} 579a5ae21e4Smrg 580a5ae21e4Smrgsub init_21() { 581a5ae21e4Smrg $Tcolors{background} = 0x1a1a1a; 582a5ae21e4Smrg $Tcolors{foreground} = 0xaaaaaa; 583a5ae21e4Smrg 584a5ae21e4Smrg $Acolors[0] = 0x000000; 585a5ae21e4Smrg $Acolors[1] = 0x9e1828; 586a5ae21e4Smrg $Acolors[2] = 0x008800; 587a5ae21e4Smrg $Acolors[3] = 0xd2bb4b; 588a5ae21e4Smrg $Acolors[4] = 0x414171; 589a5ae21e4Smrg $Acolors[5] = 0x963c59; 590a5ae21e4Smrg $Acolors[6] = 0x418179; 591a5ae21e4Smrg $Acolors[7] = 0xbebebe; 592a5ae21e4Smrg $Acolors[8] = 0x666666; 593a5ae21e4Smrg $Acolors[9] = 0xbc5766; 594a5ae21e4Smrg $Acolors[10] = 0x61a171; 595a5ae21e4Smrg $Acolors[11] = 0xe7db52; 596a5ae21e4Smrg $Acolors[12] = 0x5085af; 597a5ae21e4Smrg $Acolors[13] = 0xa97a99; 598a5ae21e4Smrg $Acolors[14] = 0x6ba4a4; 599a5ae21e4Smrg $Acolors[15] = 0xffffff; 600a5ae21e4Smrg} 601a5ae21e4Smrg 602a5ae21e4Smrgsub init_22() { 603a5ae21e4Smrg $Tcolors{background} = 0x000000; 604a5ae21e4Smrg $Tcolors{foreground} = 0xbebebe; 605a5ae21e4Smrg 606a5ae21e4Smrg $Acolors[0] = 0x000000; 607a5ae21e4Smrg $Acolors[1] = 0xd36265; 608a5ae21e4Smrg $Acolors[2] = 0xaece91; 609a5ae21e4Smrg $Acolors[3] = 0xe7e18c; 610a5ae21e4Smrg $Acolors[4] = 0x7a7ab0; 611a5ae21e4Smrg $Acolors[5] = 0x963c59; 612a5ae21e4Smrg $Acolors[6] = 0x7f9f7f; 613a5ae21e4Smrg $Acolors[7] = 0xbebebe; 614a5ae21e4Smrg $Acolors[8] = 0x666666; 615a5ae21e4Smrg $Acolors[9] = 0xef8171; 616a5ae21e4Smrg $Acolors[10] = 0xe5f779; 617a5ae21e4Smrg $Acolors[11] = 0xf0dfaf; 618a5ae21e4Smrg $Acolors[12] = 0x8e9fbc; 619a5ae21e4Smrg $Acolors[13] = 0xef9ebe; 620a5ae21e4Smrg $Acolors[14] = 0x71bebe; 621a5ae21e4Smrg $Acolors[15] = 0xffffff; 622a5ae21e4Smrg} 623a5ae21e4Smrg 624a5ae21e4Smrgsub init_23() { 625a5ae21e4Smrg $Tcolors{background} = 0x0e0e0e; 626a5ae21e4Smrg $Tcolors{foreground} = 0x4ad5e1; 627a5ae21e4Smrg 628a5ae21e4Smrg $Acolors[0] = 0x000000; 629a5ae21e4Smrg $Acolors[1] = 0xdc74d1; 630a5ae21e4Smrg $Acolors[2] = 0x0eb8c7; 631a5ae21e4Smrg $Acolors[3] = 0xdfe37e; 632a5ae21e4Smrg $Acolors[4] = 0x0; #?? 633a5ae21e4Smrg $Acolors[5] = 0x9e88f0; 634a5ae21e4Smrg $Acolors[6] = 0x73f7ff; 635a5ae21e4Smrg $Acolors[7] = 0xe1dddd; 636a5ae21e4Smrg $Acolors[8] = 0x8b8f93; 637a5ae21e4Smrg $Acolors[9] = 0xdc74d1; 638a5ae21e4Smrg $Acolors[10] = 0x0eb8c7; 639a5ae21e4Smrg $Acolors[11] = 0xdfe37e; 640a5ae21e4Smrg $Acolors[13] = 0x9e88f0; 641a5ae21e4Smrg $Acolors[14] = 0x73f7ff; 642a5ae21e4Smrg $Acolors[15] = 0xe1dddd; 643a5ae21e4Smrg} 644a5ae21e4Smrg 645a5ae21e4Smrgsub init_24() { 646a5ae21e4Smrg $Acolors[0] = 0x000000; 647a5ae21e4Smrg $Acolors[1] = 0xcd5c5c; 648a5ae21e4Smrg $Acolors[2] = 0x8eae71; 649a5ae21e4Smrg $Acolors[3] = 0xd2b48c; 650a5ae21e4Smrg $Acolors[4] = 0x5f7b8a; 651a5ae21e4Smrg $Acolors[5] = 0xcdcdb4; 652a5ae21e4Smrg $Acolors[6] = 0x686868; 653a5ae21e4Smrg $Acolors[7] = 0xffffff; 654a5ae21e4Smrg $Acolors[8] = 0x000000; 655a5ae21e4Smrg $Acolors[9] = 0xee6363; 656a5ae21e4Smrg $Acolors[10] = 0x95c749; 657a5ae21e4Smrg $Acolors[11] = 0xcdcdc1; 658a5ae21e4Smrg $Acolors[12] = 0x6b7b8a; 659a5ae21e4Smrg $Acolors[13] = 0xcdcdb4; 660a5ae21e4Smrg $Acolors[14] = 0x778798; 661a5ae21e4Smrg $Acolors[15] = 0xcacaca; 662a5ae21e4Smrg} 663a5ae21e4Smrg 664a5ae21e4Smrgsub init_25() { 665a5ae21e4Smrg $Acolors[0] = 0x000000; 666a5ae21e4Smrg $Acolors[1] = 0x800000; 667a5ae21e4Smrg $Acolors[2] = 0x008000; 668a5ae21e4Smrg $Acolors[3] = 0xd0d090; 669a5ae21e4Smrg $Acolors[4] = 0x000080; 670a5ae21e4Smrg $Acolors[5] = 0x800080; 671a5ae21e4Smrg $Acolors[6] = 0xa6caf0; 672a5ae21e4Smrg $Acolors[7] = 0xd0d0d0; 673a5ae21e4Smrg $Acolors[8] = 0xb0b0b0; 674a5ae21e4Smrg $Acolors[9] = 0xf08060; 675a5ae21e4Smrg $Acolors[10] = 0x60f080; 676a5ae21e4Smrg $Acolors[11] = 0xe0c060; 677a5ae21e4Smrg $Acolors[12] = 0x80c0e0; 678a5ae21e4Smrg $Acolors[13] = 0xf0c0f0; 679a5ae21e4Smrg $Acolors[14] = 0xc0d8f8; 680a5ae21e4Smrg $Acolors[15] = 0xe0e0e0; 681a5ae21e4Smrg} 682a5ae21e4Smrg 683a5ae21e4Smrg# (Griffin) colors ripped from rezza: http://metawire.org/~rezza/index.php 684a5ae21e4Smrgsub init_rezza() { 685a5ae21e4Smrg $Tcolors{foreground} = 0xdddddd; 686a5ae21e4Smrg $Tcolors{background} = 0x222222; 687a5ae21e4Smrg 688a5ae21e4Smrg $Acolors[0] = 0x191919; 689a5ae21e4Smrg $Acolors[1] = 0x803232; 690a5ae21e4Smrg $Acolors[2] = 0x5b762f; 691a5ae21e4Smrg $Acolors[3] = 0xaa9943; 692a5ae21e4Smrg $Acolors[4] = 0x324c80; 693a5ae21e4Smrg $Acolors[5] = 0x706c9a; 694a5ae21e4Smrg $Acolors[6] = 0x92b19e; 695a5ae21e4Smrg $Acolors[7] = 0xffffff; 696a5ae21e4Smrg $Acolors[8] = 0x252525; 697a5ae21e4Smrg $Acolors[9] = 0x982b2b; 698a5ae21e4Smrg $Acolors[10] = 0x89b83f; 699a5ae21e4Smrg $Acolors[11] = 0xefef60; 700a5ae21e4Smrg $Acolors[12] = 0x2b4f98; 701a5ae21e4Smrg $Acolors[13] = 0x826ab1; 702a5ae21e4Smrg $Acolors[14] = 0xa1cdcd; 703a5ae21e4Smrg $Acolors[15] = 0xdddddd; 704a5ae21e4Smrg} 705a5ae21e4Smrg 706a5ae21e4Smrgsub init_theme($) { 707a5ae21e4Smrg my $theme = shift; 708a5ae21e4Smrg 709a5ae21e4Smrg @Acolors = (); 710a5ae21e4Smrg %Tcolors = (); 711a5ae21e4Smrg 712a5ae21e4Smrg &init_solarized if ( index( "solarized", $theme ) eq 0 ); 713a5ae21e4Smrg &init_rezza if ( index( "rezza", $theme ) eq 0 ); 714a5ae21e4Smrg 715a5ae21e4Smrg &init_1 if ( $theme eq 1 ); 716a5ae21e4Smrg &init_2 if ( $theme eq 2 ); 717a5ae21e4Smrg &init_3 if ( $theme eq 3 ); 718a5ae21e4Smrg &init_4 if ( $theme eq 4 ); 719a5ae21e4Smrg &init_5 if ( $theme eq 5 ); 720a5ae21e4Smrg &init_6 if ( $theme eq 6 ); 721a5ae21e4Smrg &init_7 if ( $theme eq 7 ); 722a5ae21e4Smrg &init_8 if ( $theme eq 8 ); 723a5ae21e4Smrg &init_9 if ( $theme eq 9 ); 724a5ae21e4Smrg &init_10 if ( $theme eq 10 ); 725a5ae21e4Smrg &init_11 if ( $theme eq 11 ); 726a5ae21e4Smrg &init_12 if ( $theme eq 12 ); 727a5ae21e4Smrg &init_13 if ( $theme eq 13 ); 728a5ae21e4Smrg &init_14 if ( $theme eq 14 ); 729a5ae21e4Smrg &init_15 if ( $theme eq 15 ); 730a5ae21e4Smrg &init_16 if ( $theme eq 16 ); 731a5ae21e4Smrg &init_17 if ( $theme eq 17 ); 732a5ae21e4Smrg &init_18 if ( $theme eq 18 ); 733a5ae21e4Smrg &init_19 if ( $theme eq 19 ); 734a5ae21e4Smrg &init_20 if ( $theme eq 20 ); 735a5ae21e4Smrg &init_21 if ( $theme eq 21 ); 736a5ae21e4Smrg &init_22 if ( $theme eq 22 ); 737a5ae21e4Smrg &init_23 if ( $theme eq 23 ); 738a5ae21e4Smrg &init_24 if ( $theme eq 24 ); 739a5ae21e4Smrg &init_25 if ( $theme eq 25 ); 740a5ae21e4Smrg} 741a5ae21e4Smrg 742a5ae21e4Smrgsub all_themes() { 743a5ae21e4Smrg my @result; 744a5ae21e4Smrg push @result, "solarized"; 745a5ae21e4Smrg push @result, "rezza"; 746a5ae21e4Smrg for my $n ( 1 .. 25 ) { 747a5ae21e4Smrg push @result, $n; 748a5ae21e4Smrg } 749a5ae21e4Smrg return \@result; 750a5ae21e4Smrg} 751a5ae21e4Smrg 752a5ae21e4Smrgsub raw() { 753a5ae21e4Smrg ReadMode 'ultra-raw', 'STDIN'; # allow single-character inputs 754a5ae21e4Smrg} 755a5ae21e4Smrg 756a5ae21e4Smrgsub cooked() { 757a5ae21e4Smrg ReadMode 'normal'; 758a5ae21e4Smrg} 759a5ae21e4Smrg 760a5ae21e4Smrgsub get_reply($$) { 761a5ae21e4Smrg my $command = shift; 762a5ae21e4Smrg my $finish = shift; 763a5ae21e4Smrg my $reply = ""; 764a5ae21e4Smrg 765a5ae21e4Smrg &raw; 766a5ae21e4Smrg printf STDERR "%s", $command; 767a5ae21e4Smrg my $start = time; 768a5ae21e4Smrg while ( index( $reply, $finish ) < 0 ) { 769a5ae21e4Smrg my $test = ReadKey 0.1; 770a5ae21e4Smrg last if ( time > ( $start + 3 ) ); 771a5ae21e4Smrg next if not defined $test; 772a5ae21e4Smrg 773a5ae21e4Smrg $reply .= $test; 774a5ae21e4Smrg } 775a5ae21e4Smrg &cooked; 776a5ae21e4Smrg return $reply; 777a5ae21e4Smrg} 778a5ae21e4Smrg 779a5ae21e4Smrgsub query_color($$) { 780a5ae21e4Smrg my $ansi = shift; 781a5ae21e4Smrg my $code = shift; 782a5ae21e4Smrg my @result; 783a5ae21e4Smrg my $parms; 784a5ae21e4Smrg if ($ansi) { 785a5ae21e4Smrg $parms = sprintf( "4;%d", $code ); 786a5ae21e4Smrg } 787a5ae21e4Smrg else { 788a5ae21e4Smrg $parms = sprintf( "%d", 10 + $code ); 789a5ae21e4Smrg } 790a5ae21e4Smrg my $query = sprintf( "%s%s;?%s", $OSC, $parms, $ST ); 791a5ae21e4Smrg my $reply = &get_reply( $query, $ST ); 792a5ae21e4Smrg if ( $reply =~ /^${OSC}${parms};rgb:/ ) { 793a5ae21e4Smrg $reply =~ s/^${OSC}${parms};rgb://; 794a5ae21e4Smrg $reply =~ s/[^[:print:]].*$//; 795a5ae21e4Smrg if ( $reply =~ /^[[:xdigit:]]+(\/[[:xdigit:]]+)+$/ ) { 796a5ae21e4Smrg $reply =~ s/([[:xdigit:]]+)/0x$1/g; 797a5ae21e4Smrg @result = split /\//, $reply; 798a5ae21e4Smrg 799a5ae21e4Smrg # RGB should have 3 values 800a5ae21e4Smrg for my $n ( 0 .. $#result ) { 801a5ae21e4Smrg $result[$n] = hex $result[$n]; 802a5ae21e4Smrg } 803a5ae21e4Smrg 804a5ae21e4Smrg # add the limit based on the number of bits needed to print. 805a5ae21e4Smrg push @result, 2**( 4 * ( length($reply) - 2 ) / 3 ); 806a5ae21e4Smrg } 807a5ae21e4Smrg } 808a5ae21e4Smrg 809a5ae21e4Smrg # this would occur in case of error 810a5ae21e4Smrg push @result, $reply unless ( $#result >= 3 ); 811a5ae21e4Smrg return @result; 812a5ae21e4Smrg} 813a5ae21e4Smrg 814a5ae21e4Smrgsub get_color_string($$) { 815a5ae21e4Smrg my $ansi = shift; 816a5ae21e4Smrg my $color = shift; 817a5ae21e4Smrg my $result; 818a5ae21e4Smrg my @check = &query_color( $ansi, $color ); 819a5ae21e4Smrg if ( $#check == 3 ) { 820a5ae21e4Smrg while ( $check[3] > 0x10000 ) { 821a5ae21e4Smrg $check[0] /= ( 16 * 16 ); 822a5ae21e4Smrg $check[1] /= ( 16 * 16 ); 823a5ae21e4Smrg $check[2] /= ( 16 * 16 ); 824a5ae21e4Smrg $check[3] /= ( 16 * 16 * 16 ); 825a5ae21e4Smrg } 826a5ae21e4Smrg $result = sprintf "( %3d %3d %3d )", $check[0], $check[1], $check[2]; 827a5ae21e4Smrg } 828a5ae21e4Smrg else { 829a5ae21e4Smrg $result = sprintf( "{%s}", $check[0] ); 830a5ae21e4Smrg } 831a5ae21e4Smrg return $result; 832a5ae21e4Smrg} 833a5ae21e4Smrg 834a5ae21e4Smrgsub guess_dark() { 835a5ae21e4Smrg my $result = 0; # assume black-on-white 836a5ae21e4Smrg if (&isatty) { 837a5ae21e4Smrg my @check = &query_color( 0, 1 ); 838a5ae21e4Smrg if ( $#check == 3 ) { 839a5ae21e4Smrg my $value = ( ( $check[0] ) + ( $check[1] ) + ( $check[2] ) ) / 3; 840a5ae21e4Smrg printf "%#x / %#x\n", $value, $check[3]; 841a5ae21e4Smrg $result = 1 if ( $value < ( $check[3] / 2 ) ); 842a5ae21e4Smrg printf "%s\n", $result ? "dark" : "light" if ($opt_v); 843a5ae21e4Smrg } 844a5ae21e4Smrg } 845a5ae21e4Smrg return $result; 846a5ae21e4Smrg} 847a5ae21e4Smrg 848a5ae21e4Smrgsub for_tput($) { 849a5ae21e4Smrg my $value = shift; 850a5ae21e4Smrg $value *= 1000; 851a5ae21e4Smrg $value /= 255; 852a5ae21e4Smrg $value *= 256 / 255; 853a5ae21e4Smrg return sprintf( "%.0f", $value ); 854a5ae21e4Smrg} 855a5ae21e4Smrg 856a5ae21e4Smrgsub reset_Acolor($) { 857a5ae21e4Smrg my $number = shift; 858a5ae21e4Smrg printf STDERR "%s104;%d%s", $OSC, $number, $ST; 859a5ae21e4Smrg printf "\t%2d ->reset Acolor\n", $number if ($opt_v); 860a5ae21e4Smrg} 861a5ae21e4Smrg 862a5ae21e4Smrgsub set_Acolor($) { 863a5ae21e4Smrg my $number = shift; 864a5ae21e4Smrg my $result = 0; 865a5ae21e4Smrg if ( defined $Acolors[$number] ) { 866a5ae21e4Smrg my $value = $Acolors[$number]; 867a5ae21e4Smrg my $r = ( ( $value / ( 256 * 256 ) ) % 256 ); 868a5ae21e4Smrg my $g = ( ( $value / (256) ) % 256 ); 869a5ae21e4Smrg my $b = ( ( $value / (1) ) % 256 ); 870a5ae21e4Smrg if ($opt_x) { 871a5ae21e4Smrg system( 872a5ae21e4Smrg sprintf( 873a5ae21e4Smrg "$opt_x $opt_T initc %d %d %d %d", 874a5ae21e4Smrg $number, &for_tput($r), &for_tput($g), &for_tput($b) 875a5ae21e4Smrg ) 876a5ae21e4Smrg ); 877a5ae21e4Smrg } 878a5ae21e4Smrg else { 879a5ae21e4Smrg printf STDERR "%s4;%d;rgb:%02X/%02X/%02X%s", $OSC, $number, $r, $g, 880a5ae21e4Smrg $b, 881a5ae21e4Smrg $ST; 882a5ae21e4Smrg } 883a5ae21e4Smrg printf "\t%2d ->%06X ( %3d %3d %3d )\n", $number, $value, $r, $g, $b 884a5ae21e4Smrg if ($opt_v); 885a5ae21e4Smrg $result = 1; 886a5ae21e4Smrg } 887a5ae21e4Smrg return $result; 888a5ae21e4Smrg} 889a5ae21e4Smrg 890a5ae21e4Smrgsub reset_Tcolor($) { 891a5ae21e4Smrg my $number = shift; 892a5ae21e4Smrg my $actual = $Tcolor_names{$number}; 893a5ae21e4Smrg printf STDERR "%s%d%s", $OSC, 110 + $number, $ST; 894a5ae21e4Smrg printf "\t%2d ->reset Tcolor{%s}\n", $number, $actual 895a5ae21e4Smrg if ($opt_v); 896a5ae21e4Smrg} 897a5ae21e4Smrg 898a5ae21e4Smrgsub set_Tcolor($) { 899a5ae21e4Smrg my $number = shift; 900a5ae21e4Smrg my $actual = $Tcolor_names{$number}; 901a5ae21e4Smrg my $result = 0; 902a5ae21e4Smrg if (%Tcolors) { 903a5ae21e4Smrg if ( defined $Tcolors{$actual} ) { 904a5ae21e4Smrg my $value = $Tcolors{$actual}; 905a5ae21e4Smrg my $r = ( ( $value / ( 256 * 256 ) ) % 256 ); 906a5ae21e4Smrg my $g = ( ( $value / (256) ) % 256 ); 907a5ae21e4Smrg my $b = ( ( $value / (1) ) % 256 ); 908a5ae21e4Smrg printf STDERR "%s%d;rgb:%02X/%02X/%02X%s", $OSC, 10 + $number, $r, 909a5ae21e4Smrg $g, $b, $ST; 910a5ae21e4Smrg printf "\t%2d ->set Tcolor{%s}\n", $number, $actual 911a5ae21e4Smrg if ($opt_v); 912a5ae21e4Smrg $result = 1; 913a5ae21e4Smrg } 914a5ae21e4Smrg } 915a5ae21e4Smrg return $result; 916a5ae21e4Smrg} 917a5ae21e4Smrg 918a5ae21e4Smrgsub set_colors() { 919a5ae21e4Smrg for my $n ( 0 .. 2 ) { 920a5ae21e4Smrg &reset_Tcolor($n) unless &set_Tcolor($n); 921a5ae21e4Smrg } 922a5ae21e4Smrg for my $n ( 0 .. 15 ) { 923a5ae21e4Smrg &reset_Acolor($n) unless &set_Acolor($n); 924a5ae21e4Smrg } 925a5ae21e4Smrg printf STDERR "\007" if (&isatty); 926a5ae21e4Smrg STDERR->flush; 927a5ae21e4Smrg} 928a5ae21e4Smrg 929a5ae21e4Smrgsub reset_colors() { 930a5ae21e4Smrg for my $n ( 0 .. 2 ) { 931a5ae21e4Smrg &reset_Tcolor($n); 932a5ae21e4Smrg } 933a5ae21e4Smrg printf STDERR "%s104%s", $OSC, $ST; 934a5ae21e4Smrg printf "\tall ->reset Acolor\n" if ($opt_v); 935a5ae21e4Smrg} 936a5ae21e4Smrg 937a5ae21e4Smrgsub dump_colors($) { 938a5ae21e4Smrg my $theme = shift; 939a5ae21e4Smrg if ( open( DUMP, ">>", $opt_d ) ) { 940a5ae21e4Smrg my $state = &get_reply( sprintf( "%s#R", $CSI ), "Q" ); 941a5ae21e4Smrg $state = substr( $state, length($CSI) ) 942a5ae21e4Smrg if ( index( $state, $CSI ) == 0 ); 943a5ae21e4Smrg printf DUMP "State \"%s\"\n", $state; 944a5ae21e4Smrg printf DUMP "Palette after \"%s\"\n", $theme; 945a5ae21e4Smrg if (&isatty) { 946a5ae21e4Smrg printf DUMP "Tcolors:\n"; 947a5ae21e4Smrg for my $n ( 0 .. 2 ) { 948a5ae21e4Smrg printf DUMP "\t%s = %s\n", $Tcolor_names{$n}, 949a5ae21e4Smrg &get_color_string( 0, $n ); 950a5ae21e4Smrg } 951a5ae21e4Smrg printf DUMP "Acolors:\n"; 952a5ae21e4Smrg for my $n ( 0 .. 15 ) { 953a5ae21e4Smrg printf DUMP "\t%2d -> %s\n", $n, &get_color_string( 1, $n ); 954a5ae21e4Smrg } 955a5ae21e4Smrg } 956a5ae21e4Smrg close DUMP; 957a5ae21e4Smrg } 958a5ae21e4Smrg} 959a5ae21e4Smrg 960a5ae21e4Smrgsub show_colors($) { 961a5ae21e4Smrg my $theme = shift; 962a5ae21e4Smrg if ( substr( $theme, 0, 1 ) eq "+" ) { 963a5ae21e4Smrg 964a5ae21e4Smrg # push (or set slot, if number follows) 965a5ae21e4Smrg if ( $theme =~ /^\+[0-9]$/ ) { 966a5ae21e4Smrg my $slot = substr( $theme, 1 ); 967a5ae21e4Smrg printf STDERR "%s#%dP", $CSI, $slot + 1; 968a5ae21e4Smrg printf "\tpush %s\n", $slot if ($opt_v); 969a5ae21e4Smrg } 970a5ae21e4Smrg else { 971a5ae21e4Smrg printf STDERR "%s#P", $CSI; 972a5ae21e4Smrg printf "\tpush\n" if ($opt_v); 973a5ae21e4Smrg } 974a5ae21e4Smrg } 975a5ae21e4Smrg elsif ( substr( $theme, 0, 1 ) eq "-" ) { 976a5ae21e4Smrg 977a5ae21e4Smrg # pop (or restore from slot, if number follows) 978a5ae21e4Smrg if ( $theme =~ /^-[0-9]$/ ) { 979a5ae21e4Smrg my $slot = substr( $theme, 1 ); 980a5ae21e4Smrg printf STDERR "%s#%dQ", $CSI, $slot + 1; 981a5ae21e4Smrg printf "\tpop %s\n", $slot if ($opt_v); 982a5ae21e4Smrg } 983a5ae21e4Smrg else { 984a5ae21e4Smrg printf STDERR "%s#Q", $CSI; 985a5ae21e4Smrg printf "\tpop\n" if ($opt_v); 986a5ae21e4Smrg } 987a5ae21e4Smrg } 988a5ae21e4Smrg elsif ( $theme eq "?" ) { 989a5ae21e4Smrg 990a5ae21e4Smrg # query TODO 991a5ae21e4Smrg printf STDERR "%s#R", $CSI; 992a5ae21e4Smrg printf "\tquery\n" if ($opt_v); 993a5ae21e4Smrg } 994a5ae21e4Smrg else { 995a5ae21e4Smrg &init_theme($theme); 996a5ae21e4Smrg &set_colors if ( $#Acolors >= 0 ); 997a5ae21e4Smrg &reset_colors unless ( $#Acolors >= 0 ); 998a5ae21e4Smrg } 999a5ae21e4Smrg &dump_colors($theme) if ($opt_d); 1000a5ae21e4Smrg} 1001a5ae21e4Smrg 1002a5ae21e4Smrgsub show_themes($) { 1003a5ae21e4Smrg my @themes = @{ $_[0] }; 1004a5ae21e4Smrg for my $n ( 0 .. $#themes ) { 1005a5ae21e4Smrg &show_colors( $themes[$n] ); 1006a5ae21e4Smrg sleep $opt_s if ( ( $n != $#themes ) and &isatty ); 1007a5ae21e4Smrg } 1008a5ae21e4Smrg} 1009a5ae21e4Smrg 1010a5ae21e4Smrgsub main::HELP_MESSAGE() { 1011a5ae21e4Smrg printf STDERR <<EOF 1012a5ae21e4SmrgUsage: $0 [options] [themes] 1013a5ae21e4Smrg 1014a5ae21e4SmrgOptions: 1015a5ae21e4Smrg -8 use 8-bit controls 1016a5ae21e4Smrg -a show all themes 1017a5ae21e4Smrg -b use BEL rather than ST for terminating strings 1018a5ae21e4Smrg -d FILE dump palette to file after setting colors 1019a5ae21e4Smrg -g ask terminal for its default background color 1020a5ae21e4Smrg -i assume terminal colors are reversed, i.e., white-on-black 1021a5ae21e4Smrg -s SECS sleep this long between changes 1022a5ae21e4Smrg -T TERM override "xterm-256color" for TPUT 1023a5ae21e4Smrg -x TPUT use TPUT program rather than hardcoded escapes 1024a5ae21e4Smrg -v verbose 1025a5ae21e4Smrg 1026a5ae21e4SmrgThemes: 1027a5ae21e4Smrg solarized default 1028a5ae21e4Smrg rezza named 1029a5ae21e4Smrg 1-25 numbered 1030a5ae21e4Smrg 0 reset 1031a5ae21e4SmrgEOF 1032a5ae21e4Smrg ; 1033a5ae21e4Smrg exit 1; 1034a5ae21e4Smrg} 1035a5ae21e4Smrg 1036a5ae21e4Smrg$Getopt::Std::STANDARD_HELP_VERSION = 1; 1037a5ae21e4Smrg&getopts('abd:gis:T:x:v8') || &main::HELP_MESSAGE; 1038a5ae21e4Smrg 1039a5ae21e4Smrg&main::HELP_MESSAGE if ( $opt_a and ( $#ARGV >= 0 ) ); 1040a5ae21e4Smrg 1041a5ae21e4Smrgif ($opt_8) { 1042a5ae21e4Smrg $CSI = "\x9b"; 1043a5ae21e4Smrg $OSC = "\x9d"; 1044a5ae21e4Smrg $ST = "\x9c"; 1045a5ae21e4Smrg} 1046a5ae21e4Smrgelse { 1047a5ae21e4Smrg $CSI = "\x1b["; 1048a5ae21e4Smrg $OSC = "\x1b]"; 1049a5ae21e4Smrg $ST = "\x1b\\"; 1050a5ae21e4Smrg} 1051a5ae21e4Smrg 1052a5ae21e4Smrg$ST = "\007" if ($opt_b); 1053a5ae21e4Smrg 1054a5ae21e4Smrg$opt_s = 1 unless ($opt_s); 1055a5ae21e4Smrg$opt_T = "-T $opt_T" if ($opt_T); 1056a5ae21e4Smrg$opt_T = "-T xterm-256color" unless ($opt_T); 1057a5ae21e4Smrg 1058a5ae21e4Smrg$DARK = 0; 1059a5ae21e4Smrg$DARK = 1 if ($opt_i); 1060a5ae21e4Smrg$DARK = &guess_dark if ($opt_g); 1061a5ae21e4Smrg 1062a5ae21e4Smrgif ($opt_a) { 1063a5ae21e4Smrg &show_themes(&all_themes); 1064a5ae21e4Smrg} 1065a5ae21e4Smrgelsif ( $#ARGV >= 0 ) { 1066a5ae21e4Smrg &show_themes( \@ARGV ); 1067a5ae21e4Smrg} 1068a5ae21e4Smrgelse { 1069a5ae21e4Smrg &show_colors("solarized"); 1070a5ae21e4Smrg} 1071a5ae21e4Smrg 1072a5ae21e4Smrg1; 1073