jquast / blessed

Blessed is an easy, practical library for making python terminal apps

Home Page:http://pypi.python.org/pypi/blessed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Behaves very differently in Windows as in Linux. Even differs based on terminal in windows

GNUGradyn opened this issue · comments

Hello, I am trying to write a prompt that sticks to the bottom of the page. I don't have it quite working yet but the main concern right now is it behaves completely differently on Windows then it does on Linux. Here is my code

from blessed import Terminal
import time

print("pre-init")
term = Terminal()
print("post-init")

line = term.get_location(timeout=5)[0]

print(term.move_xy(0, term.height), end="")
while True:
        time.sleep(0.2)
        with term.location(0, line):
                print("DATA TIIIIIME")
                line+=1

Here it is on Linux (I'm aware of the issue when the data reaches the bottom, thats an unrelated error with my code). This is how I expect it to behave.

2021-06-30.19-53-06.mp4

Here it is on Windows in cmd. also behaves like this on powershell. Note I am spamming my keyboard as fast as I can from the moment the data starts flowing. This is not how I expect it to behave.

2021-07-01.20-12-04.mp4

And then with Git Bash on windows we get something in between! This makes a little more sense but is still not how I expect it to behave

2021-07-01.20-21-58.mp4

Whats going on here? Am I missing something or is this a library issue?

I think this is more to do with how input buffering is handled in the different terminals. Notice you'd get similar behavior if you just did this.

import time

while True:
    print('HELLO')
    time.sleep(0.2)

To get the behavior you're looking for, you'll probably need to capture the input with Terminal.cbreak() or Terminal.raw() and output it to the terminal where you want it.

Thanks. This makes sense for cmd and powershell, but git bash still does not seem to be functioning properly. In fact it doesn't seem to be able to move the cursor at all.

It does move the cursor in my testing with git bash and it did in the screen recording you provided earlier. If you have some other code, I can try it on my side.