diff --git a/terminaldisplay.cpp b/terminaldisplay.cpp index 18abe0c..3faa062 100644 --- a/terminaldisplay.cpp +++ b/terminaldisplay.cpp @@ -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()) ) { diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index 8500bd8..30a0067 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -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( height, newrow() ); window_title.clear(); + /* do not reset bell_count */ } void Framebuffer::soft_reset( void ) diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 4eacd37..6c564e0 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -189,6 +189,7 @@ namespace Terminal { private: std::deque rows; std::deque 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 ); } }; } diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index 1128ef5..77ff531 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -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 );