directvt / vtm

Text-based desktop environment
MIT License
1.63k stars 43 forks source link

Maintaining the "don't wrap configuration" #574

Closed hansalemaos closed 9 months ago

hansalemaos commented 9 months ago

First, I want to thank you for your great tool. It's the only way that I found to visualize big pandas DataFrames in the Terminal.
But I have a little problem:

When I call print(df) from my Python script and run it, everything works perfectly.
But when I start working in interactive Python mode, it wraps the DataFrame every time when str or repr is called.
It is possible to unwrap it easily, but it's really a pain unwrapping big DataFrames all the time.

Here is a short video to show what I mean: https://www.youtube.com/watch?v=bf8AxbrUrEw

My question is: Is there a setting that I can change to keep the "unwrapped lines configuration", or a way to quickly unwrap a bunch of lines?

o-sdn-o commented 9 months ago

Thanks for your feedback!

By design, the text wrapping mode should be preserved, but something resets it. This is something I will investigate further. But for you now, a possible solution would be to set this mode using the vt sequence CSI [ 12 : 2 p at the beginning of the data output.

https://github.com/directvt/vtm/blob/master/doc/apps.md#runtime-configuraion-vt-sequences

Example (bash):

printf "\e[12:2pUnwrapped teeeeeeeeeeeeeeeeeeeeeeeeeext\n\e[12:1pWrapped teeeeeeeeeeeeeeeeeeeeeeeeeext.\n"
hansalemaos commented 9 months ago

Thanks for your fast feedback! I will try that in a couple of minutes and give you feedback! Keep up the great work!

o-sdn-o commented 9 months ago

Example for python:

print('\033[12:2pUnwrapped teeeeeeeeeeeeeeeext')

print('\033[12:2p'); print(df)
hansalemaos commented 9 months ago

Working!! Awesome! Now I'll find out the best way to do that automatically. Thx very much!!