-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctrl+v paste does not copy text correctly in linux(wsl) #95
Comments
On first read this sounds related to #73 (comment). Readchar can only guarantee character recognition inside its own function and behaviour outside of them is not defined. So for your example, the first character will be read and returned by readchar, but its not clear what will happen to the rest of the input during the printing and flushing code... Readchar is currently not really ready to handle input streams, only human input which is guaranteed to be slow enough. I am working on this on the context-mamager branch, which would allow for exacly this kind of behaviour, but this faces its own issue currently. |
Understandable, can you put this feature in your list of functionality of your progress. And close this afterwards |
Anyways... Have you tried to use the terminal functionality, by pressing |
this should be solved as soon as the feature is merged, but I currently cant get it to work consistently in all cases 😢 you can however install the developent version in your enviroment and test if it allready solves your usecase. simply run: pip install git+https://github.com/magmax/python-readchar@contexmanager |
I removed the old install and installed from the contextmanager and no change happened bug still exists, import os
import time
import fcntl
import termios
class NonBlockingInput(object):
def __enter__(self):
# canonical mode, no echo
self.old = termios.tcgetattr(sys.stdin)
new = termios.tcgetattr(sys.stdin)
new[3] = new[3] & ~(termios.ICANON | termios.ECHO)
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new)
# set for non-blocking io
# orig_fl = fcntl.fcntl(sys.stdin, fcntl.F_GETFL)
# fcntl.fcntl(sys.stdin, fcntl.F_SETFL, orig_fl | os.O_NONBLOCK)
def __exit__(self, *args):
# restore terminal to previous state
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.old)
with NonBlockingInput():
while True:
sys.stdout.write(sys.stdin.read(1))
sys.stdout.flush() it would be nice to have this non-blocking input added as an activated functionality with a function call for example to activate it and another to deactivate. or just simply by using with keyword |
looking into the pr it seems you added a class "Readchar" that has that code but can't use it in import because it is not exported in import sys
from readchar import ReadChar
reader = ReadChar()
with reader:
while True:
sys.stdout.write(reader.char())
sys.stdout.flush() |
Yea its not jet externalised and you have to import it directly from the submodules, But good to know that it allready fixes your issue |
Take this sample
if I copy the text
ClientMessage.to_server
and paste it into the program terminal in linux(wsl) I would get unordered charactersor missing characters like this
ClientMto_seerrv
on windows cmd it works fine
The text was updated successfully, but these errors were encountered: