preview/plaintorich: add <br> tags at end of text/plain lines instead of using <pre> tag (allows line wrapping).

This commit is contained in:
Jean-Francois Dockes 2011-03-08 19:12:00 +01:00
parent 43230c1c60
commit 7eb7bd52bb
5 changed files with 19 additions and 4 deletions

View File

@ -122,6 +122,8 @@ void rwSettings(bool writing)
SETTING_RW(prefs.showResultsAsTable, SETTING_RW(prefs.showResultsAsTable,
"/Recoll/prefs/showResultsAsTable", Bool, false); "/Recoll/prefs/showResultsAsTable", Bool, false);
SETTING_RW(prefs.maxhltextmbs, "/Recoll/prefs/preview/maxhltextmbs", Int, 3); 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"); SETTING_RW(prefs.qtermcolor, "/Recoll/prefs/qtermcolor", String, "blue");
if (!writing && prefs.qtermcolor == "") if (!writing && prefs.qtermcolor == "")
prefs.qtermcolor = "blue"; prefs.qtermcolor = "blue";

View File

@ -80,7 +80,11 @@ class PrefsPack {
bool queryBuildAbstract; bool queryBuildAbstract;
bool queryReplaceAbstract; bool queryReplaceAbstract;
bool startWithAdvSearchOpen; bool startWithAdvSearchOpen;
// Try to display html if it exists in the internfile stack.
bool previewHtml; bool previewHtml;
// Use <pre> tag to display highlighted text/plain inside html (else
// we use <br> at end of lines, which lets textedit wrap lines).
bool previewPlainPre;
bool collapseDuplicates; bool collapseDuplicates;
bool showResultsAsTable; bool showResultsAsTable;
@ -130,9 +134,8 @@ class PrefsPack {
queryReplaceAbstract(false), queryReplaceAbstract(false),
startWithAdvSearchOpen(false), startWithAdvSearchOpen(false),
termMatchType(0), termMatchType(0),
rclVersion(1009) rclVersion(1505)
{ { }
}
}; };
/** Global preferences record */ /** Global preferences record */

View File

@ -80,7 +80,13 @@ public:
if (m_inputhtml) { if (m_inputhtml) {
return snull; return snull;
} else { } else {
return string("<qt><head><title></title></head><body><pre>"); if (prefs.previewPlainPre) {
m_eolbr = false;
return string("<qt><head><title></title></head><body><pre>");
} else {
m_eolbr = true;
return string("<qt><head><title></title></head><body>");
}
} }
} }
virtual string startMatch() virtual string startMatch()

View File

@ -435,6 +435,8 @@ bool PlainToRich::plaintorich(const string& in,
if (eol > 2) if (eol > 2)
eol = 2; eol = 2;
while (eol) { while (eol) {
if (!m_inputhtml && m_eolbr)
*olit += "<br>";
*olit += "\n"; *olit += "\n";
eol--; eol--;
} }

View File

@ -89,6 +89,8 @@ public:
protected: protected:
static const string snull; static const string snull;
bool m_inputhtml; bool m_inputhtml;
// Use <br> to break plain text lines (else caller has used a <pre> tag)
bool m_eolbr;
}; };
#endif /* _PLAINTORICH_H_INCLUDED_ */ #endif /* _PLAINTORICH_H_INCLUDED_ */