aboutsummaryrefslogtreecommitdiffstats
path: root/bin/colo
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbin/colo136
-rwxr-xr-xbin/color6
-rwxr-xr-xbin/colormake40
3 files changed, 182 insertions, 0 deletions
diff --git a/bin/colo b/bin/colo
new file mode 100755
index 0000000..ac2818d
--- /dev/null
+++ b/bin/colo
@@ -0,0 +1,136 @@
+#!/usr/bin/env python3
+# _*_ coding=utf-8 _*_
+
+import argparse
+import code
+import os
+import signal
+import sys
+from html.parser import HTMLParser
+
+
+# BASH_STR = 'printf "\x1b[38;5;XXXmcolourXXX YYY \x1b[0m\t";'
+BASH_STR = '\x1b[38;5;XXXmcolourXXX YYY \x1b[0m\t'
+BASH_ANSI_STR = '\\x1b[38;5;XXXm'
+COLO_LIST = []
+LJUST_CONST = 4
+
+
+def SigHandler_SIGINT(signum, frame):
+ print()
+ sys.exit(0)
+
+
+class Argparser(object):
+ def __init__(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--ansi", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--hsi", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--rgb", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--number", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--name", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--hex", action="store_true",
+ help="bool", default=False)
+ parser.add_argument("--dbg", action="store_true",
+ help="debug", default=False)
+ self.args = parser.parse_args()
+
+
+class ColoParser(HTMLParser):
+ def handle_data(self, data):
+ if data == "\n":
+ pass
+ else:
+ COLO_LIST.append(data)
+
+
+def premain(argparser):
+ signal.signal(signal.SIGINT, SigHandler_SIGINT)
+ # here
+ PRINT_LIST = str()
+ with open(os.path.dirname(sys.argv[0])+"/index.html", "r") as colo:
+ lines = colo.readlines()
+ for line in lines:
+ parser = ColoParser()
+ parser.feed(line)
+ NUMBER_COLO_LIST = [COLO_LIST[j]
+ for j in range(0, len(COLO_LIST)) if ((j+1) % 5) == 1]
+
+ if argparser.args.hsi:
+ HSL_COLO_LIST = [COLO_LIST[j]
+ for j in range(0, len(COLO_LIST)) if ((j+1) % 5) == 0]
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 6 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", HSL_COLO_LIST[i])
+ elif argparser.args.rgb:
+ RGB_COLO_LIST = [COLO_LIST[j]
+ for j in range(0, len(COLO_LIST)) if ((j+1) % 5) == 4]
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 6 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", RGB_COLO_LIST[i])
+ elif argparser.args.number:
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 12 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", NUMBER_COLO_LIST[i])
+ elif argparser.args.name:
+ NAME_COLO_LIST = [COLO_LIST[j]
+ for j in range(0, len(COLO_LIST)) if ((j+1) % 5) == 2]
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 6 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", NAME_COLO_LIST[i])
+ elif argparser.args.hex:
+ HEX_COLO_LIST = [COLO_LIST[j]
+ for j in range(0, len(COLO_LIST)) if ((j+1) % 5) == 3]
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 8 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", HEX_COLO_LIST[i])
+ elif argparser.args.ansi:
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 6 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", BASH_ANSI_STR.replace("XXX", NUMBER_COLO_LIST[i]))
+ else:
+ for i in range(0, len(NUMBER_COLO_LIST)):
+ if i % 12 == 0 and i != 0:
+ PRINT_LIST += "\n"
+ PRINT_LIST += BASH_STR.replace("XXX", NUMBER_COLO_LIST[i]).replace(
+ "YYY", NUMBER_COLO_LIST[i])
+ print(PRINT_LIST)
+
+
+def main():
+ argparser = Argparser()
+ if argparser.args.dbg:
+ try:
+ premain(argparser)
+ except Exception as e:
+ if hasattr(e, "__doc__"):
+ print(e.__doc__)
+ if hasattr(e, "message"):
+ print(e.message)
+ variables = globals().copy()
+ variables.update(locals())
+ shell = code.InteractiveConsole(variables)
+ shell.interact(banner="DEBUG REPL")
+ else:
+ premain(argparser)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/bin/color b/bin/color
new file mode 100755
index 0000000..d96fde3
--- /dev/null
+++ b/bin/color
@@ -0,0 +1,6 @@
+#!/bin/sh
+for i in {0..255};do
+ if (( i % 12 == 0 )); then echo;fi
+ printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\t"
+done
+echo
diff --git a/bin/colormake b/bin/colormake
new file mode 100755
index 0000000..c8f352d
--- /dev/null
+++ b/bin/colormake
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Colored Make 2016.1.21
+# Copyright (c) 2014 Renato Silva
+# Licensed under BSD
+# https://github.com/renatosilva/colormake
+
+# Enable 256 colors for MinTTY in MSYS2
+if [[ "$MSYSCON" = mintty* && "$TERM" = *256color* ]]; then
+ red="\e[38;05;9m"
+ green="\e[38;05;76m"
+ blue="\e[38;05;74m"
+ cyan="\e[0;36m"
+ purple="\e[38;05;165m"
+ yellow="\e[0;33m"
+ gray="\e[38;05;244m"
+else
+ red="\e[1;31m"
+ green="\e[1;32m"
+ blue="\e[1;34m"
+ cyan="\e[1;36m"
+ purple="\e[1;35m"
+ yellow="\e[1;33m"
+ gray="\e[1;30m"
+fi
+normal="\e[0m"
+
+# Errors, warnings, notes and compiler recipes
+error="s/(^error|^.*[^a-z]error:)/$(printf $red)\\1$(printf $normal)/i"
+warning="s/(^warning|^.*[^a-z]warning:)/$(printf $yellow)\\1$(printf $normal)/i"
+make="s/^make(\[[0-9]+\])?:/$(printf $blue)make\\1:$(printf $normal)/"
+compiler_recipe="s/^((gcc|g\+\+|clang)(.exe)? .*)/$(printf $gray)\\1$(printf $normal)/"
+
+if [[ $(uname -or) != 1.*Msys ]]; then
+ command "${COLORMAKE_COMMAND:-make}" "$@" 2> >(sed -ru -e "$warning" -e "$error" -e "$make" -e "$compiler_recipe") \
+ > >(sed -ru -e "$warning" -e "$error" -e "$make" -e "$compiler_recipe")
+else
+ # MinGW MSYS does not support process substitution
+ command "${COLORMAKE_COMMAND:-make}" "$@" 2>&1 | sed -ru -e "$warning" -e "$error" -e "$make" -e "$compiler_recipe"
+fi