-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Multiline render option breaks multi coloured cell data #21
Comments
Digging into this I realised it was the wrapping code that got tripped up, it doesn't know how to wrap such a string. Here: https://github.com/piotrmurach/tty-table/blob/master/lib/tty/table/operation/wrapped.rb#L37 The newline appears in the middle :) Took some digging to get there! Working around with monkey patch in my app: module Operation
class Wrapped
def call(field, row, col)
column_width = widths[col] || field.width
@pastel ||= Pastel.new
if @pastel.colored? field.content
field.content
else
Strings.wrap(field.content, column_width)
end
end
end
end Which just ignores wrapping for colourful strings. Will work up a proper patch for you, using this https://github.com/alyssais/table/blob/master/lib/ansi/string_view.rb which heroically solves the wrapping coloured text problem I avoided. Hello @alyssais 👋 |
Hey! Fwiw, it wouldn’t be possible to include that class of mine in tty-prompt as it stands, because of its licensing (it’s GPLv3). If you want to use it, I’d have to think about whether I want to relicense. (If you just want to take inspiration from it and basically use it as documentation on ANSI escape handling, but write a new thing that just solves the problem here, that’s a moot point.) |
@markpitchless Thank you for pointing out the issue! This is very helpful. As far as I'm concerned I would be keen for the bug to be addressed directly in the strings dependency and in particular the @alyssais Hello! As the author/maintainer of tty related gems I can assure you that I don't have the intention of using your gem in any of the tty gems and will not be reading or copying the source from your table gem, I'm already very happy with the |
Oh neat, I hadn’t seen the strings gem. That’s awesome! |
Spotted an odd bug trying to render multicoloured strings in a cell, tty-tables looks to be getting confused by the end and start of colour codes generated by
pastel
. Can see it most clearly in :unicode render but it also fails with :basic render.The middle one shows the problem.
multiline: true
seems to cause tty-table to splithello\e[0m\e[30;41mworld
with a newline after[30;
but (the 3rd image) it is ok withhello\e[0m \e[30;41mworld
(space between coloured bits).The text was updated successfully, but these errors were encountered: