7.12.2010 - bug fixes in PIString, all classes now based on PIString
This commit is contained in:
@@ -17,7 +17,7 @@ PIConsole::PIConsole(bool startNow, KeyFunc slot): PIThread() {
|
||||
GetConsoleMode(hOut, &smode);
|
||||
GetConsoleCursorInfo(hOut, &curinfo);
|
||||
#endif
|
||||
addTab(string("main"));
|
||||
addTab(PIString("main"));
|
||||
listener = new PIKbdListener(key_event, this);
|
||||
if (startNow) start(40);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ PIConsole::~PIConsole() {
|
||||
}
|
||||
|
||||
|
||||
int PIConsole::addTab(string name, char bind_key) {
|
||||
int PIConsole::addTab(PIString name, char bind_key) {
|
||||
tabs.push_back(Tab(name, bind_key));
|
||||
cur_tab = tabs.size() - 1;
|
||||
return tabs.size();
|
||||
@@ -53,7 +53,7 @@ void PIConsole::removeTab(uint index) {
|
||||
}
|
||||
|
||||
|
||||
void PIConsole::removeTab(string name) {
|
||||
void PIConsole::removeTab(PIString name) {
|
||||
uint index = tabs.size() + 1;
|
||||
for (uint i = 0; i < tabs.size(); ++i) {
|
||||
if (tabs[i].name == name) {
|
||||
@@ -78,7 +78,7 @@ bool PIConsole::setTab(uint index) {
|
||||
}
|
||||
|
||||
|
||||
bool PIConsole::setTab(string name) {
|
||||
bool PIConsole::setTab(PIString name) {
|
||||
uint index = tabs.size() + 1;
|
||||
for (uint i = 0; i < tabs.size(); ++i) {
|
||||
if (tabs[i].name == name) {
|
||||
@@ -98,7 +98,7 @@ bool PIConsole::setTabBindKey(uint index, char bind_key) {
|
||||
}
|
||||
|
||||
|
||||
bool PIConsole::setTabBindKey(string name, char bind_key) {
|
||||
bool PIConsole::setTabBindKey(PIString name, char bind_key) {
|
||||
uint index =tabs.size() + 1;
|
||||
for (uint i = 0; i < tabs.size(); ++i) {
|
||||
if (tabs[i].name == name) {
|
||||
@@ -122,7 +122,7 @@ void PIConsole::key_event(void * t, char key) {
|
||||
}
|
||||
|
||||
|
||||
string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
||||
PIString PIConsole::fstr(Flags<PIConsole::Format> f) {
|
||||
if (f[PIConsole::Dec]) num_format = 0;
|
||||
if (f[PIConsole::Hex]) num_format = 1;
|
||||
if (f[PIConsole::Oct]) num_format = 2;
|
||||
@@ -154,7 +154,7 @@ string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
||||
SetConsoleTextAttribute(hOut, attr);
|
||||
return "";
|
||||
#else
|
||||
string ts = "\e[0";
|
||||
PIString ts = "\e[0";
|
||||
|
||||
if (f[PIConsole::Bold]) ts += ";1";
|
||||
if (f[PIConsole::Faint]) ts += ";2";
|
||||
@@ -187,7 +187,7 @@ string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
||||
#define fprint(x) switch (num_format) {case (3): return printf("%e", x); break; default: return printf("%.5g", x); break;}
|
||||
#define dprint(x) switch (num_format) {case (3): return printf("%le", x); break; default: return printf("%.5lg", x); break;}
|
||||
|
||||
inline int PIConsole::couts(string v) {return printf("%s", v.c_str());}
|
||||
inline int PIConsole::couts(PIString v) {return printf("%s", v.data());}
|
||||
inline int PIConsole::couts(char * v) {return printf("%s", v);}
|
||||
inline int PIConsole::couts(bool v) {return (v ? printf("true") : printf("false"));}
|
||||
inline int PIConsole::couts(char v) {return printf("%c", v);}
|
||||
@@ -262,7 +262,7 @@ void PIConsole::run() {
|
||||
case 14: clen = printValue(bitsValue(tv.uc, tv.bitFrom, tv.bitCount), tv.format); break;
|
||||
}
|
||||
if (clen + tv.offset < (uint)col_wid)
|
||||
printf("%s", string(col_wid - clen - tv.offset, ' ').c_str());
|
||||
printf("%s", PIString(col_wid - clen - tv.offset, ' ').data());
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void PIConsole::status() {
|
||||
if (ctab->key == 0) continue;
|
||||
printValue(ctab->key, PIConsole::Bold);
|
||||
printValue(ctab->name + " ", PIConsole::Cyan | PIConsole::Inverse);
|
||||
printValue(string(" "), PIConsole::Normal);
|
||||
printValue(PIString(" "), PIConsole::Normal);
|
||||
}
|
||||
newLine();
|
||||
}
|
||||
@@ -346,37 +346,37 @@ int PIConsole::bitsValue(unsigned char * src, int offset, int count) {
|
||||
|
||||
#define ADD_VAR_BODY tv.name = name; tv.bitFrom = tv.bitCount = 0; tv.format = format; checkColumn(column);
|
||||
|
||||
void PIConsole::addString(string name, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addString(PIString name, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 0; tv.s = 0; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, string* ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, PIString* ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 0; tv.s = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, bool * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, bool * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 1; tv.b = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, int * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, int * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 2; tv.i = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, long * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, long * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 3; tv.l = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, char * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, char * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 4; tv.c = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, float * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, float * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 5; tv.f = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, double * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, double * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 6; tv.d = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, short * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, short * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 7; tv.sh = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, uint * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, uint * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 8; tv.ui = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, ulong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, ulong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 9; tv.ul = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, ushort * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, ushort * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 10; tv.ush = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, uchar * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, uchar * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 11; tv.uc = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, llong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, llong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 12; tv.ll = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addVariable(string name, ullong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addVariable(PIString name, ullong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||
ADD_VAR_BODY tv.type = 13; tv.ull = ptr; vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addBitVariable(string name, uchar * ptr, int fromBit, int bitCount, int column, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::addBitVariable(PIString name, uchar * ptr, int fromBit, int bitCount, int column, Flags<PIConsole::Format> format) {
|
||||
tv.name = name; tv.bitFrom = fromBit; tv.bitCount = bitCount; tv.type = 14; tv.uc = ptr; tv.format = format;
|
||||
checkColumn(column); vars()[column - 1].push_back(tv);}
|
||||
void PIConsole::addEmptyLine(int column) {
|
||||
@@ -385,17 +385,17 @@ void PIConsole::addEmptyLine(int column) {
|
||||
|
||||
#define PRINT_VAR_BODY couts(fstr(format)); int ret = couts(value); fstr(PIConsole::Dec); return ret;
|
||||
|
||||
void PIConsole::printLine(string value, int dx, Flags<PIConsole::Format> format) {
|
||||
void PIConsole::printLine(PIString value, int dx, Flags<PIConsole::Format> format) {
|
||||
int i = width - value.length() - dx;
|
||||
#ifdef QNX
|
||||
--i;
|
||||
#endif
|
||||
couts(fstr(format));
|
||||
if (i >= 0) couts(value + string(i, ' '));
|
||||
else couts(string(value, 0, value.length() + i));
|
||||
if (i >= 0) couts(value + PIString(i, ' '));
|
||||
else couts(value.left(value.length() + i));
|
||||
couts(fstr(Dec));
|
||||
}
|
||||
int PIConsole::printValue(string value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||
int PIConsole::printValue(PIString value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||
int PIConsole::printValue(char * value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||
int PIConsole::printValue(bool value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||
int PIConsole::printValue(int value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||
|
||||
Reference in New Issue
Block a user