git-svn-id: svn://db.shs.com.ru/pip@386 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -422,21 +422,98 @@ inline int PIConsole::couts(const PISystemTime & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIConsole::toUpperLeft() {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
void PIConsole::toUpperLeft() {SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);}
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
|
||||||
void PIConsole::moveRight(int n) {SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(n));}
|
#else
|
||||||
void PIConsole::moveLeft(int n) {SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(-n));}
|
printf("\e[H");
|
||||||
void PIConsole::moveTo(int x, int y) {PRIVATE->ccoord.X = x; PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y; SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);}
|
|
||||||
void PIConsole::clearScreen() {couts(fstr(Normal)); toUpperLeft(); FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
|
||||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);}
|
|
||||||
void PIConsole::clearScreenLower() {couts(fstr(Normal)); PRIVATE->getWinCurCoord(); FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
|
||||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);}
|
|
||||||
void PIConsole::clearLine() {PRIVATE->getWinCurCoord(); FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
|
||||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);}
|
|
||||||
void PIConsole::newLine() {PRIVATE->getWinCurCoord(); PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++; SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);}
|
|
||||||
void PIConsole::hideCursor() {PRIVATE->curinfo.bVisible = false; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);}
|
|
||||||
void PIConsole::showCursor() {PRIVATE->curinfo.bVisible = true; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::moveRight(int n) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(n));
|
||||||
|
#else
|
||||||
|
if (n > 0) printf("\e[%dC", n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::moveLeft(int n) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(-n));
|
||||||
|
#else
|
||||||
|
if (n > 0) printf("\e[%dD", n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::moveTo(int x, int y) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->ccoord.X = x;
|
||||||
|
PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y;
|
||||||
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||||
|
#else
|
||||||
|
printf("\e[%d;%dH", y, x);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::clearScreen() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
couts(fstr(Normal));
|
||||||
|
toUpperLeft();
|
||||||
|
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||||
|
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||||
|
#else
|
||||||
|
couts(fstr(Normal)); printf("\e[H\e[J");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::clearScreenLower() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
couts(fstr(Normal));
|
||||||
|
PRIVATE->getWinCurCoord();
|
||||||
|
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||||
|
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||||
|
#else
|
||||||
|
couts(fstr(Normal)); printf("\e[J");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::clearLine() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->getWinCurCoord();
|
||||||
|
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||||
|
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
|
||||||
|
#else
|
||||||
|
printf("\e[K");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::newLine() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->getWinCurCoord();
|
||||||
|
PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++;
|
||||||
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||||
|
#else
|
||||||
|
printf("\eE");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::hideCursor() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->curinfo.bVisible = false;
|
||||||
|
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||||
|
#else
|
||||||
|
printf("\e[?25l");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIConsole::showCursor() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->curinfo.bVisible = true; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||||
|
#else
|
||||||
|
printf("\e[?25h");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConsole::begin() {
|
void PIConsole::begin() {
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ public:
|
|||||||
void disconnect();
|
void disconnect();
|
||||||
bool isConnected() const {return state == Connected;}
|
bool isConnected() const {return state == Connected;}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
void toUpperLeft();
|
void toUpperLeft();
|
||||||
void moveRight(int n = 1);
|
void moveRight(int n = 1);
|
||||||
void moveLeft(int n = 1);
|
void moveLeft(int n = 1);
|
||||||
@@ -259,18 +258,6 @@ public:
|
|||||||
void newLine();
|
void newLine();
|
||||||
void hideCursor();
|
void hideCursor();
|
||||||
void showCursor();
|
void showCursor();
|
||||||
#else
|
|
||||||
void toUpperLeft() {printf("\e[H");}
|
|
||||||
void moveRight(int n = 1) {if (n > 0) printf("\e[%dC", n);}
|
|
||||||
void moveLeft(int n = 1) {if (n > 0) printf("\e[%dD", n);}
|
|
||||||
void moveTo(int x = 0, int y = 0) {printf("\e[%d;%dH", y, x);}
|
|
||||||
void clearScreen() {couts(fstr(Normal)); printf("\e[H\e[J");}
|
|
||||||
void clearScreenLower() {couts(fstr(Normal)); printf("\e[J");}
|
|
||||||
void clearLine() {printf("\e[K");}
|
|
||||||
void newLine() {printf("\eE");}
|
|
||||||
void hideCursor() {printf("\e[?25l");}
|
|
||||||
void showCursor() {printf("\e[?25h");}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EVENT_HANDLER0(void, clearVariables) {clearVariables(true);}
|
EVENT_HANDLER0(void, clearVariables) {clearVariables(true);}
|
||||||
EVENT_HANDLER1(void, clearVariables, bool, clearScreen);
|
EVENT_HANDLER1(void, clearVariables, bool, clearScreen);
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ typedef void(*PINtSetTimerResolution)(ULONG, BOOLEAN, PULONG);
|
|||||||
#ifdef CC_GCC
|
#ifdef CC_GCC
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cstdlib>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user