Introduce Utils::SynchronousProcess::normalizeNewlines

Replaces \r\n? with \n.

Some console applications (e.g. git-push, git-rebase) use \r alone to
move the cursor to the line's beginning. This should be replaced by \n
rather than just be erased.

Change-Id: I8d614d2b471e59decdbfa7f173ffa7fbdb11759b
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-08-02 12:15:04 +03:00
committed by Orgad Shaneh
parent 1b13122cd1
commit 208aeb79ed
8 changed files with 43 additions and 27 deletions

View File

@@ -33,6 +33,8 @@
#include "coreconstants.h"
#include "icore.h"
#include <utils/synchronousprocess.h>
#include <QAction>
#include <QScrollBar>
@@ -200,8 +202,7 @@ void OutputWindow::setMaxLineCount(int count)
void OutputWindow::appendMessage(const QString &output, OutputFormat format)
{
QString out = output;
out.remove(QLatin1Char('\r'));
const QString out = Utils::SynchronousProcess::normalizeNewlines(output);
setMaximumBlockCount(m_maxLineCount);
const bool atBottom = isScrollbarAtBottom();
@@ -251,8 +252,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
// TODO rename
void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &format)
{
QString text = textIn;
text.remove(QLatin1Char('\r'));
const QString text = Utils::SynchronousProcess::normalizeNewlines(textIn);
if (m_maxLineCount > 0 && document()->blockCount() >= m_maxLineCount)
return;
const bool atBottom = isScrollbarAtBottom();