PIScreen windows optimization, expanded pisd copy dialog

git-svn-id: svn://db.shs.com.ru/pip@90 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-11 14:13:03 +00:00
parent b82453d845
commit 493d8ba0c7
8 changed files with 151 additions and 43 deletions

View File

@@ -162,14 +162,11 @@ void PIScreen::SystemConsole::resize(int w, int h) {
pcells[i].resize(width, Cell(0));
}
#ifdef WINDOWS
PRIVATE->bs.X = width;
PRIVATE->bs.Y = height;
PRIVATE->sbi.srWindow = PRIVATE->csbi.srWindow;
PRIVATE->chars.resize(width * height);
#else
#endif
for (int i = 0; i < pcells.size_s(); ++i)
pcells[i].fill(Cell());
#endif
clear();
clearScreen();
}
@@ -177,16 +174,44 @@ void PIScreen::SystemConsole::resize(int w, int h) {
void PIScreen::SystemConsole::print() {
#ifdef WINDOWS
static int cnt = 0;
for (int i = 0; i < width; ++i)
for (int j = 0; j < height; ++j) {
int k = j * width + i;
Cell & c(cells[j][i]);
//static int cnt = 0;
PRIVATE->srect = PRIVATE->sbi.srWindow;
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
for (int j = 0; j < height; ++j) {
PIVector<Cell> & ccv(cells[j]);
PIVector<Cell> & pcv(pcells[j]);
for (int i = 0; i < width; ++i)
if (ccv[i] != pcv[i]) {
if (dx0 < 0) {
dx0 = dx1 = i;
dy0 = dy1 = j;
} else {
dx0 = piMini(dx0, i);
dx1 = piMaxi(dx1, i);
dy0 = piMini(dy0, j);
dy1 = piMaxi(dy1, j);
}
}
}
if (dx0 < 0) return;
int dw = dx1 - dx0 + 1, dh = dy1 - dy0 + 1;
for (int i = 0; i < dw; ++i)
for (int j = 0; j < dh; ++j) {
int k = j * dw + i;
Cell & c(cells[j + dy0][i + dx0]);
PRIVATE->chars[k].Char.UnicodeChar = 0;
PRIVATE->chars[k].Char.AsciiChar = c.symbol.toAscii();
PRIVATE->chars[k].Attributes = attributes(c);
}
PRIVATE->srect = PRIVATE->sbi.srWindow;
//PRIVATE->bc.X = dx0;
//PRIVATE->bc.Y = dy0;
//piCout << "draw" << dw << dh;
PRIVATE->bs.X = dw;
PRIVATE->bs.Y = dh;
PRIVATE->srect.Left += dx0;
PRIVATE->srect.Top += dy0;
PRIVATE->srect.Right -= width - dx1 - 1;
PRIVATE->srect.Bottom -= height - dy1 - 1;
WriteConsoleOutput(PRIVATE->hOut, PRIVATE->chars.data(), PRIVATE->bs, PRIVATE->bc, &PRIVATE->srect);
#else
PIString s;
@@ -226,11 +251,10 @@ void PIScreen::SystemConsole::print() {
printf("%s", (formatString(cells[j][i]) + cells[j][i].symbol).data());
}*/
}
for (int i = 0; i < height; ++i)
pcells[i] = cells[i];
printf("\e[0m");
fflush(0);
#endif
pcells = cells;
}

View File

@@ -159,6 +159,18 @@ PITime PITime::current() {
}
PITime PITime::fromSystemTime(const PISystemTime & st) {
double s = st.toSeconds();
int v = s;
PITime ret;
ret.milliseconds = (s - v) * 1000;
ret.seconds = v % 60; v = (v - ret.seconds) / 60;
ret.minutes = v % 60; v = (v - ret.minutes) / 60;
ret.hours = v;
return ret;
}
PIDate PIDate::current() {
time_t rt = ::time(0);
tm * pt = localtime(&rt);

View File

@@ -190,6 +190,7 @@ struct PIP_EXPORT PITime {
int milliseconds;
PIString toString(const PIString & format = "h:mm:ss") const;
static PITime current();
static PITime fromSystemTime(const PISystemTime & st);
};
PIP_EXPORT bool operator ==(const PITime & t0, const PITime & t1);
PIP_EXPORT bool operator <(const PITime & t0, const PITime & t1);

View File

@@ -48,9 +48,9 @@ PIPeer::PeerData::~PeerData() {
void PIPeer::PeerData::dtThread() {
piCoutObj << "send DT ...";
//piCoutObj << "send DT ...";
dt_out.send(data);
piCoutObj << "send DT done";
//piCoutObj << "send DT done";
}
@@ -68,7 +68,7 @@ void PIPeer::PeerData::receivedPacket(uchar type, const PIByteArray & d) {
dt = &dt_in;
if (type == 2)
dt = &dt_out;
piCoutObj << "DT received" << int(type) << d.size_s();
//piCoutObj << "DT received" << int(type) << d.size_s();
if (dt) dt->received(d);
}
@@ -335,7 +335,7 @@ bool PIPeer::sendInternal(const PIString & to, const PIByteArray & data) {
}
PIByteArray ba;
ba << int(4) << self_info.name << to << int(0) << data;
piCoutObj << "sendInternal" << to << data.size_s() << int(data.front());
//piCoutObj << "sendInternal" << to << data.size_s() << int(data.front());
if (!sendToNeighbour(dp, ba)) return false;
return true;
}