Replace tab characters by 8 spaces
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 13 Apr 2010 21:38:22 +0000 (23:38 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 13 Apr 2010 21:42:10 +0000 (23:42 +0200)
Our layout engine can't properly handle tabs (and it's doubtful how they should be handled
anyway on random pastes), and it breaks while trying. So now we replace tabs by 8 spaces.

Note that Konversation (and probably some others) currently sends a \t for the "italics" format.
This is non-standard and not very consistent across clients, so I chose to not have a tab trigger italics.
So for pastes, we show something mostly correct, while italic text sent from Konversation will cause
some whitespace instead. I think that's a better tradeoff than the other way round (showing italics
when tabs are pasted).

src/uisupport/uistyle.cpp

index f23ec19..dd2ed96 100644 (file)
@@ -504,6 +504,7 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat
 QString UiStyle::mircToInternal(const QString &mirc_) {
   QString mirc = mirc_;
   mirc.replace('%', "%%");      // escape % just to be sure
+  mirc.replace('\t', "        ");      // tabs break layout, also this is italics in Konversation
   mirc.replace('\x02', "%B");
   mirc.replace('\x0f', "%O");
   mirc.replace('\x12', "%R");