📄 pmdconio.c
字号:
/***************************************************************************** $Workfile: PMDconio.c $ $Revision: 7 $ Purpose: Console IO redirector/****************************************************************************/#include <stdio.h>#include <stdarg.h>#ifdef _LINUX#include "/usr/include/time.h"#include <sys/time.h>#else#include <sys/timeb.h>#endif#ifdef _CONSOLE #include <conio.h>#elif _WINDOWS#include <windows.h>#elif _LINUX#ifdef __cplusplusextern "C" {#endif#ifdef WIN32#include "ConsFunc.h" /* PLX utility */#endif#ifdef __cplusplus}#endif //cplusplus#endif // _LINUX#include "PMDconio.h"static PRINTFN (*reprintf)(const char*, ...) =//#ifndef WIN32// PlxPrintf;//#else printf;//#endif//*****************************************************************************void SetPMDprintf(PRINTFN (*fn)(const char*, ...)){ reprintf = fn;}//*****************************************************************************void PMDprintf( char *fmt, ... ){ char buff[200]; va_list arglist; va_start( arglist, fmt ); vsprintf( buff, fmt, arglist ); va_end( arglist ); reprintf( buff );}//*****************************************************************************// check for a key to be hit on the keyboardint PMDkbhit(){#ifdef _CONSOLE // call getch after kbhit to absorb the character return (kbhit() && getch());#elif _WINDOWS // If the most significant bit is set, the key is down, and if the least significant bit is set, // the key was pressed after the previous call to GetAsyncKeyState. return ((GetAsyncKeyState(VK_ESCAPE) & 0x8000) || (GetAsyncKeyState(VK_SPACE) & 0x8000));#elif _LINUX // return (Plx_kbhit() && getch()); #else return 0;#endif}//*****************************************************************************void HostDelay(int milliseconds){#ifdef _LINUX struct timeval currentTime;#else struct timeb currentTime;#endif unsigned long stopms; unsigned long currentms;#ifdef _LINUX gettimeofday(¤tTime, NULL); stopms = currentTime.tv_sec * 1000l + currentTime.tv_usec/1000l;#else ftime( ¤tTime ); stopms = currentTime.time * 1000 + currentTime.millitm;#endif stopms += milliseconds; do {#ifdef _LINUX gettimeofday(¤tTime, NULL); currentms = currentTime.tv_sec * 1000l + currentTime.tv_usec/1000l;#else ftime( ¤tTime ); currentms = currentTime.time * 1000 + currentTime.millitm;#endif } while (currentms <= stopms);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -