Bug 59448 - Let the KNode-EtText parser ignore signatures
Summary: Let the KNode-EtText parser ignore signatures
Status: RESOLVED FIXED
Alias: None
Product: knode
Classification: Unmaintained
Component: general (other bugs)
Version First Reported In: 0.7.1
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-06 22:41 UTC by Malte S. Stretz
Modified: 2004-11-11 13:53 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot of lost spaces (16.82 KB, image/png)
2003-06-06 22:42 UTC, Malte S. Stretz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Malte S. Stretz 2003-06-06 22:41:20 UTC
Version:           0.7.2 (using KDE 3.1.2)
Installed from:    SuSE
Compiler:          gcc version 2.95.3 20010315 (SuSE)
OS:          Linux (i686) release 2.4.18

Hi,

for some reason does KNode sometimes "loose" some spaces: I noticed this only in one special signature from somebody posting on my University's newsserver. The spaces are shown correctly in the source of the posting and I also retrieved the posting per hand and it looks ok (I didn't have a chance to test in in another newsreader though).

One such posting I'm referring to is available in the group [1], Message-Id [2] (it always happens with his signature). I'll attach a screenshot to make clear what I mean.

Cheers,
Malte

[1]news://news.fh-wedel.de/fhw.talk
[2]msgid:bbigc2$a2l$1@mail.fh-wedel.de
Comment 1 Malte S. Stretz 2003-06-06 22:42:08 UTC
Created attachment 1739 [details]
screenshot of lost spaces
Comment 2 Malte S. Stretz 2003-06-07 16:21:27 UTC
Christian Janoff just pointed me to the right direction in private mail: The problem 
seems to be that I have "Interpret text format tags" enabled. Thus the string 
  _( )_ 
is interpreted as two underlined brackets. 
 
I don't know if it is possible to improve the format interpreter so that it can guess 
ASCII art from normal text or if it should be disabled for signatures where you 
most often find ASCII art and not emphased text. 
Comment 3 W K Havinga 2003-07-10 16:05:56 UTC
Just tried this, and it has to do with the format interpreter indeed. It works
fine when you set 'View->Fixed Font' and have the interpreter disabled. And it
screws up a bit when you enable the interpreter, as described above.

Improving the formatter so it will recognize ASCII-art looks like a wishlist
item to me, maybe the severity should be changed from minor to wishlist?

Btw. I wonder if it would be feasible to change the format interpreter so it
will recognize ascii art, yet still work when it is needed. When making the
formatter more complex, it is bound to make mistakes in other weird cases.

Alternative option: would it be a good idea to skip formatting the message
signature (e.g. anything below the sigsep '-- '), because people tend to use
ASCII art in their sigs? I'd guess this would be relatively easy to implement,
as the formatter obviously already recognizes sigseps - it transforms them into
a horizontal bar the width of your article window...

Anyhow, even then it would be a 'wishlist' item :)

Any comment on this (from the bug reporter, maybe)?
Comment 4 Malte S. Stretz 2003-07-11 18:00:52 UTC
The reporter says: Full ACK to W K Havinga ;-) 
 
P.S.: The term "EtText" is taken from the Perl module Text::EtText [3] -- dunno 
how to call it else. 
 
[3]http://ettext.taint.org/ 
Comment 5 Jakob Schröter 2004-11-11 13:53:54 UTC
CVS commit by schrot: 

- scroll the reader win back after rot13 (#76797)
- dito for switching from/to fixed font
- insert spelling correction at correct position (#76396)
- formatting of 1-letter words (bold etc.) (#70726)
- disable formatting of signatures (#59448)
- add %L as line break alias (#66772)

BUG: 76797
BUG: 76396
BUG: 70726
BUG: 59448
FEATURE: 66772


  M +1 -0      knarticlefactory.cpp   1.83
  M +10 -2     knarticlewidget.cpp   1.187
  M +10 -12    kncomposer.cpp   1.203
  M +1 -1      knconfigwidgets.cpp   1.120


--- kdepim/knode/knarticlefactory.cpp  #1.82:1.83
@@ -217,4 +217,5 @@ void KNArticleFactory::createReply(KNRem
   attribution.replace(QRegExp("%MSID"),a->messageID()->asUnicodeString());
   attribution.replace(QRegExp("%GROUP"),g->groupname());
+  attribution.replace(QRegExp("%L"),"\n");
   attribution+="\n\n";
 

--- kdepim/knode/knarticlewidget.cpp  #1.186:1.187
@@ -730,5 +730,5 @@ QString KNArticleWidget::toHtmlString(co
           if (regExp.search(text,idx)==(int)idx) {
             matchLen = regExp.matchedLength();
-            if (( matchLen > 3 ) &&
+            if (( matchLen >= 3 ) &&
                 ((idx==0)||text[idx-1].isSpace()||(text[idx-1] == '(')) &&
                 ((idx+matchLen==len)||text[idx+matchLen].isSpace()||(text[idx+matchLen]==',')||
@@ -1368,8 +1368,10 @@ void KNArticleWidget::createHtmlPage()
               }
             }
-          }
           html+=toHtmlString(line,true,true,true)+"<br>";
         }
         else
+            html+=toHtmlString(line,true,false,true)+"<br>";
+        }
+        else
           html+="<br>";
       }
@@ -1791,6 +1793,9 @@ void KNArticleWidget::slotToggleFullHdrs
 void KNArticleWidget::slotToggleRot13()
 {
+  int x = contentsX();
+  int y = contentsY();
   r_ot13=!r_ot13;
   updateContents();
+  setContentsPos(x, y);
 }
 
@@ -1798,8 +1803,11 @@ void KNArticleWidget::slotToggleRot13()
 void KNArticleWidget::slotToggleFixedFont()
 {
+  int x = contentsX();
+  int y = contentsY();
   // ok, this is a hack
   if (knGlobals.artWidget == this)
     knGlobals.configManager()->readNewsViewer()->setUseFixedFont(!knGlobals.configManager()->readNewsViewer()->useFixedFont());
   applyConfig();
+  setContentsPos(x, y);
 }
 

--- kdepim/knode/kncomposer.cpp  #1.202:1.203
@@ -345,6 +345,8 @@ KNComposer::KNComposer(KNLocalArticle *a
 
   if (firstEdit) {   // now we place the cursor at the end of the quoted text / below the attribution line
-    if (knGlobals.configManager()->postNewsComposer()->cursorOnTop())
-      v_iew->e_dit->setCursorPosition(1,0);
+    if (knGlobals.configManager()->postNewsComposer()->cursorOnTop()) {
+      int numLines = knGlobals.configManager()->postNewsComposer()->intro().contains("%L");
+      v_iew->e_dit->setCursorPosition(numLines+1,0);
+    }
     else
       v_iew->e_dit->setCursorPosition(v_iew->e_dit->numLines()-1,0);
@@ -2057,14 +2059,10 @@ bool KNComposer::Editor::eventFilter(QOb
           int parIdx = 1, txtIdx = 1;
           getCursorPosition(&parIdx, &txtIdx);
-
-          //Put in our replacement
-          QString txtContents = text();
-          QString newContents = txtContents.left(firstSpace) + m_replacements[word][id] +
-                                txtContents.right( txtContents.length() - lastSpace );
-          setText( newContents );
-
-          //Restore the cursor position
-          if( txtIdx > lastSpace )
-            txtIdx += newContents.length() - txtContents.length();
+          setSelection(para, firstSpace, para, lastSpace);
+          insert(m_replacements[word][id]);
+          // Restore the cursor position; if the cursor was behind the
+          // misspelled word then adjust the cursor position
+          if ( para == parIdx && txtIdx >= lastSpace )
+            txtIdx += m_replacements[word][id].length() - word.length();
           setCursorPosition(parIdx, txtIdx);
         }

--- kdepim/knode/knconfigwidgets.cpp  #1.119:1.120
@@ -2242,5 +2242,5 @@ KNConfig::PostNewsComposerWidget::PostNe
   replyL->addMultiCellWidget(new QLabel(i_ntro,i18n("&Introduction phrase:"), replyB),1,1,0,1);
   replyL->addMultiCellWidget(i_ntro, 2,2,0,1);
-  replyL->addMultiCellWidget(new QLabel(i18n("Placeholders: %NAME=name, %EMAIL=email address,\n%DATE=date, %MSID=message-id, %GROUP=group name"), replyB),3,3,0,1);
+  replyL->addMultiCellWidget(new QLabel(i18n("Placeholders: %NAME=name, %EMAIL=email address,\n%DATE=date, %MSID=message-id, %GROUP=group name, %L=line break"), replyB),3,3,0,1);
   connect(i_ntro, SIGNAL(textChanged(const QString&)), SLOT(slotEmitChanged()));