Easy Crafty Question for Dr. Hyatt

Code, algorithms, languages, construction...
Post Reply
User avatar
LiquidNitrogen
Posts: 19
Joined: Sun Jun 13, 2010 1:20 am
Real Name: Ed Trice

Easy Crafty Question for Dr. Hyatt

Post by LiquidNitrogen » Fri Jul 23, 2010 2:21 am

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.

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Easy Crafty Question for Dr. Hyatt

Post by hyatt » Fri Jul 23, 2010 2:29 am

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...

User avatar
LiquidNitrogen
Posts: 19
Joined: Sun Jun 13, 2010 1:20 am
Real Name: Ed Trice

Re: Easy Crafty Question for Dr. Hyatt

Post by LiquidNitrogen » Fri Jul 23, 2010 2:33 am

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.

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Easy Crafty Question for Dr. Hyatt

Post by hyatt » Fri Jul 23, 2010 3:40 am

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...

Post Reply