git-svn-id: svn://db.shs.com.ru/pip@388 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -278,22 +278,24 @@ ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||
}
|
||||
#undef FOREGROUND_MASK
|
||||
#undef BACKGROUND_MASK
|
||||
void PIScreen::SystemConsole::getWinCurCoord() {GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi); PRIVATE->ccoord = PRIVATE->csbi.dwCursorPosition;}
|
||||
void PIScreen::SystemConsole::toUpperLeft() {SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);}
|
||||
void PIScreen::SystemConsole::moveTo(int x, int y) {PRIVATE->ccoord.X = x; PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y; SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);}
|
||||
void PIScreen::SystemConsole::clearScreen() {toUpperLeft(); FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);}
|
||||
void PIScreen::SystemConsole::clearScreenLower() {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 PIScreen::SystemConsole::clearLine() {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 PIScreen::SystemConsole::newLine() {getWinCurCoord(); PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++; SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);}
|
||||
void PIScreen::SystemConsole::hideCursor() {PRIVATE->curinfo.bVisible = false; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);}
|
||||
void PIScreen::SystemConsole::showCursor() {PRIVATE->curinfo.bVisible = true; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);}
|
||||
#endif
|
||||
|
||||
void PIScreen::SystemConsole::getWinCurCoord() {
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
||||
PRIVATE->ccoord = PRIVATE->csbi.dwCursorPosition;
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
void PIScreen::SystemConsole::clearLine() {
|
||||
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 PIScreen::SystemConsole::newLine() {
|
||||
getWinCurCoord();
|
||||
PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++;
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||
}
|
||||
#else // WINDOWS
|
||||
PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||
PIString ts("\e[0");
|
||||
switch (c.format.color_char) {
|
||||
@@ -322,7 +324,64 @@ PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||
if ((c.format.flags & Inverse) == Inverse) ts += ";7";
|
||||
return ts + "m";
|
||||
}
|
||||
#endif // WINDOWS
|
||||
|
||||
|
||||
void PIScreen::SystemConsole::toUpperLeft() {
|
||||
#ifdef WINDOWS
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
|
||||
#else
|
||||
printf("\e[H");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::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 + 1, x + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::clearScreen() {
|
||||
#ifdef WINDOWS
|
||||
toUpperLeft();
|
||||
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||
#else
|
||||
printf("\e[0m\e[H\e[J");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::clearScreenLower() {
|
||||
#ifdef WINDOWS
|
||||
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
|
||||
printf("\e[0m\e[J");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::hideCursor() {
|
||||
#ifdef WINDOWS
|
||||
PRIVATE->curinfo.bVisible = false;
|
||||
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
printf("\e[?25l");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::showCursor() {
|
||||
#ifdef WINDOWS
|
||||
PRIVATE->curinfo.bVisible = true;
|
||||
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
printf("\e[?25h");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user