Correctly render on terminals without BCE (fixes #56 github issue)

This commit is contained in:
Keith Winstein
2012-03-16 13:17:28 -04:00
parent 57d97209c0
commit c896055d15
3 changed files with 22 additions and 4 deletions
+6 -2
View File
@@ -244,12 +244,15 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
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? */
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.x += clear_count;
} else {
if ( has_ech ) {
if ( has_ech && can_use_erase ) {
if ( clear_count == 1 ) {
frame.append( "\033[X" );
} else {
@@ -258,6 +261,7 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
}
frame.x += clear_count;
} else { /* no ECH, so just print a space */
/* unlike erases, this will use background color irrespective of BCE */
frame.append( " " );
frame.cursor_x++;
frame.x++;
+2
View File
@@ -52,6 +52,8 @@ namespace Terminal {
bool has_ech; /* erase character is part of vt200 but not supported by tmux
(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;
public:
+14 -2
View File
@@ -29,7 +29,7 @@
using namespace Terminal;
Display::Display( bool use_environment )
: has_ech( true )
: has_ech( true ), has_bce( true )
{
if ( use_environment ) {
int errret = -2;
@@ -52,12 +52,24 @@ Display::Display( bool use_environment )
}
}
/* check for ECH */
char ech_name[] = "ech";
char *val = tigetstr( ech_name );
if ( val == (char *)-1 )
if ( val == (char *)-1 ) {
throw std::string( "Invalid terminfo string capability " ) + ech_name;
}
if ( val == 0 ) {
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;
}
}
}