-
Notifications
You must be signed in to change notification settings - Fork 2
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
Console/Output: cursor and linelength #28
Comments
Hm, the reason the cursor movement methods don't influence the lineLength is because they're not quite compatible, as you showed. Especially when you consider The most fitting solution here is that as soon as you use a cursor-movement method, |
There are some other solutions possible, but I feel they might get really complicated very quickly. I think the solution I mentioned before should be enough, and then add some comments to |
(additionally, after trying your example, the lineLength is 18260, and on my full-screen terminal it ends up just clearing the screen and printing "All done", hehe) |
Fixed by #27 |
Not sure if bug or mis-use but shouldn't
cursorBack
and-Forward
affect the linelength in some way? Consider this case (overly simplified version obviously):What is the final result of this? You'd think it'd be just a single line "All done". However, due to how it works internally, it prints 9 * 1 + 90 * 2 + 900 * 3 + 1 * 4 = 2893 spaces (obviously spanning multiple lines), then tries to move back 2893 places but only goes as far as the start of the current line, and then prints "All done" on the beginning of the line, resulting in a lot of unexpected "blank" lines.
Solution (if you don't consider this a bug) might be something like a new function
cursorReset
which moves the cursor to the beginning of the line and setslinelength
back to 0. This loses the ability to clear the current line, however seeing my given case that's not always needed anyway: replace thecursorBack
call with thiscursorReset
and all behaves as expected ( / needed for this scenario).However while my case is an extreme one, the mismatch can happen way earlier. Think of a console width of 80 characters, I print 45, go back 15, print another 45. Actual line is now 75, all one line. However because of
linelength
,clearLine()
will print 90 spaces, thus basically inserting a newline.The text was updated successfully, but these errors were encountered: