From e91ae2bddafa0301e4a6265505ac14875e79d2c8 Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Thu, 15 Jul 2021 13:18:39 +0200 Subject: Move example_escs.py to contrib/ --- contrib/example_escs.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ example_escs.py | 107 ------------------------------------------------ 2 files changed, 107 insertions(+), 107 deletions(-) create mode 100755 contrib/example_escs.py delete mode 100755 example_escs.py diff --git a/contrib/example_escs.py b/contrib/example_escs.py new file mode 100755 index 0000000..1d8ced6 --- /dev/null +++ b/contrib/example_escs.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +def sgr(*args): + return '\033[' + ';'.join(map(str,args)) + 'm' + +def sgr_extended(*args): + return '\033[' + ':'.join(map(str,args)) + 'm' + +def print_heading(t): + print('\n{}{}{}\n'.format(sgr(1,4), t, sgr())) + +print_heading('text style') + +print('{}bold{}'.format(sgr(1), sgr(22))) +print('{}faint{}'.format(sgr(2), sgr(22))) +print('{}italic{}'.format(sgr(3), sgr(23))) +print('{}underline{}'.format(sgr(4), sgr(24))) +print('the following is concealed: {}invisible{}'.format(sgr(8), sgr(28))) +print('{}strikethrough{}'.format(sgr(9), sgr(29))) +print('{}double underline{}'.format(sgr(21), sgr(24))) + +for s in [30,90,40,100]: + print_heading( + '16 color {}{}'.format( + 'bright ' if s > 50 else '', + 'foreground' if s % 3 == 0 else 'background', + ) + ) + + for c in range(8): + print( + '{}|{:2}{}'.format( + sgr(s + c), + c, + sgr() + ), + end='' + ) + + print('') + +for s in [38, 48]: + section = 'foreground' if s == 38 else 'background' + + print_heading( + '16 color {}'.format(section) + ) + + for y in range(2): + for x in range(8): + c = x + y * 8 + print( + '{}|{:>2}{}'.format( + sgr_extended(s, 5, c), + c, + sgr(s + 1) + ), + end='' + ) + + print('') + + print_heading('6 * 6 * 6 cube color {}'.format(section)) + + for y in range(6): + for x in range(36): + c = 16 + x + y * 36 + print( + '{}|{:>3}{}'.format( + sgr_extended(s, 5, c), + c, + sgr(s + 1) + ), + end='' + ) + print('') + + print_heading('grayscale {}'.format(section)) + + for c in range(232, 256): + print( + '{}|{:>3}{}'.format( + sgr_extended(s, 5, c), + c, + sgr(s + 1) + ), + end='' + ) + print('') + + +print_heading('16 color combinations') + +print(' |' + '|'.join(map(lambda x: '{:<4}'.format(x), range(16)))) +for f in range(16): + print(f'{f:>2}', end='') + + for b in range(16): + print( + '{}{}|test{}'.format( + sgr_extended(38, 5, f), + sgr_extended(48, 5, b), + sgr(39, 49) + ), + end='' + ) + print('') diff --git a/example_escs.py b/example_escs.py deleted file mode 100755 index 1d8ced6..0000000 --- a/example_escs.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python3 - -def sgr(*args): - return '\033[' + ';'.join(map(str,args)) + 'm' - -def sgr_extended(*args): - return '\033[' + ':'.join(map(str,args)) + 'm' - -def print_heading(t): - print('\n{}{}{}\n'.format(sgr(1,4), t, sgr())) - -print_heading('text style') - -print('{}bold{}'.format(sgr(1), sgr(22))) -print('{}faint{}'.format(sgr(2), sgr(22))) -print('{}italic{}'.format(sgr(3), sgr(23))) -print('{}underline{}'.format(sgr(4), sgr(24))) -print('the following is concealed: {}invisible{}'.format(sgr(8), sgr(28))) -print('{}strikethrough{}'.format(sgr(9), sgr(29))) -print('{}double underline{}'.format(sgr(21), sgr(24))) - -for s in [30,90,40,100]: - print_heading( - '16 color {}{}'.format( - 'bright ' if s > 50 else '', - 'foreground' if s % 3 == 0 else 'background', - ) - ) - - for c in range(8): - print( - '{}|{:2}{}'.format( - sgr(s + c), - c, - sgr() - ), - end='' - ) - - print('') - -for s in [38, 48]: - section = 'foreground' if s == 38 else 'background' - - print_heading( - '16 color {}'.format(section) - ) - - for y in range(2): - for x in range(8): - c = x + y * 8 - print( - '{}|{:>2}{}'.format( - sgr_extended(s, 5, c), - c, - sgr(s + 1) - ), - end='' - ) - - print('') - - print_heading('6 * 6 * 6 cube color {}'.format(section)) - - for y in range(6): - for x in range(36): - c = 16 + x + y * 36 - print( - '{}|{:>3}{}'.format( - sgr_extended(s, 5, c), - c, - sgr(s + 1) - ), - end='' - ) - print('') - - print_heading('grayscale {}'.format(section)) - - for c in range(232, 256): - print( - '{}|{:>3}{}'.format( - sgr_extended(s, 5, c), - c, - sgr(s + 1) - ), - end='' - ) - print('') - - -print_heading('16 color combinations') - -print(' |' + '|'.join(map(lambda x: '{:<4}'.format(x), range(16)))) -for f in range(16): - print(f'{f:>2}', end='') - - for b in range(16): - print( - '{}{}|test{}'.format( - sgr_extended(38, 5, f), - sgr_extended(48, 5, b), - sgr(39, 49) - ), - end='' - ) - print('') -- cgit 1.4.1