src/term/term.c
void clear_term(void){
#if defined(_WIN32) && (!defined(_WIN32_PREFER_ANSI_ESC_SEQ) || !_WIN32_PREFER_ANSI_ESC_SEQ)
    COORD   coordScreen = { 0, 0 };
    BOOL    bSuccess = 1;
    DWORD   cCharsWritten;
    DWORD   dwConSize;
    HANDLE  hConsole;
    CONSOLE_SCREEN_BUFFER_INFO  csbi;

    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    if(!GetConsoleScreenBufferInfo( hConsole, &csbi ))
        return;

    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    if(!FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
        dwConSize, coordScreen, &cCharsWritten ))
        return;

    if(!GetConsoleScreenBufferInfo( hConsole, &csbi ))
        return;

    if(!FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
        dwConSize, coordScreen, &cCharsWritten ))
        return;

    if(!SetConsoleCursorPosition( hConsole, coordScreen ))
        return;

    return;
#elif defined(__linux__) || (defined(_WIN32_PREFER_ANSI_ESC_SEQ) && _WIN32_PREFER_ANSI_ESC_SEQ)
# ifdef _WIN32
    enable_esc_seq_support();
# endif
    printf("\033[2J\033[H");
    return;
#endif
}
// *********************************************************************************************************************** //
// Clear current term/console, and move cursor to upper left corner
// Returned 0 for success, -1 for failure
Clear current term/console, and move cursor to upper left corner
Returned 0 for success, -1 for failure
Clear current term / console and move cursor to upper left corner Returned 0 for success - 1 for failure
void clear_term(void){
#if defined(_WIN32) && (!defined(_WIN32_PREFER_ANSI_ESC_SEQ) || !_WIN32_PREFER_ANSI_ESC_SEQ)
    COORD   coordScreen = { 0, 0 };
    BOOL    bSuccess = 1;
    DWORD   cCharsWritten;
    DWORD   dwConSize;
    HANDLE  hConsole;
    CONSOLE_SCREEN_BUFFER_INFO  csbi;
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    if(!GetConsoleScreenBufferInfo( hConsole, &csbi ))
        return;
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    if(!FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
        dwConSize, coordScreen, &cCharsWritten ))
        return;
    if(!GetConsoleScreenBufferInfo( hConsole, &csbi ))
        return;
    if(!FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
        dwConSize, coordScreen, &cCharsWritten ))
        return;
    if(!SetConsoleCursorPosition( hConsole, coordScreen ))
        return;
    return;
#elif defined(__linux__) || (defined(_WIN32_PREFER_ANSI_ESC_SEQ) && _WIN32_PREFER_ANSI_ESC_SEQ)
# ifdef _WIN32
    enable_esc_seq_support();
# endif
    printf("\033[2J\033[H");
    return;
#endif
}
void clear_term ( void ) { #if defined ( _WIN32 ) && ( ! defined ( _WIN32_PREFER_ANSI_ESC_SEQ ) || ! _WIN32_PREFER_ANSI_ESC_SEQ ) COORD coordScreen = { 0 , 0 } ; BOOL bSuccess = 1 ; DWORD cCharsWritten ; DWORD dwConSize ; HANDLE hConsole ; CONSOLE_SCREEN_BUFFER_INFO csbi ; hConsole = GetStdHandle ( STD_OUTPUT_HANDLE ) ; if ( ! GetConsoleScreenBufferInfo ( hConsole , & csbi ) ) return ; dwConSize = csbi . dwSize . X * csbi . dwSize . Y ; if ( ! FillConsoleOutputCharacter ( hConsole , ( TCHAR ) ' ' , dwConSize , coordScreen , & cCharsWritten ) ) return ; if ( ! GetConsoleScreenBufferInfo ( hConsole , & csbi ) ) return ; if ( ! FillConsoleOutputAttribute ( hConsole , csbi . wAttributes , dwConSize , coordScreen , & cCharsWritten ) ) return ; if ( ! SetConsoleCursorPosition ( hConsole , coordScreen ) ) return ; return ; #elif defined ( __linux__ ) || ( defined ( _WIN32_PREFER_ANSI_ESC_SEQ ) && _WIN32_PREFER_ANSI_ESC_SEQ ) # ifdef _WIN32 enable_esc_seq_support ( ) ; # endif printf ( " \033 \033 " ) ; return ; #endif }
Clear current term/console, and move cursor to upper left corner
Returned 0 for success, -1 for failure
Clear current term / console and move cursor to upper left corner Returned 0 for success - 1 for failure