Smarter cursor movement, and fix bug with recursive termemu
This commit is contained in:
+19
-5
@@ -46,6 +46,8 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
current_renditions.push_back( 0 );
|
current_renditions.push_back( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cursor_x = -1, cursor_y = -1;
|
||||||
|
|
||||||
/* iterate for every cell */
|
/* iterate for every cell */
|
||||||
for ( int y = 0; y < f.ds.get_height(); y++ ) {
|
for ( int y = 0; y < f.ds.get_height(); y++ ) {
|
||||||
for ( int x = 0; x < f.ds.get_width(); /* let charwidth handle advance */ ) {
|
for ( int x = 0; x < f.ds.get_width(); /* let charwidth handle advance */ ) {
|
||||||
@@ -57,10 +59,12 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char curmove[ 32 ];
|
if ( (x != cursor_x) || (y != cursor_y) ) {
|
||||||
snprintf( curmove, 32, "\033[%d;%dH", y + 1, x + 1 );
|
char curmove[ 32 ];
|
||||||
screen.append( curmove );
|
snprintf( curmove, 32, "\033[%d;%dH", y + 1, x + 1 );
|
||||||
cursor_was_moved = true;
|
screen.append( curmove );
|
||||||
|
cursor_was_moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<int> cell_print_renditions;
|
std::vector<int> cell_print_renditions;
|
||||||
cell_print_renditions = cell->renditions;
|
cell_print_renditions = cell->renditions;
|
||||||
@@ -82,7 +86,9 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* clear cell */
|
/* clear cell */
|
||||||
screen.append( "\033[X" );
|
if ( cell->contents.empty() ) {
|
||||||
|
screen.append( "\033[X" );
|
||||||
|
}
|
||||||
|
|
||||||
/* cells that begin with combining character get combiner attached to no-break space */
|
/* cells that begin with combining character get combiner attached to no-break space */
|
||||||
if ( cell->fallback ) {
|
if ( cell->fallback ) {
|
||||||
@@ -99,7 +105,15 @@ std::string Display::new_frame( Framebuffer &f )
|
|||||||
screen.append( utf8 );
|
screen.append( utf8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursor_x = x;
|
||||||
|
cursor_y = y;
|
||||||
|
|
||||||
x += cell->width;
|
x += cell->width;
|
||||||
|
|
||||||
|
if ( cell->contents.empty() ) {
|
||||||
|
} else {
|
||||||
|
cursor_x += cell->width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user