From: <at...@us...> - 2007-11-14 00:28:17
|
Revision: 544 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=544&view=rev Author: atani Date: 2007-11-13 16:28:15 -0800 (Tue, 13 Nov 2007) Log Message: ----------- enable/disable features for Console Modified Paths: -------------- tiki/examples/console/TikiSnake/src/snake.cpp tiki/examples/net/httpclient/src/main.cpp tiki/examples/sound/sfx/src/main.cpp tiki/include/Tiki/drawables/console.h tiki/src/gl/drawables/console.cpp Property Changed: ---------------- tiki/examples/events/ Modified: tiki/examples/console/TikiSnake/src/snake.cpp =================================================================== --- tiki/examples/console/TikiSnake/src/snake.cpp 2007-11-11 20:50:23 UTC (rev 543) +++ tiki/examples/console/TikiSnake/src/snake.cpp 2007-11-14 00:28:15 UTC (rev 544) @@ -79,8 +79,8 @@ ct->setSize(screenExtents.x, screenExtents.y); screenExtents *= 0.5f; ct->setTranslate(screenExtents); - ct->setAutoScroll( 0 ); - ct->setAutoWrap( 0 ); + ct->disable( AUTO_SCROLL ); + ct->disable( AUTO_WRAP ); //initialize the board for ( x = 0;x < BOARD_X;x++ ) { Property changes on: tiki/examples/events ___________________________________________________________________ Name: svn:ignore - Debug Release build *.user *.nds *.ds.gba + Debug Release build *.user *.nds *.ds.gba tikievents Modified: tiki/examples/net/httpclient/src/main.cpp =================================================================== --- tiki/examples/net/httpclient/src/main.cpp 2007-11-11 20:50:23 UTC (rev 543) +++ tiki/examples/net/httpclient/src/main.cpp 2007-11-14 00:28:15 UTC (rev 544) @@ -89,8 +89,8 @@ console->setSize(screenExtents.x, screenExtents.y); screenExtents *= 0.5f; console->setTranslate(screenExtents); - console->setAutoWrap( true ); - console->setAutoScroll( true ); + console->enable( AUTO_WRAP ); + console->enable( AUTO_SCROLL ); console->color( BLACK, GREY ); console->clear(); Modified: tiki/examples/sound/sfx/src/main.cpp =================================================================== --- tiki/examples/sound/sfx/src/main.cpp 2007-11-11 20:50:23 UTC (rev 543) +++ tiki/examples/sound/sfx/src/main.cpp 2007-11-14 00:28:15 UTC (rev 544) @@ -88,8 +88,8 @@ console->setSize(screenExtents.x, screenExtents.y); screenExtents *= 0.5f; console->setTranslate(screenExtents); - console->setAutoWrap( true ); - console->setAutoScroll( true ); + console->enable( AUTO_WRAP ); + console->enable( AUTO_SCROLL ); console->color( BLACK, GREY ); console->clear(); Modified: tiki/include/Tiki/drawables/console.h =================================================================== --- tiki/include/Tiki/drawables/console.h 2007-11-11 20:50:23 UTC (rev 543) +++ tiki/include/Tiki/drawables/console.h 2007-11-14 00:28:15 UTC (rev 544) @@ -40,6 +40,17 @@ INVISIBLE = 0xA000 }; + enum ConsoleFeatures { + BACKSPACE_PROCESSING = 0x0001, + NEWLINE_PROCESSING = 0x0002, + CARRIAGE_RETURN_PROCESSING = 0x0004, + CLEAR_SCREEN_PROCESSING = 0x0008, + ANSI_PROCESSING = 0x0010, + AUTO_SCROLL = 0x0020, + AUTO_WRAP = 0x0040, + AUTO_REFRESH = 0x0080 + }; + /** Console -- Console displays an array of fixed width characters. */ class Console : public Drawable { public: @@ -56,22 +67,20 @@ void scroll(int rows, int top, int left, int bottom, int right); void scroll(int rows); - void setAutoScroll(bool s) { - m_autoScroll = s; + void enable(int code) { + m_features |= code; } - void setAutoWrap(bool w) { - m_autoWrap = w; + void disable(int code) { + if(m_features & code) { + m_features ^= code; + } } - void setAutoRefresh(bool r) { - m_autoRefresh = r; + int getFeatures() { + return m_features; } - void setANSI(bool a) { - m_ansi = a; - } - char getChar(int x, int y) { assert(x<m_cols && y<m_rows); return m_charData[(y*m_cols) + x]; @@ -92,17 +101,17 @@ m_colorData[(y*m_cols) + x] = attr; } - int getRows() { - return m_rows; - } - - int getCols() { - return m_cols; + int getRows() { + return m_rows; } - - Tiki::Math::Vector getSize() const { - return Tiki::Math::Vector(m_w, m_h, 0.0f); + + int getCols() { + return m_cols; } + + Tiki::Math::Vector getSize() const { + return Tiki::Math::Vector(m_w, m_h, 0.0f); + } Console& operator <<(std::string input) { printf("%s",input.c_str()); @@ -153,8 +162,7 @@ private: RefPtr<Texture> m_texture; Color m_palette[8]; - bool m_autoScroll, m_autoWrap, m_autoRefresh; - bool m_ansi; + int m_features; int m_cursor_x, m_cursor_y; int m_save_x, m_save_y; int m_attr; Modified: tiki/src/gl/drawables/console.cpp =================================================================== --- tiki/src/gl/drawables/console.cpp 2007-11-11 20:50:23 UTC (rev 543) +++ tiki/src/gl/drawables/console.cpp 2007-11-14 00:28:15 UTC (rev 544) @@ -42,12 +42,11 @@ m_cursor_x = 0; m_cursor_y = 0; + + enable( BACKSPACE_PROCESSING | NEWLINE_PROCESSING | CARRIAGE_RETURN_PROCESSING ); + enable( AUTO_SCROLL ); + enable( AUTO_WRAP ); - m_autoScroll = true; - m_autoWrap = true; - m_ansi = false; - m_autoRefresh = false; - color( GREY, BLACK ); clear(); } @@ -80,7 +79,7 @@ m_cursor_y = 0; ansiptr = 0; - if ( m_autoRefresh ) + if ( m_features & AUTO_REFRESH ) refresh(); } @@ -105,7 +104,7 @@ } } - if ( m_autoRefresh ) + if ( m_features & AUTO_REFRESH ) refresh(); } @@ -160,7 +159,7 @@ processAnsiString(); } } - else if ( buf[ i ] == '\x1b' && m_ansi ) + else if ( buf[ i ] == '\x1b' && ( m_features & ANSI_PROCESSING ) ) { ansistr[ 0 ] = buf[ i ]; ansiptr = 1; @@ -186,18 +185,19 @@ m_cursor_x = 0; continue; } - else if ( buf[ i ] == 12 ) - { // funky old style clearscreen + else if ( buf[ i ] == 12 && ( m_features & CLEAR_SCREEN_PROCESSING ) ) + { + // funky old style clearscreen clear(); continue; } - if ( m_cursor_x >= m_cols && m_autoWrap ) + if ( m_cursor_x >= m_cols && ( m_features & AUTO_WRAP ) ) { m_cursor_y++; m_cursor_x = 0; } - if ( m_cursor_y >= m_rows && m_autoScroll ) + if ( m_cursor_y >= m_rows && ( m_features & AUTO_SCROLL ) ) { scroll( 1 ); m_cursor_y = m_rows - 1; @@ -213,7 +213,7 @@ } } - if ( m_autoRefresh ) + if ( m_features & AUTO_REFRESH ) refresh(); } @@ -540,8 +540,7 @@ BG_PALETTE_SUB[ ( 16 * 14 ) + 1 ] = RGB15( 31, 31, 0 ); BG_PALETTE_SUB[ ( 16 * 15 ) + 1 ] = RGB15( 31, 31, 31 ); - setANSI(true); - setAutoRefresh(true); + enable( ANSI_PROCESSING | AUTO_REFRESH ); } // use the following value to ensure the background is visible when rendered This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |