mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-31 17:42:55 +08:00
parent
accb18d7f2
commit
c439e5a5f7
@ -86,6 +86,7 @@ IO::Console::Console()
|
||||
, m_autoscroll(true)
|
||||
, m_showTimestamp(false)
|
||||
, m_isStartingLine(true)
|
||||
, m_lastCharWasCR(false)
|
||||
{
|
||||
// Clear buffer & reserve memory
|
||||
clear();
|
||||
@ -300,6 +301,7 @@ void IO::Console::clear()
|
||||
m_textBuffer.clear();
|
||||
m_textBuffer.reserve(10 * 1000);
|
||||
m_isStartingLine = true;
|
||||
m_lastCharWasCR = false;
|
||||
Q_EMIT dataReceived();
|
||||
}
|
||||
|
||||
@ -485,8 +487,16 @@ void IO::Console::append(const QString &string, const bool addTimestamp)
|
||||
if (string.isEmpty())
|
||||
return;
|
||||
|
||||
// Only use \n as line separator
|
||||
auto data = string;
|
||||
|
||||
// Omit leading \n if a trailing \r was already rendered from previous payload
|
||||
if (m_lastCharWasCR && data.startsWith("\n"))
|
||||
data.removeFirst();
|
||||
|
||||
// Record trailing \r
|
||||
m_lastCharWasCR = data.endsWith("\r");
|
||||
|
||||
// Only use \n as line separator for rendering
|
||||
data = data.replace("\r\n", "\n");
|
||||
data = data.replace("\r", "\n");
|
||||
|
||||
|
@ -170,6 +170,7 @@ private:
|
||||
bool m_autoscroll;
|
||||
bool m_showTimestamp;
|
||||
bool m_isStartingLine;
|
||||
bool m_lastCharWasCR;
|
||||
|
||||
StringList m_lines;
|
||||
StringList m_historyItems;
|
||||
|
Loading…
x
Reference in New Issue
Block a user