Search code examples
c++command-line-tool

How exit from replxx using Ctrl+C


I use replxx as modern command-line tool. I found example but in this example Ctrl+C means about to edit current line of text. But I want Ctrl+C to finish application.

Looks like I should change code. Default behavior (abort current editing) is not what I want...

rx.bind_key_internal( Replxx::KEY::control( 'C' ),                 "abort_line" );

Solution

  • Instead of this code

    rx.bind_key_internal( Replxx::KEY::control( 'C' ), "abort_line" );

    Use this code

    Replxx::key_press_handler_t mySigIntHandler= [](char32_t code){
        return Replxx::ACTION_RESULT::BAIL;
    };
    rx.bind_key( Replxx::KEY::control( 'C' ), mySigIntHandler);