@@ -188,6 +188,7 @@ Replxx::ReplxxImpl::ReplxxImpl( std::istream & in_, std::ostream & out_, int in_
188188 , _namedActions()
189189 , _editingMode( 0 )
190190 , _keyPressHandlers()
191+ , _defaultKeyPressHandlers()
191192 , _terminal(in_fd_, out_fd_)
192193 , _currentThread()
193194 , _prompt( _terminal )
@@ -465,6 +466,10 @@ void Replxx::ReplxxImpl::bind_key( char32_t code_, Replxx::key_press_handler_t h
465466 _keyPressHandlers[editingMode_][code_] = handler_;
466467}
467468
469+ void Replxx::ReplxxImpl::bind_default_key ( Replxx::key_press_handler_t handler_, int editingMode_ ) {
470+ _defaultKeyPressHandlers[editingMode_] = handler_;
471+ }
472+
468473void Replxx::ReplxxImpl::bind_key_internal ( char32_t code_, char const * actionName_, int editingMode_ ) {
469474 named_actions_t ::const_iterator it ( _namedActions.find ( actionName_ ) );
470475 if ( it == _namedActions.end () ) {
@@ -1494,9 +1499,18 @@ int Replxx::ReplxxImpl::get_input_line( void ) {
14941499 continue ;
14951500 }
14961501
1502+ Replxx::key_press_handler_t * handler ( nullptr );
14971503 key_press_handlers_t ::iterator it ( _keyPressHandlers[_editingMode].find ( c ) );
14981504 if ( it != _keyPressHandlers[_editingMode].end () ) {
1499- next = it->second ( c );
1505+ handler = &it->second ;
1506+ } else {
1507+ key_press_handlers_t ::iterator dit ( _defaultKeyPressHandlers.find ( _editingMode ) );
1508+ if ( dit != _defaultKeyPressHandlers.end () ) {
1509+ handler = &dit->second ;
1510+ }
1511+ }
1512+ if ( handler ) {
1513+ next = ( *handler )( c );
15001514 if ( _modifiedState ) {
15011515 refresh_line ();
15021516 } else if ( _moveCursor ) {
0 commit comments