console.cpp
Go to the documentation of this file.
00001 /* Copyright (c) Xsens Technologies B.V., 2006-2012. All rights reserved.
00002  
00003       This source code is provided under the MT SDK Software License Agreement 
00004 and is intended for use only by Xsens Technologies BV and
00005        those that have explicit written permission to use it from
00006        Xsens Technologies BV.
00007  
00008       THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009        KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010        IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00011        PARTICULAR PURPOSE.
00012  */
00013 
00014 #include "xsensdeviceapi.h"
00015 
00020 void gotoXY(int x, int y)
00021 {
00022 #ifdef WIN32
00023         COORD coord;
00024         coord.X = x;
00025         coord.Y = y;
00026         SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
00027 #else
00028         char essq[100];         // String variable to hold the escape sequence
00029         char xstr[100];         // Strings to hold the x and y coordinates
00030         char ystr[100];         // Escape sequences must be built with characters
00031 
00032         /*
00033         ** Convert the screen coordinates to strings
00034         */
00035         sprintf(xstr, "%d", x);
00036         sprintf(ystr, "%d", y);
00037 
00038         /*
00039         ** Build the escape sequence (vertical move)
00040         */
00041         essq[0] = '\0';
00042         strcat(essq, "\033[");
00043         strcat(essq, ystr);
00044 
00045         /*
00046         ** Described in man terminfo as vpa=\E[%p1%dd
00047         ** Vertical position absolute
00048         */
00049         strcat(essq, "d");
00050 
00051         /*
00052         ** Horizontal move
00053         ** Horizontal position absolute
00054         */
00055         strcat(essq, "\033[");
00056         strcat(essq, xstr);
00057         // Described in man terminfo as hpa=\E[%p1%dG
00058         strcat(essq, "G");
00059 
00060         /*
00061         ** Execute the escape sequence
00062         ** This will move the cursor to x, y
00063         */
00064         printf("%s", essq);
00065 #endif
00066 }
00067 
00070 void clearScreen()
00071 {
00072 #ifdef WIN32
00073         CONSOLE_SCREEN_BUFFER_INFO csbi;
00074         HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
00075         COORD coord = {0, 0};
00076         DWORD count;
00077 
00078         GetConsoleScreenBufferInfo(hStdOut, &csbi);
00079         FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
00080         SetConsoleCursorPosition(hStdOut, coord);
00081 #else
00082         int i;
00083 
00084         for (i = 0; i < 100; i++)
00085                 // Insert new lines to create a blank screen
00086                 putchar('\n');
00087         gotoXY(0,0);
00088 #endif
00089 }
00090 


receive_xsens
Author(s): Ji Zhang, Silvio Maeta
autogenerated on Tue Sep 8 2015 00:25:08