input: Add Begin & End

This commit is contained in:
augustin64 2023-11-17 11:08:17 +01:00
parent 9b0c3900f8
commit 60eccf1c15

View File

@ -92,6 +92,19 @@ string get_line_with_hist(vector<string> history, int line_num) {
if (input_index < (int)input.size()) if (input_index < (int)input.size())
cout << "\033[" << input.size() - input_index << "D"; cout << "\033[" << input.size() - input_index << "D";
} }
break;
} case 'H': { //* Begin
if (input_index > 0) {
cout << "\033[" << input_index << "D"; // Go left input_index
input_index = 0;
}
break;
} case 'F': { //* End
if (input_index < (int)input.size()) {
cout << "\033[" << (input.size() - input_index) << "C"; // Go right input.size() - input_index
input_index = input.size();
}
break;
} }
} }
} else if (ch == '\b' || ch == 127) { //* Backspace } else if (ch == '\b' || ch == 127) { //* Backspace