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
Support text wrapping and added correct splitting of strings containing ANSI style codes #36
Conversation
@@ -60,6 +63,45 @@ const getBorderChars = borderStyle => { | |||
return chars; | |||
}; | |||
|
|||
const splitAnsiCorrectly = text => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "correctly"? Why cannot wrap-ansi
be used directly?
for (const len of lineLengths) { | ||
t.is(len, process.stdout.columns); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this feature needs a lot more tests. It's a difficult feature with a lot of potential issues.
I seem to have missed this PR... If you're still interested in finishing this, could you fix the merge conflict? |
Hi! I can definitely take a look at this again, but it will take me a bit to get reacquainted, since this PR is now a year old. To answer your question:
If I recall correctly, at the time when I developed this, the introduction of newlines in the text screwed up the ANSI codes a bit, so I made a method in which they could be applied correctly. I seem to recall having made an issue about this. (Issue #35 ) |
…o add method to correctly split a string with embedded ANSI codes
I haven't forgotten this, I've simply not had the time to work on it. I probably will progress with this issue in the next couple of weeks. |
Bump |
Hi! So yeah, a lot of stuff happened in between and I kind of lost track of this... I'll see if I can manage to work on this during the weekend (this time for real!) |
I feel like I've been putting this off for a while now, but I swear that every single weekend I've had has been super busy. I will try to do this ASAP. |
Missclicked, my bad |
This PR resolves #16 and also fixes #35.
A condition was added to see whether the size of the content together with padding and margin would be larger than the number of columns available and if so it would use
wrap-ansi
to bring the content down to a size where the content fits just right on the terminal.Also, when the string to place within the box contains ANSI codes, a new method will be used to split the strnig which correctly places ANSI style codes in order to maintain the expected style both on the string and the box.