terminal linebuffers on edit

This commit is contained in:
MichaelDvP
2021-04-26 14:50:23 +02:00
parent e6e507a470
commit b01264f701

View File

@@ -158,7 +158,8 @@ void Shell::loop_normal() {
// Interrupt (^C) // Interrupt (^C)
line_buffer_.clear(); line_buffer_.clear();
println(); println();
cursor_ = 0; cursor_ = 0;
line_no_ = 0;
break; break;
case '\x04': case '\x04':
@@ -174,13 +175,15 @@ void Shell::loop_normal() {
// Del/Backspace (^?) // Del/Backspace (^?)
if (line_buffer_.length() > cursor_) { if (line_buffer_.length() > cursor_) {
line_buffer_.erase(line_buffer_.length() - cursor_ - 1, 1); line_buffer_.erase(line_buffer_.length() - cursor_ - 1, 1);
line_no_ = 0;
} }
break; break;
case '\x09': case '\x09':
// Tab (^I) // Tab (^I)
process_completion(); process_completion();
cursor_ = 0; cursor_ = 0;
line_no_ = 0;
break; break;
case '\x0A': case '\x0A':
@@ -200,12 +203,14 @@ void Shell::loop_normal() {
case '\x15': case '\x15':
// Delete line (^U) // Delete line (^U)
line_buffer_.clear(); line_buffer_.clear();
cursor_ = 0; cursor_ = 0;
line_no_ = 0;
break; break;
case '\x17': case '\x17':
// Delete word (^W) // Delete word (^W)
delete_buffer_word(true); delete_buffer_word(true);
line_no_ = 0;
break; break;
case '\033': case '\033':
@@ -251,6 +256,7 @@ void Shell::loop_normal() {
if ((esc_ == 3) && cursor_) { // del if ((esc_ == 3) && cursor_) { // del
cursor_--; cursor_--;
line_buffer_.erase(line_buffer_.length() - cursor_ - 1, 1); line_buffer_.erase(line_buffer_.length() - cursor_ - 1, 1);
line_no_ = 0;
} else if (esc_ == 4) { // end } else if (esc_ == 4) { // end
cursor_ = 0; cursor_ = 0;
} else if (esc_ == 1) { // pos1 } else if (esc_ == 1) { // pos1