[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Thu Dec 1 00:11:45 CET 2005


SVN commit 484478 by netterfield:

Tabs and spaces come and go properly in text edit 


 M  +16 -1     kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #484477:484478
@@ -37,6 +37,7 @@
 #include <qmetaobject.h>
 #include <qptrstack.h>
 #include <qtextedit.h>
+#include <qregexp.h>
 
 #include <stdlib.h>
 
@@ -576,7 +577,14 @@
   if (!w) {
     return false;
   }
-  widget->_text->setText(_txt);
+  // replace \n & \t with tabs and newlines for the text edit box
+  QString tmpstr = _txt;
+  QRegExp cr("\\\\n");
+  QRegExp tab("\\\\t");
+  tmpstr.replace(cr,"\n");
+  tmpstr.replace(tab,"\t");
+  widget->_text->setText(tmpstr);
+  
   return true;
 }
 
@@ -585,7 +593,14 @@
   if (!w) {
     return false;
   }
+  
+  // Replace tabs and newlines in text edit box with \n and \t 
+  QRegExp cr("\n");
+  QRegExp tab("\t");
   _txt = widget->_text->text();
+  _txt.replace(cr, "\\n");
+  _txt.replace(tab, "\\t");
+
   reparse(); // calls setDirty()
   return true;
 }


More information about the Kst mailing list