-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiletp_color.py
161 lines (153 loc) Β· 3.15 KB
/
filetp_color.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import builtins
from filetp.filetp import *
import rich
from rich.console import *
from rich.syntax import *
from rich.highlighter import *
from rich.progress import *
import rich.text
co.init(co.COMODE_LINUX)
def printcolor(num,string,bold=False,highlight=False,end="\n",flush=False,file=sys.stdout):
co.initdt[1](num,string,bold,highlight,end,flush,file)
resetcolor()
def resetcolor():
co.initdt[2]()
colors=co.colors
console = rich.get_console()
def printcode(code:str,stype:str):
syntax = Syntax(code, stype, theme="monokai", line_numbers=True)
console.print(syntax)
#ext
class ConvDict(dict):
default=None
def __getitem__(self, __key):
return self.get(__key,self.default)
ext2lang=ConvDict({
#Python
"py":"python",
"rpy":"python",
"pyw":"python",
"cpy":"python",
"gyp":"python",
"gypi":"python",
"pyi":"python",
"ipy":"python",
"pyt":"python",
"spec":"python",#pyinstaller
#Java
"java":"java",
"class":"java",
"jav":"java",
#C++
"cpp":"c++",
"cc":"c++",
"cxx":"c++",
"c++":"c++",
"hpp":"c++",
"hh":"c++",
"hxx":"c++",
"h":"c++",
"ii":"c++",
#C
"c":"c",
"i":"c",
#C#
"cs":"cs",
"csx":"cs",
"cake":"cs",
#XML
"xml":"xml",
"xsd":"xml",
"ascx":"xml",
"atom":"xml",
"axml":"xml",
"axaml":"xml",
"bpmn":"xml",
"cpt":"xml",
"csl":"xml",
"csproj":"xml",
"cppproj":"xml",
"pyproj":"xml",
"ui":"xml",#Qt
#HTML
"html":"html",
"htm":"html",
"shtml":"html",
"xhtml":"html",
"xht":"html",
"mdoc":"html",
"jsp":"html",
"jshtm":"html",
"asp":"html",
"aspx":"html",
#CSS
"css":"css",
#Javascript
"js":"js",
"es6":"js",
"mjs":"js",
"cjs":"js",
"pac":"js",
#PHP
"php":"php",
"php4":"php",
"php5":"php",
"phtml":"php",
"ctp":"php",
#Batch
"bat":"batch",
"cmd":"batch",
#sh
"sh":"sh",
"bash":"sh",
"bashrc":"sh",
"bash_aliases":"sh",
"bash_profile":"sh",
"bash_login":"sh",
"ebuild":"sh",
"profile":"sh",
"bash_logout":"sh",
"xprofile":"sh",
#VB
"vb":"vb",
"brs":"vb",
"bas":"vb",
"vba":"vb",
#VBS
"vbs":"vbs",
#text
"txt":"text",
"text":"text",
#vim
"vim":"vim"
})
ext2lang.default="auto"
'''
'''
lang2icon=ConvDict({
"python":"π",
"java":"β",
"text":"π",
"dir":"π",
"markdown":"π"
})
lang2icon.default="π"
#fix open
richopen=open
open=builtins.open
try:
with open(config.get("langpack",os.devnull),"r",encoding="utf-8") as f:
for i in f:
i=i.strip()
if(i.startswith("#") or i==""):
continue
try:
k,v=i.split("=")
k=k.strip()
v=v.strip()
#exec("strings.%s=%s"%(k,v))
lang2icon[k]=v
except Exception as e:
pass
except Exception as e:
pass