fix console line
This commit is contained in:
@@ -28,15 +28,30 @@ QStringList ConsoleManager::update_log() const { return m_update_log; }
|
||||
|
||||
void ConsoleManager::append_update_log(const QByteArray& chunk)
|
||||
{
|
||||
m_update_log_buffer += QString::fromUtf8(chunk);
|
||||
m_update_log_buffer.replace(QLatin1Char('\r'), QLatin1Char('\n'));
|
||||
const QString text = QString::fromUtf8(chunk);
|
||||
|
||||
qsizetype new_line;
|
||||
while ((new_line = m_update_log_buffer.indexOf(QLatin1Char('\n'))) >= 0)
|
||||
for (const QChar ch : text)
|
||||
{
|
||||
const QString line = m_update_log_buffer.left(new_line);
|
||||
m_update_log_buffer.remove(0, new_line + 1);
|
||||
if (!line.trimmed().isEmpty()) add_log_line(m_package_manager + QStringLiteral(": ") + line);
|
||||
if (ch == QLatin1Char('\r'))
|
||||
{
|
||||
m_pending_cr = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == QLatin1Char('\n'))
|
||||
{
|
||||
commit_line();
|
||||
m_pending_cr = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_pending_cr)
|
||||
{
|
||||
m_update_log_buffer.clear();
|
||||
m_pending_cr = false;
|
||||
}
|
||||
|
||||
m_update_log_buffer += ch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,3 +74,10 @@ void ConsoleManager::add_log_line(const QString& line)
|
||||
emit update_log_changed();
|
||||
}
|
||||
|
||||
void ConsoleManager::commit_line()
|
||||
{
|
||||
const QString line = m_update_log_buffer;
|
||||
m_update_log_buffer.clear();
|
||||
if (!line.trimmed().isEmpty())
|
||||
add_log_line(m_package_manager + QStringLiteral(": ") + line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user