04.11.2011 - adjust for Windows & QNX, multiprotocol, repeater, signals, process, codec, console input
This commit is contained in:
@@ -156,6 +156,8 @@ PIString PIConsole::fstr(PIFlags<PIConsole::Format> f) {
|
||||
if (f[PIConsole::BackMagenta]) attr |= (FOREGROUND_RED | FOREGROUND_BLUE);
|
||||
if (f[PIConsole::BackCyan]) attr |= (FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
if (f[PIConsole::BackWhite]) attr |= (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
if ((attr & BACKGROUND_RED) + (attr & BACKGROUND_GREEN) + (attr & BACKGROUND_BLUE) == 0)
|
||||
attr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
} else {
|
||||
if (f[PIConsole::Red]) attr |= FOREGROUND_RED;
|
||||
if (f[PIConsole::Green]) attr |= FOREGROUND_GREEN;
|
||||
@@ -171,6 +173,8 @@ PIString PIConsole::fstr(PIFlags<PIConsole::Format> f) {
|
||||
if (f[PIConsole::BackMagenta]) attr |= (BACKGROUND_RED | BACKGROUND_BLUE);
|
||||
if (f[PIConsole::BackCyan]) attr |= (BACKGROUND_GREEN | BACKGROUND_BLUE);
|
||||
if (f[PIConsole::BackWhite]) attr |= (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
|
||||
if ((attr & FOREGROUND_RED) + (attr & FOREGROUND_GREEN) + (attr & FOREGROUND_BLUE) == 0)
|
||||
attr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
}
|
||||
if (f[PIConsole::Bold]) attr |= FOREGROUND_INTENSITY;
|
||||
|
||||
@@ -279,7 +283,7 @@ void PIConsole::run() {
|
||||
}
|
||||
moveRight(tv.offset);
|
||||
switch (tv.type) {
|
||||
case 0: clen = printValue(tv.s != 0 ? *tv.s : "", tv.format); break;
|
||||
case 0: clen = printValue(tv.s != 0 ? *tv.s : PIString(), tv.format); break;
|
||||
case 1: clen = printValue(tv.b != 0 ? *tv.b : false, tv.format); break;
|
||||
case 2: clen = printValue(tv.i != 0 ? *tv.i : 0, tv.format); break;
|
||||
case 3: clen = printValue(tv.l != 0 ? *tv.l : 0l, tv.format); break;
|
||||
@@ -296,7 +300,11 @@ void PIConsole::run() {
|
||||
case 14: clen = printValue(bitsValue(tv.ptr, tv.bitFrom, tv.bitCount), tv.format); break;
|
||||
}
|
||||
if (clen + tv.offset < (uint)col_wid) {
|
||||
#ifdef QNX
|
||||
string ts = PIString(col_wid - clen - tv.offset - 1, ' ').stdString();
|
||||
#else
|
||||
string ts = PIString(col_wid - clen - tv.offset, ' ').stdString();
|
||||
#endif
|
||||
printf("%s", ts.c_str());
|
||||
}
|
||||
newLine();
|
||||
@@ -444,10 +452,19 @@ PIString PIConsole::getString(int x, int y) {
|
||||
bool run = isRunning();
|
||||
if (run) PIThread::stop(true);
|
||||
listener->setActive(false);
|
||||
msleep(50);
|
||||
#ifdef WINDOWS
|
||||
moveTo(x - 1, y - 1);
|
||||
#else
|
||||
moveTo(x, y);
|
||||
#endif
|
||||
showCursor();
|
||||
PIByteArray ba(4096);
|
||||
#ifdef CC_VC
|
||||
int ret = scanf_s(" %s", ba.data());
|
||||
#else
|
||||
int ret = scanf(" %s", ba.data());
|
||||
#endif
|
||||
listener->setActive(true);
|
||||
if (run) start();
|
||||
if (ret >= 1) return PIString(ba);
|
||||
|
||||
Reference in New Issue
Block a user