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

Add support for the linewrap escape sequence #228

Open
SystematicError opened this issue Nov 25, 2021 · 6 comments
Open

Add support for the linewrap escape sequence #228

SystematicError opened this issue Nov 25, 2021 · 6 comments

Comments

@SystematicError
Copy link

Hello, I've been using this library for a project and its amazing, one thing I felt was missing was the ability to enable or disable auto linewrap (documentation here). This is particularly useful as if by chance any text were to overflow, it won't interfere with any other lines.

For example, this is how its done in bash or any other shell scripts:

# Disabling line wrapping.
printf '\e[?7l'

# Enabling line wrapping.
printf '\e[?7h'

Once added, this feature could possibly be used like this:

with term.no_wrap():
    print("Hello World!")
@jquast
Copy link
Owner

jquast commented Nov 25, 2021

I would gladly accept a PR of the suggested design into next release, be sure to use rmam and smam terminal capabilities

Thank you!

@SystematicError
Copy link
Author

Thanks for the response, I've only scoured through the code for a couple minutes so I've only got a very loose understanding of this. I am currently working on some other stuff, so I'd try forking and submitting a PR when I'm free :)

@SystematicError
Copy link
Author

SystematicError commented Nov 26, 2021

image
I had a bit of free time and decided to quickly clone the repo to try understand how it works. I got this sorta working by adding rmam and smam to the dictionary _sugar and adding a context manager. It seems to work fine, however it seems to be truncating the line one character too long. I'll see if there's any fix to this.

@SystematicError
Copy link
Author

image
I tested across a different terminal just to verify whether it was my fault or not, the same issue still occurs.

@SystematicError
Copy link
Author

image
Weirdly this isn't happening when doing this from the terminal directly

@avylove
Copy link
Collaborator

avylove commented Nov 26, 2021

I think we'd need to see what you implemented in order to assist. My guess is it's something in your context manager as I can do this with the current release.

>>> print(term.rmam + '123456789|' * 10 )
123456789|123456789|123456789|123456789|123456789|123456789|123456789|123456789|
>>> print(term.smam + '123456789|' * 10 )
123456789|123456789|123456789|123456789|123456789|123456789|123456789|123456789|123456789|123456789|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants