some minor cleanup

This commit is contained in:
Wolfgang Thaller 2014-09-15 00:23:20 +02:00
parent dea5fa2a21
commit 02c92021ab
2 changed files with 22 additions and 43 deletions

View File

@ -79,7 +79,6 @@ void Console::ScrollUp(short n)
cursorY--;
std::copy(chars.begin() + cols, chars.end(), chars.begin());
std::fill(chars.end() - cols, chars.end(), ' ');
//Console::Draw();
RgnHandle rgn = NewRgn();
ScrollRect(&bounds, 0, -cellSizeY, rgn);
DisposeRgn(rgn);
@ -89,7 +88,6 @@ void Console::putch(char c)
{
PortSetter setport(consolePort);
//Debugger();
switch(c)
{
case '\r':
@ -131,23 +129,21 @@ std::string Console::ReadLine()
c = '\n';
if(c == '\b')
{
if(buffer.size())
{
cursorX--;
putch(' ');
cursorX--;
buffer.substr(0,buffer.size()-1);
buffer.resize(buffer.size()-1);
}
continue;
//c = 'X';
}
if(c == 127)
{
c = 'Y';
}
putch(c);
buffer += std::string(1,c);
buffer.append(1,c);
} while(c != '\n');
return buffer;
}

View File

@ -101,28 +101,9 @@ int main(int argc, char** argv)
__write_hook = &consolewrite;
__read_hook = &consoleread;
console.putch('x');
console.putch('a');
console.putch('b');
console.putch('c');
console.putch('a');
console.putch('a');
Console::currentInstance->putch('Y');
printf("Hello...\n");
console.putch('b');
console.putch('\n');
std::cout << "Hello, world.\n";
printf("Hello, world.\n");
console.putch('a');
Console::currentInstance->putch('Y');
std::cout << "Hello, world, again.\n";
/*std::cout << "X\n";
for(int i = 1; i <= 100; i++)
std::cout << "Hello, world: " << i << std::endl;
std::cout << std::flush;
std::cout << "Say something: " << std::flush;*/
printf("Say something: ");
fflush(stdout);
printf("You said: %s\n", console.ReadLine().c_str());
@ -136,15 +117,18 @@ int main(int argc, char** argv)
for(int i = 0; i < 5; i++)
{
//std::cout << "Exception speed test: " << std::flush;
printf("Exception speed test: "); fflush(stdout);
int n = i == 0 ? 1 : 100;
printf("Exception speed test (%3d iterations): ", n); fflush(stdout);
long start = TickCount();
for(int j = 0; j < n; j++)
{
try { foobar(); } catch(...) {}
long end = TickCount();
//std::cout << (end-start)*1000 / 60.0 << " ms\n";
printf("%g\n",(end-start)*1000 / 60.0);
}
//std::cout << "Click mouse 10 times...\n";
long end = TickCount();
printf("%g ms per throw/catch\n",(end-start)*1000 / 60.0 / n);
}
const int n = 3;
printf("Click mouse %d times...\n", n);
for(int i = 0; i < n; i++)
@ -153,7 +137,6 @@ int main(int argc, char** argv)
;
while(Button())
;
//std::cout << "Click #" << i + 1 << std::endl;
printf("Click #%d\n", i+1);
}
FlushEvents(everyEvent, 0);