git-svn-id: svn://db.shs.com.ru/pip@388 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -270,6 +270,16 @@ void PIConsole::key_event(PIKbdListener::KeyEvent key, void * t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PIConsole::couts(const PIString & v) {
|
||||||
|
return printf("%s", v.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PIConsole::couts(const char * v) {
|
||||||
|
return printf("%s", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConsole::clearVariables(bool clearScreen) {
|
void PIConsole::clearVariables(bool clearScreen) {
|
||||||
if (isRunning()) lock();
|
if (isRunning()) lock();
|
||||||
if (clearScreen && isRunning()) {
|
if (clearScreen && isRunning()) {
|
||||||
|
|||||||
@@ -391,22 +391,22 @@ public:
|
|||||||
|
|
||||||
PIVector<Column> & columns() {return tabs[cur_tab].columns;}
|
PIVector<Column> & columns() {return tabs[cur_tab].columns;}
|
||||||
Column & column(int index) {return tabs[cur_tab].columns[index - 1];}
|
Column & column(int index) {return tabs[cur_tab].columns[index - 1];}
|
||||||
inline int couts(const PIString & v) {return printf("%s", v.data());}
|
int couts(const PIString & v);
|
||||||
inline int couts(const char * v) {return printf("%s", v);}
|
int couts(const char * v);
|
||||||
inline int couts(const bool v);
|
int couts(const bool v);
|
||||||
inline int couts(const char v);
|
int couts(const char v);
|
||||||
inline int couts(const short v);
|
int couts(const short v);
|
||||||
inline int couts(const int v);
|
int couts(const int v);
|
||||||
inline int couts(const long v);
|
int couts(const long v);
|
||||||
inline int couts(const llong v);
|
int couts(const llong v);
|
||||||
inline int couts(const uchar v);
|
int couts(const uchar v);
|
||||||
inline int couts(const ushort v);
|
int couts(const ushort v);
|
||||||
inline int couts(const uint v);
|
int couts(const uint v);
|
||||||
inline int couts(const ulong v);
|
int couts(const ulong v);
|
||||||
inline int couts(const ullong v);
|
int couts(const ullong v);
|
||||||
inline int couts(const float v);
|
int couts(const float v);
|
||||||
inline int couts(const double v);
|
int couts(const double v);
|
||||||
inline int couts(const PISystemTime & v);
|
int couts(const PISystemTime & v);
|
||||||
|
|
||||||
struct RemoteClient;
|
struct RemoteClient;
|
||||||
|
|
||||||
|
|||||||
@@ -278,22 +278,24 @@ ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
|||||||
}
|
}
|
||||||
#undef FOREGROUND_MASK
|
#undef FOREGROUND_MASK
|
||||||
#undef BACKGROUND_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 PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||||
PIString ts("\e[0");
|
PIString ts("\e[0");
|
||||||
switch (c.format.color_char) {
|
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";
|
if ((c.format.flags & Inverse) == Inverse) ts += ";7";
|
||||||
return ts + "m";
|
return ts + "m";
|
||||||
}
|
}
|
||||||
|
#endif // WINDOWS
|
||||||
|
|
||||||
|
|
||||||
|
void PIScreen::SystemConsole::toUpperLeft() {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
|
||||||
|
#else
|
||||||
|
printf("\e[H");
|
||||||
#endif
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -106,26 +106,18 @@ private:
|
|||||||
void clear();
|
void clear();
|
||||||
void print();
|
void print();
|
||||||
void resize(int w, int h);
|
void resize(int w, int h);
|
||||||
#ifdef WINDOWS
|
|
||||||
void getWinCurCoord();
|
|
||||||
void toUpperLeft();
|
void toUpperLeft();
|
||||||
void moveRight(int n = 1);
|
|
||||||
void moveLeft(int n = 1);
|
|
||||||
void moveTo(int x = 0, int y = 0);
|
void moveTo(int x = 0, int y = 0);
|
||||||
void clearScreen();
|
|
||||||
void clearScreenLower();
|
|
||||||
void clearLine();
|
|
||||||
void newLine();
|
|
||||||
void hideCursor();
|
void hideCursor();
|
||||||
void showCursor();
|
void showCursor();
|
||||||
|
void clearScreen();
|
||||||
|
void clearScreenLower();
|
||||||
|
#ifdef WINDOWS
|
||||||
|
void getWinCurCoord();
|
||||||
|
void clearLine();
|
||||||
|
void newLine();
|
||||||
ushort attributes(const PIScreenTypes::Cell & c);
|
ushort attributes(const PIScreenTypes::Cell & c);
|
||||||
#else
|
#else
|
||||||
void toUpperLeft() {printf("\e[H");}
|
|
||||||
void moveTo(int x = 0, int y = 0) {printf("\e[%d;%dH", y + 1, x + 1);}
|
|
||||||
void hideCursor() {printf("\e[?25l");}
|
|
||||||
void showCursor() {printf("\e[?25h");}
|
|
||||||
void clearScreen() {printf("\e[0m\e[H\e[J");}
|
|
||||||
void clearScreenLower() {printf("\e[0m\e[J");}
|
|
||||||
PIString formatString(const PIScreenTypes::Cell & c);
|
PIString formatString(const PIScreenTypes::Cell & c);
|
||||||
#endif
|
#endif
|
||||||
PRIVATE_DECLARATION
|
PRIVATE_DECLARATION
|
||||||
|
|||||||
Reference in New Issue
Block a user