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

WordWrap support #9

Open
jippi opened this issue Jun 9, 2023 · 4 comments
Open

WordWrap support #9

jippi opened this issue Jun 9, 2023 · 4 comments

Comments

@jippi
Copy link

jippi commented Jun 9, 2023

Hello 👋

First, thank you for an amazingly useful project 🎉

It would be fantastic if there was a WordWrap function that would break up strings by a max-length, but retain the colour stop at EOL and resumed the colouring on the next line when wrapping

(using pseudo-vars rather than ANSI codes directly here)

example := "${BLUE}this is a pretty long string that should ${BOLD}MUST be wrapped${NO_BOLD}${RESET}"

if it was broken up between MUST and be wrapped the ansi would look like this

example := "${BLUE}this is a pretty long string that should ${BOLD}MUST${RESET}\n${BLUE}${BOLD} be wrapped${RESET}"

Basically stopping colouring at WordWrap, and the resume the previous colouring on the 2nd line, to retain colouring and formatting

@leaanthony
Copy link
Owner

Sounds like a nice idea to me! I'd be very happy to accept a PR for this 👍

@jippi
Copy link
Author

jippi commented Jun 10, 2023

I might take a stab at it - do you have any pointers on how to achieve it? I'm not super familiar with the internals of this package or it's dependencies

@leaanthony
Copy link
Owner

Yeah, it's all about the Parse function. Line 277 reads characters up to the terminating escape code. You'll need to keep track of the current line count and work out if the current iteration will break that limit.

@jippi
Copy link
Author

jippi commented Jun 10, 2023

Thank you, I'll give it a try next week at work if I got time 👌

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

No branches or pull requests

2 participants