changed clear to make it not break on vt220

still need to add compatibility
This commit is contained in:
xereeto 2024-03-09 18:07:14 +00:00
parent a66eac7a79
commit dfecaf222d
1 changed files with 15 additions and 12 deletions

View File

@ -6,9 +6,10 @@ from getch import getch
import possible import possible
import os import os
unicode=True
if not 'xterm' in os.environ['TERM']:
unicode=False unicode=False
if 'TERM' in os.environ:
if 'xterm' in os.environ['TERM']:
unicode=True
colors =[ bg("white")+fg("black"), bg("dark_gray")+fg("white"),bg("light_yellow")+fg("dark_gray"),bg("green")+fg("white"),bg("light_gray")] colors =[ bg("white")+fg("black"), bg("dark_gray")+fg("white"),bg("light_yellow")+fg("dark_gray"),bg("green")+fg("white"),bg("light_gray")]
keycolors = [fg("white")+bg("black"), fg("dark_gray")+bg("black"),fg("light_yellow")+bg("black"),fg("green")+bg("black")] keycolors = [fg("white")+bg("black"), fg("dark_gray")+bg("black"),fg("light_yellow")+bg("black"),fg("green")+bg("black")]
@ -138,21 +139,21 @@ def putCursorInside(guess,letter):
placeCursor(col,row); placeCursor(col,row);
put(colors[0]) put(colors[0])
def blankScreen(): def blankScreen():
put(reset+'\033[2J')
placeCursor(0,0) placeCursor(0,0)
put(reset+((" "*80+"\n")*24)); put(reset+((" "*80+"\n")*24));
placeCursor(0,0) placeCursor(0,0)
def main(): def main():
cursorLocation = 0 cursorLocation = 0
print("\033c")
blankScreen() blankScreen()
if not unicode: if not unicode:
screen="\x1b[?25l"+fg('green')+''' _ _ screen=fg('green')+''' _ _
__ _____ _ __ __| | | ___ __ _____ _ __ __| | | ___
\ \ /\ / / _ \| '__/ _` | |/ _ \ \ \ /\ / / _ \| '__/ _` | |/ _ \
\ V V / (_) | | | (_| | | __/ \ V V / (_) | | | (_| | | __/
\_/\_/ \___/|_| \__,_|_|\___| ''' \_/\_/ \___/|_| \__,_|_|\___| '''
else: else:
screen="\x1b[?25l"+fg('green')+''' screen=fg('green')+'''
@ -174,11 +175,11 @@ def main():
a s d f g h j k l a s d f g h j k l
z x c v b n m z x c v b n m
---------------------------------------- ----------------------------------------
Game: XXX Game:
''' '''
put(screen)
goHome() goHome()
print(screen,end="") #print(screen,end="")
goHome() goHome()
w = Wordle() w = Wordle()
while w.turn<6 and not w.wonGame(): while w.turn<6 and not w.wonGame():
@ -247,7 +248,9 @@ try:
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
finally: finally:
print("\033cGoodbye!"+reset,end='') blankScreen()
print("Goodbye!")
#put("Goodbye!")
cliflag = sys.argv[1] if len(sys.argv) > 1 else '' cliflag = sys.argv[1] if len(sys.argv) > 1 else ''
if(w and cliflag != "--no-unicode" and unicode): if(w and cliflag != "--no-unicode" and unicode):
print("\n\nWordle "+str(w.turn)+"/6") print("\n\nWordle "+str(w.turn)+"/6")
@ -257,4 +260,4 @@ finally:
for letter in guess[0]: for letter in guess[0]:
put(blocks[letter-1]) put(blocks[letter-1])
print() print()
print("\x1b[?25h")