cursor left/right: no extra chars and no function #587

This commit is contained in:
MichaelDvP
2020-10-31 10:19:12 +01:00
parent 0a12b47eb2
commit 6c309a2a8f
2 changed files with 6 additions and 13 deletions

View File

@@ -226,28 +226,22 @@ void Shell::loop_normal() {
line_buffer_ = oldline_;
display_prompt();
}
// cursor back, delete cursor chars and move on char to rest
// cursor back, delete cursor chars
if ((c == 'D') && (previous_ == '[')) {
line_buffer_.pop_back();
line_buffer_.pop_back();
if (line_buffer_.length() > 0) {
uint8_t ch = line_buffer_.back();
line_rest_.push_back(ch);
line_buffer_.pop_back();
}
// alternative work as backspace
// if (line_buffer_.length() > 0) {
// line_buffer_.pop_back();
// }
erase_current_line();
prompt_displayed_ = false;
display_prompt();
}
// cursor forward, delete cursor chars and add one from rest.
// cursor forward, only delete cursor chars
if ((c == 'C') && (previous_ == '[')) {
line_buffer_.pop_back();
line_buffer_.pop_back();
if (line_rest_.length() > 0) {
uint8_t ch = line_rest_.back();
line_buffer_.push_back(ch);
line_rest_.pop_back();
}
erase_current_line();
prompt_displayed_ = false;
display_prompt();

View File

@@ -906,7 +906,6 @@ class Shell : public std::enable_shared_from_this<Shell>, public uuid::log::Hand
size_t maximum_command_line_length_ = MAX_COMMAND_LINE_LENGTH; /*!< Maximum command line length in bytes. @since 0.6.0 */
unsigned char previous_ = 0; /*!< Previous character that was entered on the command line. Used to detect CRLF line endings. @since 0.1.0 */
std::string oldline_; /*!< old Command line buffer.*/
std::string line_rest_; /*!< rest of Command line buffer if goinig back with cursor.*/
Mode mode_ = Mode::NORMAL; /*!< Current execution mode. @since 0.1.0 */
std::unique_ptr<ModeData> mode_data_ = nullptr; /*!< Data associated with the current execution mode. @since 0.1.0 */
bool stopped_ = false; /*!< Indicates that the shell has been stopped. @since 0.1.0 */