Page 1 of 1
Easy Crafty Question for Dr. Hyatt
Posted: Fri Jul 23, 2010 2:21 am
by LiquidNitrogen
Hoping Dr. Hyatt still comes on this board now and then.
I can remember, ages ago when I studied the Crafty code, there was a clever way to "redraw" just one part of the screen. Crafty updates it's time, or replaces parts of its PV, without having the screen scroll vertically.
I promised I would "make a note of this" for later use, and now, I am writing a GUI-less windows executable, and it would be a very handy thing to do!
Of course, I no longer remember where it is {was something like print(4095...} and now I need it.
Can you offer any insight?
Thanks.
Re: Easy Crafty Question for Dr. Hyatt
Posted: Fri Jul 23, 2010 2:29 am
by hyatt
LiquidNitrogen wrote:Hoping Dr. Hyatt still comes on this board now and then.
I can remember, ages ago when I studied the Crafty code, there was a clever way to "redraw" just one part of the screen. Crafty updates it's time, or replaces parts of its PV, without having the screen scroll vertically.
I promised I would "make a note of this" for later use, and now, I am writing a GUI-less windows executable, and it would be a very handy thing to do!
Of course, I no longer remember where it is {was something like print(4095...} and now I need it.
Can you offer any insight?
Thanks.
Sure. Rather than using \n, you use \r instead. This moves the cursor back to the beginning of the current line, like \n, but does _not_ emit a linefeed, so that the cursor stays on the same line. Only warning is to make sure than when you do this to display a new line, that the new line is at least as long as the previous one so that extra characters are not left "hanging". Simplest solution is to watch what you print and add enough " " characters to make sure you overwrite anything from the previous print...
Re: Easy Crafty Question for Dr. Hyatt
Posted: Fri Jul 23, 2010 2:33 am
by LiquidNitrogen
hyatt wrote:
Sure. Rather than using \n, you use \r instead.
Wow, was it really that simple?
Thanks.
So I take it you just would redraw the last line on the screen then, padding with the space characters as needed?
I'll check it out.
Re: Easy Crafty Question for Dr. Hyatt
Posted: Fri Jul 23, 2010 3:40 am
by hyatt
LiquidNitrogen wrote:hyatt wrote:
Sure. Rather than using \n, you use \r instead.
Wow, was it really that simple?
Thanks.
So I take it you just would redraw the last line on the screen then, padding with the space characters as needed?
I'll check it out.
Correct... There are traps of course, like automatic line wrap on some devices that can get this out of sync, just avoid lines > 80 and that should not bite you at all...