TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: T M SMITH
from: BIG BAD BOB
date: 2017-10-22 23:57:00
subject: Re: Screen control

On 10/21/17 13:04, T M Smith wrote:
> I am sure this is elementary to most but bear with me please.
> I am using Raspbian on a pi. How does one get a reading to print on
> screen in the same place on a continueing basis rather than printing
> on a new line and scrolling.
>

if you're running this in a console, check out how 'curses' works.  You
can also try the VT ANSI escape sequences yourself.

you can also send a 'home' cursor to the screen to overwrite the same
line over and over...

https://en.wikipedia.org/wiki/ANSI_escape_code

I think the right sequence for 'home cursor' is:

[1G

in C code it would be:

"\x1b[1G"

so don't do a line feed '\n' at the end, but do THAT instead, and I
think the line will overwrite itself.  That's what you wanted, right?

(I've done this before but I don't have the code in front of me at the
moment)

OK curiosity bugs me now and so I wrote this:



#include 
#include 

int main()
{
int i1;

   for(i1=0; i1 < 500; i1++)
   {
     printf("Here I am: %d    \x1b[1G", i1);
     fflush(stdout);
     usleep(100000);
   }
}



try it, you'll like it!

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.