Implement terminal bell
This commit is contained in:
@@ -12,6 +12,11 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
||||
|
||||
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? */
|
||||
if ( (!initialized)
|
||||
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) {
|
||||
|
||||
@@ -28,7 +28,7 @@ DrawState::DrawState( 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_width > 0 );
|
||||
@@ -286,6 +286,7 @@ void Framebuffer::reset( void )
|
||||
ds = DrawState( width, height );
|
||||
rows = std::deque<Row>( height, newrow() );
|
||||
window_title.clear();
|
||||
/* do not reset bell_count */
|
||||
}
|
||||
|
||||
void Framebuffer::soft_reset( void )
|
||||
|
||||
@@ -189,6 +189,7 @@ namespace Terminal {
|
||||
private:
|
||||
std::deque<Row> rows;
|
||||
std::deque<wchar_t> window_title;
|
||||
unsigned int bell_count;
|
||||
|
||||
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_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
|
||||
{
|
||||
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 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -303,9 +303,10 @@ void CSI_DECSTBM( Framebuffer *fb, Dispatcher *dispatch )
|
||||
|
||||
static Function func_CSI_DECSTMB( CSI, "r", CSI_DECSTBM );
|
||||
|
||||
/* terminal bell -- ignored for now */
|
||||
void Ctrl_BEL( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch __attribute((unused)) )
|
||||
{}
|
||||
/* terminal bell */
|
||||
void Ctrl_BEL( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) {
|
||||
fb->ring_bell();
|
||||
}
|
||||
|
||||
static Function func_Ctrl_BEL( CONTROL, "\x07", Ctrl_BEL );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user