00001 #ifdef DEBUG 00002 #include "debug_ctrl.h" 00003 #include <ncurses.h> 00004 00005 namespace crs { 00006 00007 debug_ctrl::debug_ctrl( cursive &ocrs ): 00008 focused_ctrl( ocrs.getScreen(), 0, 0, ocrs.getScreen()->height - 3, ocrs.getScreen()->width, 3 ) { 00009 upperWin = new base_control( ocrs.getScreen(), 0, 0, 0, 00010 ocrs.getScreen()->width, ocrs.getScreen()->height - 3 ); 00011 upperWin->visible = true; 00012 debug_file = new std::ofstream( "debug" ); 00013 current = strings.end(); 00014 } 00015 00016 debug_ctrl::~debug_ctrl() { 00017 delete debug_file; 00018 delete upperWin; 00019 } 00020 00021 void debug_ctrl::draw() { 00022 buffer.drawHLine( 13, 0, mWidth, sc::HorizontalLine ); 00023 buffer.putPixel( 0, 0, sc::HorizontalLine ); 00024 setText( "Debug Control", 1, 0 ); 00025 buffer.fillRect( 0, 1, mWidth, mHeight - 1, ' ' ); 00026 if( current != strings.end() ) 00027 setText( *current, 1, 1 ); 00028 } 00029 00030 void debug_ctrl::setDebugStr( std::string text ) { 00031 *debug_file << text << "\n"; 00032 current = strings.insert( strings.end(), text ); 00033 } 00034 00035 void debug_ctrl::doMove( const position &old_pos, const position &new_pos ) { 00036 base_control::doMove( old_pos, new_pos ); 00037 *debug_file << "moving from " << old_pos.x << "," << old_pos.y << " to " << new_pos.x << "," << new_pos.y << "\n"; 00038 } 00039 00040 base_control *debug_ctrl::getUpperWin() { 00041 return upperWin; 00042 } 00043 00044 bool debug_ctrl::keyPress( const int key ) { 00045 switch( key ) { 00046 case KEY_NPAGE: 00047 if( current != strings.end() ) 00048 current++; 00049 break; 00050 case KEY_PPAGE: 00051 if( current != strings.begin() ) 00052 current--; 00053 break; 00054 case 'u': 00055 upperWin->visible = !(upperWin->visible); 00056 break; 00057 } 00058 return true; 00059 } 00060 00061 } 00062 00063 #endif