Skip to content

Commit dc370be

Browse files
committed
improve interactive startup
This fixes a scrolling bug that caused some lines to be hidden from the user
1 parent d03404b commit dc370be

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

python/code/wypp/ansi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def color(s, color):
2323
return color + s + RESET
2424

2525
def green(s):
26-
return color(s, GREEN)
26+
return color(s, GREEN + BOLD)
2727

2828
def red(s):
2929
return color(s, RED + BOLD)

python/code/wypp/interactive.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@
88
from constants import *
99
from myLogging import *
1010
from exceptionHandler import handleCurrentException
11-
import i18n
12-
13-
def prepareInteractive(reset=True):
14-
print()
15-
if reset:
16-
if os.name == 'nt':
17-
# clear the terminal
18-
os.system('cls')
19-
else:
20-
# On linux & mac use ANSI Sequence for this
21-
print('\033[2J\033[H')
22-
2311

2412
HISTORY_SIZE = 1000
2513

python/code/wypp/runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def pythonVersionOk(v):
3333
import runCode
3434
import exceptionHandler
3535
import cmdlineArgs
36-
36+
import ansi
3737

3838
def printWelcomeString(file, version, doTypecheck):
3939
cwd = os.getcwd() + "/"
@@ -44,8 +44,10 @@ def printWelcomeString(file, version, doTypecheck):
4444
tycheck = ''
4545
if not doTypecheck:
4646
tycheck = ', no typechecking'
47-
printStderr(i18n.tr('=== WELCOME to ') + '"Write Your Python Program" ' +
48-
'(%sPython %s, %s%s) ===' % (versionStr, pythonVersion, file, tycheck))
47+
msg = i18n.tr('=== WELCOME to ') + '"Write Your Python Program" ' + \
48+
'(%sPython %s, %s%s) ===' % (versionStr, pythonVersion, file, tycheck)
49+
fullMsg = (10 * '\n') + ansi.green(msg) + '\n'
50+
printStderr(fullMsg)
4951

5052
def main(globals, argList=None):
5153
(args, restArgs) = cmdlineArgs.parseCmdlineArgs(argList)
@@ -70,8 +72,6 @@ def main(globals, argList=None):
7072

7173
isInteractive = args.interactive
7274
version = versionMod.readVersion()
73-
if isInteractive:
74-
interactive.prepareInteractive(reset=not args.noClear)
7575

7676
if fileToRun is None:
7777
return

0 commit comments

Comments
 (0)