qx82 icon indicating copy to clipboard operation
qx82 copied to clipboard

Add maxWidth and respect maxLen in readLine

Open HoofedEar opened this issue 1 year ago • 2 comments

Related to #8

Allows for setting a maximum width of characters for readLine. Which means if the user types beyond the maxWidth, it will move the cursor to the next line. It is currently set to default of 28 so that it aligns well with the "example-hello.html" example, but of course can be set to other values. For example, here is it set to 5 (readLine("", -1, 5);) image

When you press "Enter", it will return the entire line as a single string with no newlines, so it will preserve the nature of readLine.

Also, made sure that it respects the value set for maxLen so that works now too 👍

Feel free to adjust or change anything in my code!

HoofedEar avatar May 17 '24 16:05 HoofedEar

Very nice! I think it will be a great addition to QX82.

Just one tiny thing: I like to keep 100% backwards compatibility when possible, so in this case I'd prefer if it defaulted to an infinite max width (in other words, no wrapping) if the user omits the maxLength parameter. Maybe you can make it so it defaults to -1, and have -1 mean "no wrapping" in the code?

Thanks!

btco avatar May 18 '24 17:05 btco

Maybe you can make it so it defaults to -1, and have -1 mean "no wrapping" in the code?

Done! Good call on backwards compatibility, 28 as default would have been jarring lol

Also fixed a bug in my code related to checking maxLen, so it should be good to go now! :+1:

HoofedEar avatar May 18 '24 22:05 HoofedEar

Great, perfect!

btco avatar May 25 '24 17:05 btco