Implement terminal bell

This commit is contained in:
Keith Winstein
2012-01-31 17:53:20 -05:00
parent 24653462ce
commit cdf4c6b4b3
4 changed files with 16 additions and 5 deletions
+5
View File
@@ -12,6 +12,11 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
char tmp[ 64 ]; char tmp[ 64 ];
/* has bell been rung? */
if ( f.get_bell_count() != frame.last_frame.get_bell_count() ) {
frame.append( "\x07" );
}
/* has window title changed? */ /* has window title changed? */
if ( (!initialized) if ( (!initialized)
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) { || (f.get_window_title() != frame.last_frame.get_window_title()) ) {
+2 -1
View File
@@ -28,7 +28,7 @@ DrawState::DrawState( int s_width, int s_height )
} }
Framebuffer::Framebuffer( int s_width, int s_height ) Framebuffer::Framebuffer( int s_width, int s_height )
: rows( s_height, Row( s_width, 0 ) ), window_title(), ds( s_width, s_height ) : rows( s_height, Row( s_width, 0 ) ), window_title(), bell_count( 0 ), ds( s_width, s_height )
{ {
assert( s_height > 0 ); assert( s_height > 0 );
assert( s_width > 0 ); assert( s_width > 0 );
@@ -286,6 +286,7 @@ void Framebuffer::reset( void )
ds = DrawState( width, height ); ds = DrawState( width, height );
rows = std::deque<Row>( height, newrow() ); rows = std::deque<Row>( height, newrow() );
window_title.clear(); window_title.clear();
/* do not reset bell_count */
} }
void Framebuffer::soft_reset( void ) void Framebuffer::soft_reset( void )
+5 -1
View File
@@ -189,6 +189,7 @@ namespace Terminal {
private: private:
std::deque<Row> rows; std::deque<Row> rows;
std::deque<wchar_t> window_title; std::deque<wchar_t> window_title;
unsigned int bell_count;
Row newrow( void ) { return Row( ds.get_width(), ds.get_background_rendition() ); } Row newrow( void ) { return Row( ds.get_width(), ds.get_background_rendition() ); }
@@ -262,9 +263,12 @@ namespace Terminal {
void reset_cell( Cell *c ) { c->reset( ds.get_background_rendition() ); } void reset_cell( Cell *c ) { c->reset( ds.get_background_rendition() ); }
void reset_row( Row *r ) { r->reset( ds.get_background_rendition() ); } void reset_row( Row *r ) { r->reset( ds.get_background_rendition() ); }
void ring_bell( void ) { bell_count++; }
unsigned int get_bell_count( void ) const { return bell_count; }
bool operator==( const Framebuffer &x ) const bool operator==( const Framebuffer &x ) const
{ {
return ( rows == x.rows ) && ( window_title == x.window_title ) && ( ds == x.ds ); return ( rows == x.rows ) && ( window_title == x.window_title ) && ( bell_count == x.bell_count ) && ( ds == x.ds );
} }
}; };
} }
+4 -3
View File
@@ -303,9 +303,10 @@ void CSI_DECSTBM( Framebuffer *fb, Dispatcher *dispatch )
static Function func_CSI_DECSTMB( CSI, "r", CSI_DECSTBM ); static Function func_CSI_DECSTMB( CSI, "r", CSI_DECSTBM );
/* terminal bell -- ignored for now */ /* terminal bell */
void Ctrl_BEL( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch __attribute((unused)) ) void Ctrl_BEL( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) {
{} fb->ring_bell();
}
static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL ); static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL );