Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always re-render prompt while navigating history #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/replxx_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ int Replxx::ReplxxImpl::virtual_render( char32_t const* buffer_, int len_, int&
* Refresh the user's input line: the prompt is already onscreen and is not
* redrawn here screen position
*/
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_ ) {
void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_, bool refreshPrompt_ ) {
int long long now( now_us() );
int long long duration( now - _lastRefreshTime );
if ( duration < RAPID_REFRESH_US ) {
Expand All @@ -993,10 +993,22 @@ void Replxx::ReplxxImpl::refresh_line( HINT_ACTION hintAction_ ) {

// position at the end of the prompt, clear to end of previous input
_terminal.set_cursor_visible( false );
_terminal.jump_cursor(
_prompt.indentation(), // 0-based on Win32
-( _prompt._cursorRowOffset - _prompt._extraLines )
);
if ( refreshPrompt_ )
{
_terminal.jump_cursor(
0,
-_prompt._cursorRowOffset
);
_prompt.write();
_prompt._cursorRowOffset = _prompt._extraLines;
}
else
{
_terminal.jump_cursor(
_prompt.indentation(), // 0-based on Win32
-( _prompt._cursorRowOffset - _prompt._extraLines )
);
}
// display the input line
if ( _hasNewlines ) {
_terminal.clear_screen( Terminal::CLEAR_SCREEN::TO_END );
Expand Down Expand Up @@ -1934,7 +1946,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_move( bool previous_ ) {
}
_data.assign( _history.current() );
_pos = _data.length();
refresh_line();
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
return ( Replxx::ACTION_RESULT::CONTINUE );
}

Expand Down Expand Up @@ -2006,7 +2018,7 @@ Replxx::ACTION_RESULT Replxx::ReplxxImpl::history_jump( bool back_ ) {
_history.jump( back_ );
_data.assign( _history.current() );
_pos = _data.length();
refresh_line();
refresh_line( HINT_ACTION::REGENERATE, true /* refreshPrompt */ );
}
return ( Replxx::ACTION_RESULT::CONTINUE );
}
Expand Down
2 changes: 1 addition & 1 deletion src/replxx_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private:
void call_modify_callback( void );
completions_t call_completer( std::string const& input, int& ) const;
hints_t call_hinter( std::string const& input, int&, Replxx::Color& color ) const;
void refresh_line( HINT_ACTION = HINT_ACTION::REGENERATE );
void refresh_line( HINT_ACTION = HINT_ACTION::REGENERATE, bool refreshPrompt_ = false );
void move_cursor( void );
void indent( void );
int virtual_render( char32_t const*, int, int&, int&, Prompt const* = nullptr );
Expand Down