From: Manuel Nickschas Date: Thu, 8 Oct 2015 22:12:37 +0000 (+0200) Subject: Merge pull request #151 from Tucos/ws-hist X-Git-Tag: travis-deploy-test~547 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b49c64970b6237fc95f8ca88c8bb6bcf04c251d7;hp=-c Merge pull request #151 from Tucos/ws-hist Preserve white-space in the input history. --- b49c64970b6237fc95f8ca88c8bb6bcf04c251d7 diff --combined src/uisupport/multilineedit.cpp index 7e89f499,0651abf1..37f1f62a --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@@ -41,7 -41,6 +41,7 @@@ MultiLineEdit::MultiLineEdit(QWidget *p _scrollBarsEnabled(true), _pasteProtectionEnabled(true), _emacsMode(false), + _completionSpace(0), _lastDocumentHeight(-1) { document()->setDocumentMargin(0); @@@ -55,6 -54,9 +55,9 @@@ setLineWrapEnabled(false); reset(); + // Prevent QTextHtmlImporter::appendNodeText from eating whitespace + document()->setDefaultStyleSheet("span { white-space: pre-wrap; }"); + connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged())); _mircColorMap["00"] = "#ffffff"; @@@ -668,12 -670,8 +671,12 @@@ void MultiLineEdit::on_returnPressed( } -void MultiLineEdit::on_returnPressed(const QString &text) +void MultiLineEdit::on_returnPressed(QString text) { + if (_completionSpace && text.endsWith(" ")) { + text.chop(1); + } + if (!text.isEmpty()) { foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) { if (line.isEmpty()) @@@ -692,8 -690,6 +695,8 @@@ void MultiLineEdit::on_textChanged() { + _completionSpace = qMax(_completionSpace - 1, 0); + QString newText = text(); newText.replace("\r\n", "\n"); newText.replace('\r', '\n'); @@@ -776,12 -772,3 +779,12 @@@ void MultiLineEdit::showHistoryEntry( setTextCursor(cursor); updateScrollBars(); } + + +void MultiLineEdit::addCompletionSpace() +{ + // Inserting the space emits textChanged, which should not disable removal + _completionSpace = 2; + insertPlainText(" "); +} +