Hi I am programming something and i need to use Hyperterminal to display the output, all is well but i am struggling for the right ANSI escape sequence to position the cursor to the beginning, i have tried various things including the following;
char pos [] = "\x1B[",'0',';','0','H',0;
many thanks
"i am struggling for the right ANSI escape sequence"
What "struggle", precisely, are you having?
Struggling to find out what the correct escape sequence is?
Struggling to get Hypoterminal to recognise it?
Struggling with how to code it in 'C'?
Struggling with how to get your particular target to transmit it?
Or what??
I was referring to the correct escape sequence, and how to code it into c, i thought i was clear about it... sorry
Hi,
in UV4 you can also try this sequences in the simulator-uart.
http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_serialwin.htm
. BR, /th.
Your original does seem particularly cumbersome:
Why not just:
char pos [] = "\x1B[0;0H";
Are you sure that (0,0) is correct for the "Home" postition? Some sites suggest it's (1,1)...
I'm not sure about ANSI terminal, but I know these work for vt-100.
#define CLEAR_SCREEN_LENGTH 4 //! \details String to clear the screen of a VT-100 termial static unsigned char Clear_Screen[] = {27,91,50,74}; #define HOME_CURSOR_LENGTH 3 //! \details String to home the cursor of a VT-100 termial static unsigned char Home_Cursor[] = {27,91,72};
see documentation in link:
// Clear screen and set cursor home void ClearScreen(void) { printf("%c[1;1f%c[J", 27, 27); } // set cursor to position (x, y) void SetCursorPosition(int x, int y) { printf("%c[%i;%if", 27, (signed int)y, (signed int)x); }
printf("%c[1;1f%c[J", 27, 27);
That also seems very clumsy to me - and surprisingly common!
Why not just
printf( "\x1B[1;1f\x1B[J" );
Also, if you consider code and speed consequences it's not at all efficient.
Many thanks for all your replies, its working now