Created
March 25, 2014 08:46
-
-
Save tywtyw2002/9757514 to your computer and use it in GitHub Desktop.
termcount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: | |
# work with python 2.7 | |
import curses | |
import time | |
import sys | |
color = 2 | |
space = '\x1b[48;5;%dm \x1b[0m' % color | |
i2b = {'1': 0x108421, '2':0x1f0fe1f, '3':0x1f0fc3f, '4':0x118fc21, | |
'5':0x1f87c3f, '6':0x1f87e3f, '7':0x1f08421, '8':0x1f8fe3f, '9':0x1f8fc3f, | |
'0':0x1f8c63f} | |
def num(x): | |
bits = i2b[x] | |
output = [] | |
for i in range(5): | |
r = bits >> (20 - i * 5) & 0x1f | |
o = "" | |
for i in range(5): | |
g = r >> (4 - i) & 0x1 | |
if g: | |
o+=space | |
else: | |
o+=" " | |
output.append(o) | |
return output | |
def do_print(str): | |
out = [] | |
for i in str: | |
out.append(num(i)) | |
for i in range(5): | |
for j in range(len(str)): | |
print out[j][i], " ", | |
print "\r\n", | |
def main(): | |
stdscr = curses.initscr() | |
for i in range(10): | |
do_print(str(i)) | |
sys.stdout.flush() | |
time.sleep(1) | |
stdscr.clear() | |
stdscr.refresh() | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment