Skip to content

Commit

Permalink
Merge pull request AmokHuginnsson#22 from amosbird/improvebracketedpaste
Browse files Browse the repository at this point in the history
Improve bracketed paste
  • Loading branch information
alexey-milovidov authored Mar 23, 2022
2 parents 9460e5e + e70cb7c commit 6f0b6f1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/replxx_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2402,17 +2402,21 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::clear_screen( char32_t c ) {
}

Replxx::ACTION_RESULT Replxx::ReplxxImpl::bracketed_paste( char32_t ) {
static const UnicodeString BRACK_PASTE_SUFF( "\033[201~" );
static const int BRACK_PASTE_SLEN( BRACK_PASTE_SUFF.length() );
UnicodeString buf;
while ( char32_t c = _terminal.read_char() ) {
if ( c == KEY::PASTE_FINISH ) {
break;
}
while ( char32_t c = read_unicode_character() ) {
if ( ( c == '\r' ) || ( c == KEY::control( 'M' ) ) ) {
c = '\n';
} else if ( c == KEY::control( 'I' ) ) {
}
else if ( c == KEY::control( 'I' ) ) {
c = '\t';
}
buf.push_back( c );
if ( ( c == '~' ) && buf.ends_with( BRACK_PASTE_SUFF.begin(), BRACK_PASTE_SUFF.end() ) ) {
buf.erase( buf.length() - BRACK_PASTE_SLEN, BRACK_PASTE_SLEN );
break;
}
}
_data.insert( _pos, buf, 0, buf.length() );
_pos += buf.length();
Expand Down

0 comments on commit 6f0b6f1

Please sign in to comment.