Scroll only scrolled region (fixes #31 github issue)
This commit is contained in:
@@ -69,6 +69,11 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
|||||||
if ( (!initialized)
|
if ( (!initialized)
|
||||||
|| (f.ds.get_width() != frame.last_frame.ds.get_width())
|
|| (f.ds.get_width() != frame.last_frame.ds.get_width())
|
||||||
|| (f.ds.get_height() != frame.last_frame.ds.get_height()) ) {
|
|| (f.ds.get_height() != frame.last_frame.ds.get_height()) ) {
|
||||||
|
/* reset scrolling region */
|
||||||
|
snprintf( tmp, 64, "\033[%d;%dr",
|
||||||
|
1, f.ds.get_height() );
|
||||||
|
frame.append( tmp );
|
||||||
|
|
||||||
/* clear screen */
|
/* clear screen */
|
||||||
frame.append( "\033[0m\033[H\033[2J" );
|
frame.append( "\033[0m\033[H\033[2J" );
|
||||||
initialized = false;
|
initialized = false;
|
||||||
@@ -113,26 +118,45 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
|||||||
frame.y = scroll_height;
|
frame.y = scroll_height;
|
||||||
|
|
||||||
if ( lines_scrolled ) {
|
if ( lines_scrolled ) {
|
||||||
if ( frame.cursor_y != f.ds.get_height() - 1 ) {
|
|
||||||
frame.append_silent_move( f.ds.get_height() - 1, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !(frame.current_rendition == initial_rendition()) ) {
|
if ( !(frame.current_rendition == initial_rendition()) ) {
|
||||||
frame.append( "\033[0m" );
|
frame.append( "\033[0m" );
|
||||||
frame.current_rendition = initial_rendition();
|
frame.current_rendition = initial_rendition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int top_margin = 0;
|
||||||
|
int bottom_margin = top_margin + lines_scrolled + scroll_height - 1;
|
||||||
|
|
||||||
|
assert( bottom_margin < f.ds.get_height() );
|
||||||
|
|
||||||
|
/* set scrolling region */
|
||||||
|
snprintf( tmp, 64, "\033[%d;%dr",
|
||||||
|
top_margin + 1, bottom_margin + 1);
|
||||||
|
frame.append( tmp );
|
||||||
|
|
||||||
|
/* go to bottom of scrolling region */
|
||||||
|
frame.append_silent_move( bottom_margin, 0 );
|
||||||
|
|
||||||
|
/* scroll */
|
||||||
for ( int i = 0; i < lines_scrolled; i++ ) {
|
for ( int i = 0; i < lines_scrolled; i++ ) {
|
||||||
frame.append( "\n" );
|
frame.append( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < f.ds.get_height(); i++ ) {
|
/* do the move in memory */
|
||||||
if ( i + lines_scrolled < f.ds.get_height() ) {
|
for ( int i = top_margin; i <= bottom_margin; i++ ) {
|
||||||
|
if ( i + lines_scrolled <= bottom_margin ) {
|
||||||
*(frame.last_frame.get_mutable_row( i )) = *(frame.last_frame.get_row( i + lines_scrolled ));
|
*(frame.last_frame.get_mutable_row( i )) = *(frame.last_frame.get_row( i + lines_scrolled ));
|
||||||
} else {
|
} else {
|
||||||
frame.last_frame.get_mutable_row( i )->reset( 0 );
|
frame.last_frame.get_mutable_row( i )->reset( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reset scrolling region */
|
||||||
|
snprintf( tmp, 64, "\033[%d;%dr",
|
||||||
|
1, f.ds.get_height() );
|
||||||
|
frame.append( tmp );
|
||||||
|
|
||||||
|
/* make sure we know cursor position after scrolling region reset */
|
||||||
|
frame.append_silent_move( 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user