Correctly render on terminals without BCE (fixes #56 github issue)
This commit is contained in:
@@ -244,12 +244,15 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
|
|||||||
|
|
||||||
assert( frame.x + clear_count <= f.ds.get_width() );
|
assert( frame.x + clear_count <= f.ds.get_width() );
|
||||||
|
|
||||||
|
bool can_use_erase = has_bce || (cell->renditions == initial_rendition());
|
||||||
|
|
||||||
/* can we go to the end of the line? */
|
/* can we go to the end of the line? */
|
||||||
if ( frame.x + clear_count == f.ds.get_width() ) {
|
if ( (frame.x + clear_count == f.ds.get_width())
|
||||||
|
&& can_use_erase ) {
|
||||||
frame.append( "\033[K" );
|
frame.append( "\033[K" );
|
||||||
frame.x += clear_count;
|
frame.x += clear_count;
|
||||||
} else {
|
} else {
|
||||||
if ( has_ech ) {
|
if ( has_ech && can_use_erase ) {
|
||||||
if ( clear_count == 1 ) {
|
if ( clear_count == 1 ) {
|
||||||
frame.append( "\033[X" );
|
frame.append( "\033[X" );
|
||||||
} else {
|
} else {
|
||||||
@@ -258,6 +261,7 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
|
|||||||
}
|
}
|
||||||
frame.x += clear_count;
|
frame.x += clear_count;
|
||||||
} else { /* no ECH, so just print a space */
|
} else { /* no ECH, so just print a space */
|
||||||
|
/* unlike erases, this will use background color irrespective of BCE */
|
||||||
frame.append( " " );
|
frame.append( " " );
|
||||||
frame.cursor_x++;
|
frame.cursor_x++;
|
||||||
frame.x++;
|
frame.x++;
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ namespace Terminal {
|
|||||||
bool has_ech; /* erase character is part of vt200 but not supported by tmux
|
bool has_ech; /* erase character is part of vt200 but not supported by tmux
|
||||||
(or by "screen" terminfo entry, which is what tmux advertises) */
|
(or by "screen" terminfo entry, which is what tmux advertises) */
|
||||||
|
|
||||||
|
bool has_bce; /* erases result in cell filled with background color */
|
||||||
|
|
||||||
void put_cell( bool initialized, FrameState &frame, const Framebuffer &f ) const;
|
void put_cell( bool initialized, FrameState &frame, const Framebuffer &f ) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
using namespace Terminal;
|
using namespace Terminal;
|
||||||
|
|
||||||
Display::Display( bool use_environment )
|
Display::Display( bool use_environment )
|
||||||
: has_ech( true )
|
: has_ech( true ), has_bce( true )
|
||||||
{
|
{
|
||||||
if ( use_environment ) {
|
if ( use_environment ) {
|
||||||
int errret = -2;
|
int errret = -2;
|
||||||
@@ -52,12 +52,24 @@ Display::Display( bool use_environment )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for ECH */
|
||||||
char ech_name[] = "ech";
|
char ech_name[] = "ech";
|
||||||
char *val = tigetstr( ech_name );
|
char *val = tigetstr( ech_name );
|
||||||
if ( val == (char *)-1 )
|
if ( val == (char *)-1 ) {
|
||||||
throw std::string( "Invalid terminfo string capability " ) + ech_name;
|
throw std::string( "Invalid terminfo string capability " ) + ech_name;
|
||||||
|
}
|
||||||
if ( val == 0 ) {
|
if ( val == 0 ) {
|
||||||
has_ech = false;
|
has_ech = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for BCE */
|
||||||
|
char bce_name[] = "bce";
|
||||||
|
int bce_val = tigetflag( bce_name );
|
||||||
|
if ( bce_val == -1 ) {
|
||||||
|
throw std::string( "Invalid terminfo boolean capability " ) + bce_name;
|
||||||
|
}
|
||||||
|
if ( bce_val == 0 ) {
|
||||||
|
has_bce = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user