diff --git a/App2/Console.cc b/App2/Console.cc index 0e8558d670..ab534aefaa 100644 --- a/App2/Console.cc +++ b/App2/Console.cc @@ -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': @@ -132,22 +130,20 @@ std::string Console::ReadLine() if(c == '\b') { - cursorX--; - putch(' '); - cursorX--; - - buffer.substr(0,buffer.size()-1); - + if(buffer.size()) + { + cursorX--; + putch(' '); + cursorX--; + + 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; } diff --git a/App2/test.cc b/App2/test.cc index bf2d9fd515..1db3c9732c 100644 --- a/App2/test.cc +++ b/App2/test.cc @@ -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 << "X\n"; - for(int i = 1; i <= 100; i++) - std::cout << "Hello, world: " << i << std::endl; - std::cout << std::flush; + std::cout << "Hello, world, again.\n"; - 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(); - try { foobar(); } catch(...) {} - long end = TickCount(); - //std::cout << (end-start)*1000 / 60.0 << " ms\n"; - printf("%g\n",(end-start)*1000 / 60.0); + for(int j = 0; j < n; j++) + { + try { foobar(); } catch(...) {} + } + long end = TickCount(); + + printf("%g ms per throw/catch\n",(end-start)*1000 / 60.0 / n); } - //std::cout << "Click mouse 10 times...\n"; + const int n = 3; printf("Click mouse %d times...\n", n); for(int i = 0; i < n; i++) @@ -153,8 +137,7 @@ int main(int argc, char** argv) ; while(Button()) ; - //std::cout << "Click #" << i + 1 << std::endl; - printf("Click #%d\n", i+1); + printf("Click #%d\n", i+1); } FlushEvents(everyEvent, 0); return 0;