WORD _ReadBuf(char *Buffer, WORD Count) { unsigned char Ch; WORD I; I = 0; do { Ch = _ReadKey(); if (Ch == 8) { if (I > 0) { --I; _WriteChar(8); } } else if (Ch >= 32) { if (I < Count) { Buffer[I++] = Ch; _WriteChar(Ch); } } } while (!((Ch == 13) || (_CheckEOF && (Ch == 26)))); if (I < Count - 2) { Buffer[I++] = Ch; if (Ch == 13) { Buffer[I++] = 10; _WriteChar(13); } } _TrackCursor(); return I; }
void TextDrawer::WritePixel(const std::string &crStr, const Square &tArea) { EXPECT_TRUE(std::get<2>(tArea) > 0); EXPECT_TRUE(std::get<3>(tArea) > 0); const ulong ulXStart = std::get<0>(tArea); const ulong ulYStart = std::get<1>(tArea); const ulong nColumns = std::get<2>(tArea) / FONT_WIDTH; const ulong nLines = std::get<3>(tArea) / FONT_HEIGHT; std::vector<std::string> atLines = SplitToLines(crStr, nColumns); for (ulong i=0; i<std::min((size_t)nLines, atLines.size()); ++i) { const std::string &crtLine = atLines.at(i); for (ulong j=0; j<crtLine.size(); ++j) { _WriteChar(crtLine.at(j), ulXStart + j*FONT_WIDTH, ulYStart + i*FONT_HEIGHT); } } }
int putch(int c) { _WriteChar(c); return c; }
int getche(void) { int c = _ReadKey(); _WriteChar(c); return c; }