Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfea3d8d

Browse files
committed
simplify "bold" output - just use an upper case character, slightly change
default colours
1 parent6afbe52 commitfea3d8d

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

‎bpython/cli.py‎

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def DEBUG(s):
135135

136136

137137
defget_color(name):
138-
returncolors[OPTS.color_scheme[name]]
138+
returncolors[OPTS.color_scheme[name].lower()]
139139

140140
defget_colpair(name):
141141
returncurses.color_pair(get_color(name)+1)
@@ -1099,17 +1099,18 @@ def echo(self, s, redraw=True):
10991099

11001100
a=get_colpair('output')
11011101
if'\x01'ins:
1102-
rx=re.search('\x01([a-z])([a-z]?)',s)
1102+
rx=re.search('\x01([A-Za-z])([A-Za-z]?)',s)
11031103
ifrx:
1104-
p=self._C[rx.groups()[0]]
1105-
ifrx.groups()[1]:
1106-
p*=self._C[rx.groups()[1]]
1107-
1108-
a=curses.color_pair(int(p)+1)
1109-
s=re.sub('\x01[a-z][a-z]?','',s)
1110-
if'\x02'ins:
1111-
a=a|curses.A_BOLD
1112-
s=s.replace('\x02','')
1104+
fg=rx.groups()[0]
1105+
bg=rx.groups()[1]
1106+
col_num=self._C[fg.lower()]
1107+
ifbg:
1108+
col_num*=self._C[bg.lower()]
1109+
1110+
a=curses.color_pair(int(col_num)+1)
1111+
s=re.sub('\x01[A-Za-z][A-Za-z]?','',s)
1112+
iffg.upper():
1113+
a=a|curses.A_BOLD
11131114
s=s.replace('\x03','')
11141115
s=s.replace('\x01','')
11151116

@@ -1925,33 +1926,30 @@ def loadini(configfile):
19251926
'string':'g',
19261927
'error':'r',
19271928
'number':'g',
1928-
'operator':'c',
1929-
'punctuation':'y',
1929+
'operator':'C',
1930+
'punctuation':'c',
19301931
'token':'g',
19311932
'background':'k',
19321933
'output':'w',
19331934
'main':'c',
1934-
'prompt':'r',
1935+
'prompt':'y',
19351936
'prompt_more':'g',
19361937
}
19371938
else:
19381939
path=os.path.expanduser('~/.bpython/%s.theme'% (color_scheme_name,))
1939-
# XXX ConfigParser doesn't raise an IOError if it tries to read a file
1940-
# that doesn't exist which isn't helpful to us:
1941-
ifnotos.path.isfile(path):
1942-
raiseIOError("'%s' is not a readable file"% (path,))
1943-
load_theme(color_scheme_name)
1944-
1945-
defload_theme(name):
1946-
path=os.path.expanduser('~/.bpython/%s.theme'% (name,))
1940+
load_theme(path)
1941+
1942+
defload_theme(path):
19471943
theme=CP()
1948-
theme.read(path)
1944+
f=open(path,'r')
1945+
theme.readfp(f)
19491946
OPTS.color_scheme= {}
19501947
fork,vinchain(theme.items('syntax'),theme.items('interface')):
19511948
iftheme.has_option('syntax',k):
19521949
OPTS.color_scheme[k]=theme.get('syntax',k)
19531950
else:
19541951
OPTS.color_scheme[k]=theme.get('interface',k)
1952+
f.close()
19551953

19561954

19571955
classFakeDict(object):

‎bpython/formatter.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@
6969
Punctuation:'punctuation',
7070
Token:'token',
7171
Whitespace:'background',
72+
Parenthesis:'keyword',
7273
}
7374

74-
75+
7576
classBPythonFormatter(Formatter):
7677
"""This is the custom formatter for bpython.
7778
Its format() method receives the tokensource
@@ -89,10 +90,7 @@ class BPythonFormatter(Formatter):
8990
def__init__(self,color_scheme,**options):
9091
ifnotself.f_strings:
9192
fork,vintheme_map.iteritems():
92-
ifcolor_scheme[v].isupper():
93-
self.f_strings[k]='\x01%s\x02'% (color_scheme[v].lower(),)
94-
else:
95-
self.f_strings[k]='\x01%s'% (color_scheme[v],)
93+
self.f_strings[k]='\x01%s'% (color_scheme[v],)
9694
Formatter.__init__(self,**options)
9795

9896
defformat(self,tokensource,outfile):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp