[pan2: 15/23] WIP: seperate line length check for each quote level. should only be for quoted levels.
- From: Petr Kovář <pmkovar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 15/23] WIP: seperate line length check for each quote level. should only be for quoted levels.
- Date: Sun, 29 May 2011 13:04:48 +0000 (UTC)
commit 47e55c5a4b72f943832108a75491374c5b9d8e39
Author: K. Haley <haleykd users sf net>
Date: Fri May 28 17:55:20 2010 -0600
WIP: seperate line length check for each quote level. should only be for quoted levels.
pan/usenet-utils/text-massager.cc | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/pan/usenet-utils/text-massager.cc b/pan/usenet-utils/text-massager.cc
index 10c7cf7..6856476 100644
--- a/pan/usenet-utils/text-massager.cc
+++ b/pan/usenet-utils/text-massager.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <vector>
+#include <map>
#include <cstring>
#include <glib.h>
extern "C" {
@@ -26,7 +27,7 @@ extern "C" {
}
#include <glib/gunicode.h>
#include "text-massager.h"
-
+#include <pan/general/log.h>
using namespace pan;
TextMassager :: TextMassager ():
@@ -110,6 +111,8 @@ namespace
void merge_fixed (paragraphs_t ¶graphs, lines_t &lines, int wrap_col)
{
+ std::map<std::string, int> max_map;
+ std::map<std::string, int>::iterator map_end = max_map.end();
int prev_content_len = 0;
int max_len = wrap_col;
StringView cur_leader;
@@ -118,8 +121,14 @@ namespace
for (lines_cit it=lines.begin(), end=lines.end(); it!=end; ++it)
{
const Line& line (*it);
- max_len = MAX(max_len, line.leader.len + line.content.len);
+ int line_len = line.leader.len + line.content.len;
+ if (map_end != max_map.find(line.leader))
+ max_map[line.leader] = MAX(max_map[line.leader], line_len );
+ else
+ // use 12 as the minimum line length
+ max_map.insert( std::make_pair(line.leader, MAX(line_len, 12) ) );
}
+
for (lines_cit it=lines.begin(), end=lines.end(); it!=end; ++it)
{
const Line& line (*it);
@@ -138,7 +147,7 @@ namespace
// line but wasn't assume deliberate line break.
if (!paragraph_end && prev_content_len && line.content.len)
{
- int space = max_len - (prev_content_len + line.leader.len) - 1;
+ int space = max_map[line.leader] - (prev_content_len + line.leader.len) - 1;
if ( space > 0 && ((line.content.len < space)
|| g_utf8_strchr (line.content.str, space, ' ')) )
paragraph_end = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]