Skip to content
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

[Question] Paste text contents into LineEdit does not perform well #118

Closed
NickyXu1989 opened this issue Feb 21, 2023 · 2 comments · Fixed by #119
Closed

[Question] Paste text contents into LineEdit does not perform well #118

NickyXu1989 opened this issue Feb 21, 2023 · 2 comments · Fixed by #119
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@NickyXu1989
Copy link

When I tried to paste something into widget Line Edit using [ctrl] + [insert], the widget didnot show all the contents.
I digged into this situation and find that it is possibly because of this file [TermTk/TTkCore/TTkTerm/readinputlinux.py].
I tried to fix this problem by changing some of the code as below:

`

class ReadInput():
    __slots__ = ('_readPipe','_attr', '_closeFlag')

    def __init__(self):
        self._readPipe = os.pipe()
        self._attr = termios.tcgetattr(sys.stdin)
        tty.setcbreak(sys.stdin)
        self._closeFlag = False

    def close(self):
        termios.tcsetattr(sys.stdin, termios.TCSANOW, self._attr)
        # os.write(self._readPipe[1], b'quit')
        os.write(self._readPipe[1], b'quit')
        self._closeFlag = True

    def cont(self):
        tty.setcbreak(sys.stdin)

    def read(self):

        while sys.stdin.readable() and self._closeFlag == False:
            stdinRead = sys.stdin.read(1)
            if self._closeFlag == True:
                break

            if stdinRead == "\033":
                _fl = fcntl.fcntl(sys.stdin, fcntl.F_GETFL)
                fcntl.fcntl(sys.stdin, fcntl.F_SETFL, _fl | os.O_NONBLOCK) # Set the input as NONBLOCK to read the full sequence
                stdinRead += sys.stdin.read(20)       # Check if the stream start with an escape sequence
                if stdinRead.startswith("\033[<"):    # Clear the buffer if this is a mouse code
                    sys.stdin.read(0x40)
                fcntl.fcntl(sys.stdin, fcntl.F_SETFL, _fl)
           
            return stdinRead

`
Hope that will work.

@ceccopierangiolieugenio
Copy link
Owner

ceccopierangiolieugenio commented Feb 21, 2023

Yes this is a feature I haven't properly implemented,
my input routine need definitely some tweaking,
the reason I use a select is to not make it blocking so I can close it through the readpipe.
I'll try to fix it as soon as I can,
thanks

@ceccopierangiolieugenio ceccopierangiolieugenio added bug Something isn't working enhancement New feature or request labels Feb 21, 2023
@ceccopierangiolieugenio ceccopierangiolieugenio linked a pull request Feb 21, 2023 that will close this issue
ceccopierangiolieugenio added a commit that referenced this issue Feb 21, 2023
@ceccopierangiolieugenio
Copy link
Owner

fix deployed in v0.22.0a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants