Bring some sanity to renditions (rationalize list on append)
This commit is contained in:
+2
-1
@@ -21,4 +21,5 @@ template class vector<wchar_t>;
|
||||
template class vector<int>;
|
||||
template class map<string, Function>;
|
||||
template class vector<bool>;
|
||||
|
||||
template class list<int>;
|
||||
template void std::list<int, std::allocator<int> >::remove_if<bool (*)(int const&)>(bool (*)(int const&));
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ void Emulator::debug_printout( int fd )
|
||||
/* print renditions */
|
||||
screen.append( "\033[0" );
|
||||
char rendition[ 32 ];
|
||||
for ( std::vector<int>::iterator i = cell->renditions.begin();
|
||||
for ( std::list<int>::iterator i = cell->renditions.begin();
|
||||
i != cell->renditions.end();
|
||||
i++ ) {
|
||||
snprintf( rendition, 32, ";%d", *i );
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Terminal {
|
||||
private:
|
||||
bool initialized;
|
||||
Framebuffer last_frame;
|
||||
std::vector<int> current_renditions;
|
||||
std::list<int> current_renditions;
|
||||
|
||||
public:
|
||||
Display( int width, int height )
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ std::string Display::new_frame( Framebuffer &f )
|
||||
cursor_was_moved = true;
|
||||
}
|
||||
|
||||
std::vector<int> cell_print_renditions;
|
||||
std::list<int> cell_print_renditions;
|
||||
cell_print_renditions = cell->renditions;
|
||||
cell_print_renditions.insert( cell_print_renditions.begin(), 0 );
|
||||
|
||||
@@ -74,7 +74,7 @@ std::string Display::new_frame( Framebuffer &f )
|
||||
/* print renditions */
|
||||
screen.append( "\033[0" );
|
||||
char rendition[ 32 ];
|
||||
for ( std::vector<int>::iterator i = cell->renditions.begin();
|
||||
for ( std::list<int>::iterator i = cell->renditions.begin();
|
||||
i != cell->renditions.end();
|
||||
i++ ) {
|
||||
snprintf( rendition, 32, ";%d", *i );
|
||||
|
||||
+29
-2
@@ -407,11 +407,11 @@ void DrawState::resize( int s_width, int s_height )
|
||||
int DrawState::get_background_rendition( void )
|
||||
{
|
||||
int color = -1;
|
||||
for ( std::vector<int>::iterator i = renditions.begin();
|
||||
for ( std::list<int>::iterator i = renditions.begin();
|
||||
i != renditions.end();
|
||||
i++ ) {
|
||||
int r = *i;
|
||||
if ( (40 <= r) && (r <= 47) ) {
|
||||
if ( (40 <= r) && (r <= 49) ) {
|
||||
color = r;
|
||||
}
|
||||
}
|
||||
@@ -436,3 +436,30 @@ void Framebuffer::back_color_erase( void )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool fg_colorval( const int &x ) { return (30 <= x) && (x <= 39); }
|
||||
static bool bg_colorval( const int &x ) { return (40 <= x) && (x <= 49); }
|
||||
|
||||
void DrawState::add_rendition( int x )
|
||||
{
|
||||
/* Filter out older renditions that we know
|
||||
will now be reset */
|
||||
|
||||
renditions.remove( x );
|
||||
|
||||
switch ( x ) {
|
||||
case 1: case 22: renditions.remove( 1 ); renditions.remove( 22 ); break; /* bold */
|
||||
case 4: case 24: renditions.remove( 4 ); renditions.remove( 24 ); break; /* underlined */
|
||||
case 5: case 25: renditions.remove( 5 ); renditions.remove( 25 ); break; /* blink */
|
||||
case 7: case 27: renditions.remove( 7 ); renditions.remove( 27 ); break; /* inverse */
|
||||
case 8: case 28: renditions.remove( 8 ); renditions.remove( 28 ); break; /* invisible */
|
||||
}
|
||||
|
||||
if ( (30 <= x) && (x <= 39) ) { /* foreground color */
|
||||
renditions.remove_if( fg_colorval );
|
||||
} else if ( (40 <= x) && (x <= 49) ) { /* background color */
|
||||
renditions.remove_if( bg_colorval );
|
||||
}
|
||||
|
||||
renditions.push_back( x );
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
/* Terminal framebuffer */
|
||||
|
||||
@@ -13,7 +14,7 @@ namespace Terminal {
|
||||
std::vector<wchar_t> contents;
|
||||
char fallback; /* first character is combining character */
|
||||
int width;
|
||||
std::vector<int> renditions; /* e.g., bold, blinking, etc. */
|
||||
std::list<int> renditions; /* e.g., bold, blinking, etc. */
|
||||
bool need_back_color_erase;
|
||||
|
||||
Cell();
|
||||
@@ -36,7 +37,7 @@ namespace Terminal {
|
||||
class SavedCursor {
|
||||
public:
|
||||
int cursor_col, cursor_row;
|
||||
std::vector<int> renditions;
|
||||
std::list<int> renditions;
|
||||
/* character set shift state */
|
||||
bool auto_wrap_mode;
|
||||
bool origin_mode;
|
||||
@@ -59,7 +60,7 @@ namespace Terminal {
|
||||
|
||||
int scrolling_region_top_row, scrolling_region_bottom_row;
|
||||
|
||||
std::vector<int> renditions;
|
||||
std::list<int> renditions;
|
||||
|
||||
SavedCursor save;
|
||||
|
||||
@@ -100,8 +101,8 @@ namespace Terminal {
|
||||
int limit_bottom( void );
|
||||
|
||||
void clear_renditions( void ) { renditions.clear(); }
|
||||
void add_rendition( int x ) { renditions.push_back( x ); }
|
||||
const std::vector<int> get_renditions( void ) { return renditions; }
|
||||
void add_rendition( int x );
|
||||
const std::list<int> get_renditions( void ) { return renditions; }
|
||||
int get_background_rendition( void );
|
||||
|
||||
void save_cursor( void );
|
||||
|
||||
Reference in New Issue
Block a user