diff --git a/src/console/Screen.cpp b/src/console/Screen.cpp index 1d382c8..f338359 100644 --- a/src/console/Screen.cpp +++ b/src/console/Screen.cpp @@ -84,6 +84,26 @@ CONSOLELINE::~CONSOLELINE() { } } +void CONSOLELINE::Backspace() { + if (this->inputpos > this->inputstart) { + if (this->chars <= this->inputpos) { + this->buffer[this->inputpos - 1] = '\0'; + } + else { + memcpy( + &this->buffer[this->inputpos - 1], + &this->buffer[this->inputpos], + this->chars - this->inputpos + 1 + ); + } + + this->inputpos--; + this->chars--; + + SetInputString(this->buffer); + } +} + void DrawBackground() { uint16_t indices[] = { 0, 1, 2, 3 diff --git a/src/console/Screen.hpp b/src/console/Screen.hpp index 3d33654..3f6103b 100644 --- a/src/console/Screen.hpp +++ b/src/console/Screen.hpp @@ -19,6 +19,7 @@ class CONSOLELINE : public TSLinkedNode { // Member functions ~CONSOLELINE(); + void Backspace(); }; void ConsoleScreenAnimate(float elapsedSec);