In C is there a way to clear a single line or a block of lines without affecting the text on the rest of the screen? Also, I assume that if I can clear a single line, I can also clear it after a certain point on the line.
Thx,
Steve
Printable View
In C is there a way to clear a single line or a block of lines without affecting the text on the rest of the screen? Also, I assume that if I can clear a single line, I can also clear it after a certain point on the line.
Thx,
Steve
In standard console mode on ANSI-compliant terminals you can use ANSI escape sequences to do what you want.
This is from memory so you need to check it out, including typos.
For futher ref - check out ANSI escape sequences or ANSI.SYS on the net - google is best.
Code:#define zout(c) memset(&c,0x00,sizeof(c))
#include <strings.h>
void setup(char*);
void linedel(int col,int row){ /*delete from col -> EOL on row */
const char esc =27;
char tmp[20];
zout(tmp);
setup(tmp);
/* send esc[s esc[row;colH esc[K esc[u */
printf("%s%s%s%d;%dH%s%s%s%s",
tmp,"s",
tmp,row,col,
tmp,"K",
tmp,"u");
return;
}
void setup(char * src){
char *buf;
buf=src;
*buf++=27; /* escape */
*buf++='['; /* open sq bracket */
*buf=0x00;
return;
}