Optional verifier for round-trippability, and fix wrapping and tab bugs.
This commit is contained in:
@@ -193,20 +193,22 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
||||
frame.x < f.ds.get_width(); /* let put_cell() handle advance */ ) {
|
||||
last_x = frame.x;
|
||||
put_cell( initialized, frame, f );
|
||||
}
|
||||
|
||||
/* To hint that a word-select should group the end of one line
|
||||
with the beginning of the next, we let the real cursor
|
||||
actually wrap around in cases where it wrapped around for us. */
|
||||
/* To hint that a word-select should group the end of one line
|
||||
with the beginning of the next, we let the real cursor
|
||||
actually wrap around in cases where it wrapped around for us. */
|
||||
|
||||
if ( (frame.cursor_x >= f.ds.get_width())
|
||||
&& (frame.y < f.ds.get_height() - 1)
|
||||
&& f.get_row( frame.y )->get_wrap()
|
||||
&& (!initialized || !frame.last_frame.get_row( frame.y )->get_wrap()) ) {
|
||||
/* next write will wrap */
|
||||
frame.cursor_x = 0;
|
||||
frame.cursor_y++;
|
||||
frame.force_next_put = true;
|
||||
}
|
||||
if ( (frame.y < f.ds.get_height() - 1)
|
||||
&& f.get_row( frame.y )->get_wrap() ) {
|
||||
frame.x = last_x;
|
||||
frame.force_next_put = true;
|
||||
put_cell( initialized, frame, f );
|
||||
|
||||
/* next write will wrap */
|
||||
frame.cursor_x = 0;
|
||||
frame.cursor_y++;
|
||||
frame.force_next_put = true;
|
||||
}
|
||||
|
||||
/* Turn off wrap */
|
||||
@@ -301,8 +303,10 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
|
||||
|
||||
if ( frame.force_next_put ) {
|
||||
frame.append( " " );
|
||||
frame.append_silent_move( frame.y, frame.x );
|
||||
frame.cursor_x++;
|
||||
frame.x++;
|
||||
frame.force_next_put = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* can we go to the end of the line? */
|
||||
|
||||
@@ -366,7 +366,7 @@ void DrawState::resize( int s_width, int s_height )
|
||||
|
||||
snap_cursor_to_border();
|
||||
|
||||
tabs.resize( width );
|
||||
tabs.clear();
|
||||
|
||||
/* saved cursor will be snapped to border on restore */
|
||||
|
||||
@@ -482,11 +482,6 @@ std::string Renditions::sgr( void ) const
|
||||
|
||||
/* Reduce 256 "standard" colors to the 8 ANSI colors. */
|
||||
|
||||
/* We could do something fancy like find the nearest system color in
|
||||
the deltaE(2000) sense, but for "business graphics," the colorimetric
|
||||
intent is probably less important than just having separate colors
|
||||
be separate as much as possible. */
|
||||
|
||||
/* Terminal emulators generally agree on the (R',G',B') values of the
|
||||
"standard" 256-color pallette beyond #15, but for the first 16
|
||||
colors there is disagreement. Most terminal emulators are roughly
|
||||
@@ -573,3 +568,40 @@ wchar_t Cell::debug_contents( void ) const
|
||||
return contents.front();
|
||||
}
|
||||
}
|
||||
|
||||
bool Cell::compare( const Cell &other ) const
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if ( !contents_match( other ) ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "Contents: %lc vs. %lc\n",
|
||||
debug_contents(), other.debug_contents() );
|
||||
}
|
||||
|
||||
if ( fallback != other.fallback ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "fallback: %d vs. %d\n",
|
||||
fallback, other.fallback );
|
||||
}
|
||||
|
||||
if ( width != other.width ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "width: %d vs. %d\n",
|
||||
width, other.width );
|
||||
}
|
||||
|
||||
if ( !(renditions == other.renditions) ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "renditions: %s vs. %s\n",
|
||||
renditions.sgr().c_str(), other.renditions.sgr().c_str() );
|
||||
}
|
||||
|
||||
if ( wrap != other.wrap ) {
|
||||
ret = true;
|
||||
fprintf( stderr, "wrap: %d vs. %d\n",
|
||||
wrap, other.wrap );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace Terminal {
|
||||
return ( is_blank() && other.is_blank() )
|
||||
|| ( contents == other.contents );
|
||||
}
|
||||
|
||||
bool compare( const Cell &other ) const;
|
||||
};
|
||||
|
||||
class Row {
|
||||
|
||||
Reference in New Issue
Block a user