Open gatoruss opened 4 years ago
I'm also seeing this issue running Debian WSL with Windows 10.0.17763. For now I'm getting around it with the "clear -x" hack by adding alias clear='clear -x'
to my .profile
but for the reasons you give above this isn't ideal.
I had meant to update my original post, but have been slammed on other matters. However, the subclass approach I described in my OP works so that Screen.clear() uses "clear -x" rather than "clear" -- embarrassingly, the error messages I described in my OP were the result of a typo :-(
A noted, "clear -x" does not clear the scroll buffer, but at least the menu is within the viewport.
` class MyScreen(Screen): @staticmethod def clear(): if platform.system() == 'Windows': subprocess.check_call('cls', shell=True) else: print(subprocess.check_output('clear -x', shell=True).decode())
myscreen = MyScreen() ` Then pass myscreen to MenuConsole (or the applicable menu object).
I am running Debian 10 thru WSL on a Windows 10 machine.
There seems to be a WSL bug that affects the "clear" shell command. Specifically, after executing the "clear" command the scroll buffer is erased (as expected) but the top left corner of the viewport is several lines below cursor (which is not in the viewpoint), proportional to the number of lines that were erased from scrollback. See this link --> WSL "clear" bug
So, after console menu "shows" a clears the screen, the menu is displayed outside of viewport -- you need to scroll up to see menu.
However, if you run the command "clear -x", the screen is scrolled up so that cursor is lined up with the top of the viewport; but the scroll buffer is not erased. While this is not ideal (as I would like scroll buffer erased), at least the cursor is in the viewport without scrolling up.
I can achieve this result with console menu if I edit the clear() method in screen.py so that the last line read as follows:
print(subprocess.check_output('clear -x', shell=True).decode())
However, I would like to achieve this result by sub-classing Screen. I have attempted the following:
@staticmethod def clear(): """ Clear the screen. """ if platform.system() == 'Windows': subprocess.check_call('cls', shell=True) else: print(subprocess.check_output('clear -x', shell=True).decode())
but I keep getting either (i) a command not found error (if I include "@staticmethod" in subclass as above); or (ii) an AttributeError : 0 parameters expected but 1 given (if I omit "@staticmethod" in the subclass).
How can I subclass Screen to change screen.clear() so that "clear -x" rather than "clear" isezexted by screen.clear?