PaPYrus 10-06-2015, 04:43 PM
#1
Seeing as I run winblows, my vanilla command line doesn't have the capability to use multiple colors. Naturally, I decided to fuck with it.
Commands:
Just a quick note: I included some exit handling, so you don't need to reset at the end of your file (be sure to set your DEFAULT, speaking of).
Source:
Example usage:
Screenshot:
![[Image: xVbrfnN.png]](http://i.imgur.com/xVbrfnN.png)
End notes:
Commands:
Code:
papyrus.color(c) - Changes the display color for the outputted code
papyrus.reset() - Resets the color to 'DEFAULT'Source:
Spoiler: 1.3.2
Code:
import ctypes
import struct
import atexit
#Set DEFAULT to your default commandline color (WHITE is default)
DEFAULT="WHITE"
STD_OUTPUT_HANDLE=-11
colors={"BLACK": 0x0000,
"BLUE": 0x0001,
"GREEN": 0x0002,
"AQUA": 0x0003,
"RED": 0x0004,
"PURPLE": 0x0005,
"GOLD": 0x0006,
"L_GRAY": 0x0007,
"GRAY": 0x0008,
"L_BLUE": 0x0009,
"LIME": 0x000a,
"L_AQUA": 0x000b,
"L_RED": 0x000c,
"PINK": 0x000d,
"YELLOW": 0x000e,
"WHITE": 0x000f}
def get_csbi_attributes(handle):
csbi=ctypes.create_string_buffer(22)
res=ctypes.windll.kernel32.GetConsoleScreenBufferInfo(handle,csbi)
assert res
def set_attr(a,b):
ctypes.windll.kernel32.SetConsoleTextAttribute(a,b)
handle=ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
reset=get_csbi_attributes(handle)
def color(c):
set_attr(handle, colors[c.upper()])
def reset():
set_attr(handle, colors[DEFAULT])
atexit.register(reset)Spoiler: 1.3.8
- Got rid of a bunch of useless shit that was needed in earlier versions, forgot to remove it before posting.
- Made some stuff private
- Made some stuff private
Code:
from ctypes import windll
from atexit import register
#Set DEFAULT to your default commandline color (WHITE is default)
DEFAULT="WHITE"
__STD_OUTPUT_HANDLE=-11
__HANDLE=windll.kernel32.GetStdHandle(__STD_OUTPUT_HANDLE)
__COLORS={"BLACK": 0x0000,
"BLUE": 0x0001,
"GREEN": 0x0002,
"AQUA": 0x0003,
"RED": 0x0004,
"PURPLE": 0x0005,
"GOLD": 0x0006,
"L_GRAY": 0x0007,
"GRAY": 0x0008,
"L_BLUE": 0x0009,
"LIME": 0x000a,
"L_AQUA": 0x000b,
"L_RED": 0x000c,
"PINK": 0x000d,
"YELLOW": 0x000e,
"WHITE": 0x000f}
#actually changes the color
def __set(a,b):
windll.kernel32.SetConsoleTextAttribute(a,b)
#publically called methods, both refer to __set
def color(c):
__set(__HANDLE,__COLORS[c.upper()])
def reset():
__set(__HANDLE,__COLORS[DEFAULT])
register(reset)Example usage:
Code:
from papyrus import *
color('lime') #case is ignored
print "Hello, world!"
print "Hello, world!".format(color('purple')Screenshot:
![[Image: xVbrfnN.png]](http://i.imgur.com/xVbrfnN.png)
End notes:
- While PaPYrus is cross-platform, I don't see why you would use it on Linux
I'm retarded. It's windows only.
- I was too lazy to upload the .pyc, but it'll be compiled when you import PaPYrus to any of your programs.
- Not all of this is my code. I got some help from StackOverflow, but most of it is from scratch.
- If anyone can find some cool tricks that I haven't discovered, let me know.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.















![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
