Skip to content

Commit e55cfef

Browse files
committed
Reset terminal cursor position to home on quit.
1 parent c2d01d2 commit e55cfef

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def main():
6565
except KeyboardInterrupt: pass # catch Ctrl+C
6666
finally:
6767
if os.name == 'posix': termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldsettings)
68-
print('\x1b[0m\x1b[2J\x1b[?25h') # reset terminal and show cursor
68+
print('\x1b[0m\x1b[2J\x1b[H\x1b[?25h') # reset terminal and show cursor
6969

7070
if __name__ == '__main__':
7171
main() # by Nik

matrix2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def main():
8181
except KeyboardInterrupt: pass # catch Ctrl+C
8282
finally: # ensures these run even if program is interrupted, so terminal functions properly on exit
8383
if os.name == 'posix': termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldsettings) # restore terminal settings
84-
print('\x1b[0m\x1b[2J\x1b[?25h') # reset terminal and show cursor
84+
print('\x1b[0m\x1b[2J\x1b[H\x1b[?25h') # reset terminal and show cursor
8585

8686
if __name__ == '__main__':
8787
main() # by Nik

0 commit comments

Comments
 (0)