From 7eb7bd52bbbd45004d538bd7cc02a5051e238f97 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 8 Mar 2011 19:12:00 +0100 Subject: [PATCH] preview/plaintorich: add
tags at end of text/plain lines instead of using
 tag (allows line wrapping).

---
 src/qtgui/guiutils.cpp    | 2 ++
 src/qtgui/guiutils.h      | 9 ++++++---
 src/qtgui/preview_w.cpp   | 8 +++++++-
 src/query/plaintorich.cpp | 2 ++
 src/query/plaintorich.h   | 2 ++
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp
index ecd4058a..ea1815b3 100644
--- a/src/qtgui/guiutils.cpp
+++ b/src/qtgui/guiutils.cpp
@@ -122,6 +122,8 @@ void rwSettings(bool writing)
     SETTING_RW(prefs.showResultsAsTable, 
 	       "/Recoll/prefs/showResultsAsTable", Bool, false);
     SETTING_RW(prefs.maxhltextmbs, "/Recoll/prefs/preview/maxhltextmbs", Int, 3);
+    SETTING_RW(prefs.previewPlainPre, 
+	       "/Recoll/prefs/preview/plainPre", Bool, false);
     SETTING_RW(prefs.qtermcolor, "/Recoll/prefs/qtermcolor", String, "blue");
     if (!writing && prefs.qtermcolor == "")
 	prefs.qtermcolor = "blue";
diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h
index d047042c..ab618d99 100644
--- a/src/qtgui/guiutils.h
+++ b/src/qtgui/guiutils.h
@@ -80,7 +80,11 @@ class PrefsPack {
     bool queryBuildAbstract;
     bool queryReplaceAbstract;
     bool startWithAdvSearchOpen;
+    // Try to display html if it exists in the internfile stack.
     bool previewHtml;
+    // Use 
 tag to display highlighted text/plain inside html (else
+    // we use 
at end of lines, which lets textedit wrap lines). + bool previewPlainPre; bool collapseDuplicates; bool showResultsAsTable; @@ -130,9 +134,8 @@ class PrefsPack { queryReplaceAbstract(false), startWithAdvSearchOpen(false), termMatchType(0), - rclVersion(1009) - { - } + rclVersion(1505) + { } }; /** Global preferences record */ diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index 01bffda5..abd75756 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -80,7 +80,13 @@ public: if (m_inputhtml) { return snull; } else { - return string("
");
+	    if (prefs.previewPlainPre) {
+		m_eolbr = false;
+		return string("
");
+	    } else {
+		m_eolbr = true;
+		return string("");
+	    }
 	}
     }
     virtual string startMatch() 
diff --git a/src/query/plaintorich.cpp b/src/query/plaintorich.cpp
index 5e59e4a3..abbf5c2b 100644
--- a/src/query/plaintorich.cpp
+++ b/src/query/plaintorich.cpp
@@ -435,6 +435,8 @@ bool PlainToRich::plaintorich(const string& in,
             if (eol > 2)
                 eol = 2;
             while (eol) {
+		if (!m_inputhtml && m_eolbr)
+		    *olit += "
"; *olit += "\n"; eol--; } diff --git a/src/query/plaintorich.h b/src/query/plaintorich.h index 040a5c29..77e7e335 100644 --- a/src/query/plaintorich.h +++ b/src/query/plaintorich.h @@ -89,6 +89,8 @@ public: protected: static const string snull; bool m_inputhtml; + // Use
to break plain text lines (else caller has used a
 tag)
+    bool m_eolbr; 
 };
 
 #endif /* _PLAINTORICH_H_INCLUDED_ */