new feature for parser, coordinates reader

This commit is contained in:
unK
2008-09-13 20:39:13 +02:00
parent 831f9ab405
commit 369bbf6b96
2 changed files with 39 additions and 2 deletions

View File

@@ -312,7 +312,16 @@ void Window::Write(int limit, const string &str, bool clrtoeol)
{
waddstr(itsWindow,tmp.c_str());
tmp.clear();
if (IsValidColor(color))
if (isdigit(color[2]))
{
int x, y;
getyx(itsWindow, y, x);
Coordinates coords = IntoCoordinates(color);
wmove(itsWindow, coords.second == -1 ? y : coords.second, coords.first);
limit -= coords.first-x;
}
else if (IsValidColor(color))
{
ColorPair colors = IntoColor(color);
SetColor(colors.first, colors.second);
@@ -376,7 +385,16 @@ void Window::Write(int limit, const wstring &str, bool clrtoeol)
{
waddwstr(itsWindow,tmp.c_str());
tmp.clear();
if (IsValidColor(ToString(color)))
if (isdigit(color[2]))
{
int x, y;
getyx(itsWindow, y, x);
Coordinates coords = IntoCoordinates(ToString(color));
wmove(itsWindow, coords.second == -1 ? y : coords.second, coords.first);
limit -= coords.first-x;
}
else if (IsValidColor(ToString(color)))
{
ColorPair colors = IntoColor(ToString(color));
SetColor(colors.first, colors.second);
@@ -667,6 +685,23 @@ wstring ToWString(const string &s)
return result;
}
Coordinates Window::IntoCoordinates(const string &s)
{
Coordinates result;
unsigned int sep = s.find(",");
if (sep != string::npos)
{
result.first = atoi(s.substr(2, sep-2).c_str());
result.second = atoi(s.substr(sep+1).c_str());
}
else
{
result.first = atoi(s.substr(2).c_str());
result.second = -1;
}
return result;
}
string Window::OmitBBCodes(const string &str)
{
bool collect = false;