Fix cursor glitch and more debugging info
This commit is contained in:
+24
-22
@@ -56,7 +56,7 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case deletion */
|
/* special case deletion */
|
||||||
if ( current.contents.empty() && (replacement.contents.size() == 1) && (replacement.contents.front() == 0x20) ) {
|
if ( replacement.contents.empty() && (current.contents.size() == 1) && (current.contents.front() == 0x20) ) {
|
||||||
return Correct;
|
return Correct;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row, u
|
|||||||
Validity ConditionalCursorMove::get_validity( const Framebuffer &fb, uint64_t current_frame ) const
|
Validity ConditionalCursorMove::get_validity( const Framebuffer &fb, uint64_t current_frame ) const
|
||||||
{
|
{
|
||||||
if ( !active ) {
|
if ( !active ) {
|
||||||
|
assert( !show_frozen_cursor );
|
||||||
return Inactive;
|
return Inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,9 +86,8 @@ Validity ConditionalCursorMove::get_validity( const Framebuffer &fb, uint64_t cu
|
|||||||
} else if ( current_frame < expiration_frame ) {
|
} else if ( current_frame < expiration_frame ) {
|
||||||
return Pending;
|
return Pending;
|
||||||
} else {
|
} else {
|
||||||
|
fprintf( stderr, "Bad cursor in %d (I thought (%d,%d) vs actual (%d,%d)).\n", (int)current_frame,
|
||||||
fprintf( stderr, "Bad cursor in %d (i thought %d vs %d).\n", (int)current_frame,
|
row, col, fb.ds.get_cursor_row(), fb.ds.get_cursor_col() );
|
||||||
col, fb.ds.get_cursor_col() );
|
|
||||||
return IncorrectOrExpired;
|
return IncorrectOrExpired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,25 +309,25 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
|||||||
switch ( j->get_validity( fb, i->row_num, local_frame_acked ) ) {
|
switch ( j->get_validity( fb, i->row_num, local_frame_acked ) ) {
|
||||||
case IncorrectOrExpired:
|
case IncorrectOrExpired:
|
||||||
if ( j->tentative ) {
|
if ( j->tentative ) {
|
||||||
fprintf( stderr, "Bad tentative prediction in row %d, col %d (thought %lc, was %lc)\n",
|
fprintf( stderr, "Bad tentative prediction in row %d, col %d\n",
|
||||||
i->row_num, j->col,
|
i->row_num, j->col );
|
||||||
j->replacement.debug_contents(), fb.get_cell( i->row_num, j->col )->debug_contents() );
|
|
||||||
j->reset();
|
j->reset();
|
||||||
become_tentative();
|
become_tentative();
|
||||||
if ( j->display_time != uint64_t(-1) ) {
|
if ( j->display_time != uint64_t(-1) ) {
|
||||||
fprintf( stderr, "TIMING %ld - %ld (TENT)\n", time(NULL), now - j->display_time );
|
fprintf( stderr, "TIMING %ld - %ld (TENT)\n", time(NULL), now - j->display_time );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf( stderr, "[%d=>%d] (score=%d) Killing prediction in row %d, col %d (thought %lc, was %lc)\n",
|
fprintf( stderr, "[%d=>%d] (score=%d) Killing prediction in row %d, col %d\n",
|
||||||
(int)local_frame_acked, (int)j->expiration_frame,
|
(int)local_frame_acked, (int)j->expiration_frame,
|
||||||
score,
|
score,
|
||||||
i->row_num, j->col,
|
i->row_num, j->col );
|
||||||
j->replacement.debug_contents(), fb.get_cell( i->row_num, j->col )->debug_contents() );
|
|
||||||
reset();
|
|
||||||
if ( j->display_time != uint64_t(-1) ) {
|
if ( j->display_time != uint64_t(-1) ) {
|
||||||
fprintf( stderr, "TIMING %ld - %ld\n", time(NULL), now - j->display_time );
|
fprintf( stderr, "TIMING %ld - %ld\n", time(NULL), now - j->display_time );
|
||||||
}
|
}
|
||||||
return;
|
j->reset();
|
||||||
|
become_tentative();
|
||||||
|
cursor.reset();
|
||||||
|
/* should reset and return here */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Correct:
|
case Correct:
|
||||||
@@ -387,21 +387,22 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
|||||||
for ( auto it = actions.begin(); it != actions.end(); it++ ) {
|
for ( auto it = actions.begin(); it != actions.end(); it++ ) {
|
||||||
Parser::Action *act = *it;
|
Parser::Action *act = *it;
|
||||||
|
|
||||||
|
if ( !cursor.active ) {
|
||||||
|
/* initialize new cursor prediction */
|
||||||
|
cursor.row = fb.ds.get_cursor_row();
|
||||||
|
cursor.col = fb.ds.get_cursor_col();
|
||||||
|
cursor.active = true;
|
||||||
|
cursor.prediction_time = now;
|
||||||
|
cursor.expiration_frame = local_frame_sent + 1;
|
||||||
|
assert( !cursor.show_frozen_cursor );
|
||||||
|
}
|
||||||
|
|
||||||
if ( typeid( *act ) == typeid( Parser::Print ) ) {
|
if ( typeid( *act ) == typeid( Parser::Print ) ) {
|
||||||
/* make new prediction */
|
/* make new prediction */
|
||||||
|
|
||||||
wchar_t ch = act->ch;
|
wchar_t ch = act->ch;
|
||||||
/* XXX handle wide characters */
|
/* XXX handle wide characters */
|
||||||
|
|
||||||
if ( !cursor.active ) {
|
|
||||||
/* initialize new cursor prediction */
|
|
||||||
cursor.row = fb.ds.get_cursor_row();
|
|
||||||
cursor.col = fb.ds.get_cursor_col();
|
|
||||||
cursor.active = true;
|
|
||||||
cursor.prediction_time = now;
|
|
||||||
cursor.expiration_frame = local_frame_sent + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ch == 0x7f ) { /* backspace */
|
if ( ch == 0x7f ) { /* backspace */
|
||||||
// fprintf( stderr, "Backspace.\n" );
|
// fprintf( stderr, "Backspace.\n" );
|
||||||
if ( cursor.col > 0 ) {
|
if ( cursor.col > 0 ) {
|
||||||
@@ -417,12 +418,12 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
|||||||
cell.expiration_frame = local_frame_sent + 1;
|
cell.expiration_frame = local_frame_sent + 1;
|
||||||
cell.replacement.renditions = fb.ds.get_renditions();
|
cell.replacement.renditions = fb.ds.get_renditions();
|
||||||
cell.replacement.contents.clear();
|
cell.replacement.contents.clear();
|
||||||
cell.replacement.contents.push_back( 0x20 );
|
|
||||||
cell.display_time = -1;
|
cell.display_time = -1;
|
||||||
}
|
}
|
||||||
} else if ( (ch < 0x20) || (ch > 0x7E) ) {
|
} else if ( (ch < 0x20) || (ch > 0x7E) ) {
|
||||||
/* unknown print */
|
/* unknown print */
|
||||||
become_tentative();
|
become_tentative();
|
||||||
|
fprintf( stderr, "Unknown print 0x%x\n", ch );
|
||||||
} else {
|
} else {
|
||||||
/* don't attempt to change existing blank or space cells if user has typed space */
|
/* don't attempt to change existing blank or space cells if user has typed space */
|
||||||
const Cell *existing_cell = fb.get_cell( cursor.row, cursor.col );
|
const Cell *existing_cell = fb.get_cell( cursor.row, cursor.col );
|
||||||
@@ -490,6 +491,7 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
|||||||
} else if ( typeid( *act ) == typeid( Parser::Execute ) ) {
|
} else if ( typeid( *act ) == typeid( Parser::Execute ) ) {
|
||||||
become_tentative();
|
become_tentative();
|
||||||
cursor.freeze();
|
cursor.freeze();
|
||||||
|
fprintf( stderr, "Execute 0x%x\n", act->ch );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete act;
|
delete act;
|
||||||
|
|||||||
+2
-2
@@ -49,11 +49,11 @@ namespace Overlay {
|
|||||||
Validity get_validity( const Framebuffer &fb, uint64_t current_frame ) const;
|
Validity get_validity( const Framebuffer &fb, uint64_t current_frame ) const;
|
||||||
|
|
||||||
ConditionalCursorMove( uint64_t s_exp, int s_row, int s_col )
|
ConditionalCursorMove( uint64_t s_exp, int s_row, int s_col )
|
||||||
: ConditionalOverlay( s_exp, s_col ), row( s_row ), frozen_col( -1 ), frozen_row( -1 ),
|
: ConditionalOverlay( s_exp, s_col ), row( s_row ), frozen_col( 0 ), frozen_row( 0 ),
|
||||||
show_frozen_cursor( false )
|
show_frozen_cursor( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void freeze( void ) { if ( show_frozen_cursor ) { return; } frozen_col = col; frozen_row = row; show_frozen_cursor = true; }
|
void freeze( void ) { frozen_col = col; frozen_row = row; show_frozen_cursor = true; }
|
||||||
void thaw( void ) { show_frozen_cursor = false; }
|
void thaw( void ) { show_frozen_cursor = false; }
|
||||||
void reset( void ) { active = false; thaw(); }
|
void reset( void ) { active = false; thaw(); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user