Add support for the linewrap escape sequence
SystematicError opened this issue · comments
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!")
I would gladly accept a PR of the suggested design into next release, be sure to use rmam and smam terminal capabilities
Thank you!
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 :)
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.
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|