Skip to content

Commit 313d4d1

Browse files
committed
Merge in Anatoly's changes.
2 parents 7712f2d + e17955e commit 313d4d1

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

bpython/cli.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
# The MIT License
32
#
43
# Copyright (c) 2008 Bob Farrell
4+
# Copyright (c) bpython authors
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -40,7 +40,7 @@
4040
import locale
4141
from types import ModuleType
4242

43-
# These are used for syntax hilighting.
43+
# These are used for syntax highlighting
4444
from pygments import format
4545
from pygments.formatters import TerminalFormatter
4646
from pygments.lexers import PythonLexer
@@ -68,7 +68,13 @@
6868
if not py3:
6969
import inspect
7070

71+
72+
# --- module globals ---
7173
stdscr = None
74+
colors = None
75+
76+
DO_RESIZE = False
77+
# ---
7278

7379
def getpreferredencoding():
7480
return locale.getpreferredencoding() or sys.getdefaultencoding()
@@ -180,8 +186,6 @@ def read(self, size=None):
180186
def readlines(self, size=-1):
181187
return list(iter(self.readline, ''))
182188

183-
DO_RESIZE = False
184-
185189
# TODO:
186190
#
187191
# Tab completion does not work if not at the end of the line.
@@ -197,6 +201,7 @@ def readlines(self, size=-1):
197201

198202

199203
def get_color(config, name):
204+
global colors
200205
return colors[config.color_scheme[name].lower()]
201206

202207

@@ -1282,6 +1287,7 @@ def lsize():
12821287
def size(self):
12831288
"""Set instance attributes for x and y top left corner coordinates
12841289
and width and heigth for the window."""
1290+
global stdscr
12851291
h, w = stdscr.getmaxyx()
12861292
self.y = 0
12871293
self.w = w
@@ -1521,7 +1527,7 @@ def clear(self):
15211527
self.win.clear()
15221528

15231529

1524-
def init_wins(scr, colors, config):
1530+
def init_wins(scr, config):
15251531
"""Initialise the two windows (the main repl interface and the little
15261532
status bar at the bottom with some stuff in it)"""
15271533
#TODO: Document better what stuff is on the status bar.
@@ -1581,6 +1587,7 @@ def idle(caller):
15811587
The statusbar check needs to go here to take care of timed
15821588
messages and the resize handlers need to be here to make
15831589
sure it happens conveniently."""
1590+
global DO_RESIZE
15841591

15851592
if importcompletion.find_coroutine() or caller.paste_mode:
15861593
caller.scr.nodelay(True)
@@ -1670,7 +1677,6 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
16701677
global stdscr
16711678
global DO_RESIZE
16721679
global colors
1673-
global repl
16741680
DO_RESIZE = False
16751681

16761682
old_sigwinch_handler = signal.signal(signal.SIGWINCH,
@@ -1692,7 +1698,7 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
16921698
scr.timeout(300)
16931699

16941700
curses.raw(True)
1695-
main_win, statusbar = init_wins(scr, cols, config)
1701+
main_win, statusbar = init_wins(scr, config)
16961702

16971703
if locals_ is None:
16981704
sys.modules['__main__'] = ModuleType('__main__')
@@ -1734,8 +1740,6 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
17341740

17351741

17361742
def main(args=None, locals_=None, banner=None):
1737-
global stdscr
1738-
17391743
locale.setlocale(locale.LC_ALL, "")
17401744
translations.init()
17411745

0 commit comments

Comments
 (0)