summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice <maurice.henke@protonmail.com>2021-07-06 23:37:56 +0200
committerMaurice <maurice.henke@protonmail.com>2021-07-06 23:37:56 +0200
commit125fc3959346d0b1ee961a3203574e56213a0e2a (patch)
treed2faf9519f15e3b46d1350dc0b83065eefcd0cba
parentaf1798540699326f8ab246f5a014e1e8bd4f3df1 (diff)
Make sure the console clears residue when setting a line
Also strncpy rather than strcpy for safety
-rw-r--r--source/display/console.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/display/console.cpp b/source/display/console.cpp
index 6dedf35..57655fc 100644
--- a/source/display/console.cpp
+++ b/source/display/console.cpp
@@ -70,17 +70,24 @@ namespace libtp::display
void Console::setLine( uint8_t line )
{
+ tp::jfw_system::SystemConsole* console = tp::jfw_system::systemConsole;
+
+ // Clear following lines
+ if ( line < m_Line )
+ {
+ display::clearConsole( line, 0 );
+ }
+
m_Line = line;
if ( this->m_Line >= 25 )
{
- tp::jfw_system::SystemConsole* console = tp::jfw_system::systemConsole;
this->m_Line = 24;
// Move all lines up by one starting at protected + 1
for ( uint8_t i = m_Protect + 1; i < 25; i++ )
{
- strcpy( console->consoleLine[i - 1].line, console->consoleLine[i].line );
+ strncpy( console->consoleLine[i - 1].line, console->consoleLine[i].line, 48 );
}
}
}