summaryrefslogtreecommitdiff
path: root/chinese/mutt/files/patch-pager.c
blob: dd389965048a43cfeeb38e3cc08ad7df33f47825 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--- pager.c.orig	2016-10-09 03:35:50.000000000 +0800
+++ pager.c	2016-12-02 11:21:36.940396000 +0800
@@ -20,6 +20,10 @@
 # include "config.h"
 #endif
 
+/*
+ * Trad. Chinese support by Michael Hsin <mhsin@mhsin.org>
+ */
+
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "mutt_regex.h"
@@ -1101,7 +1105,7 @@ static int format_line (struct line_t **
   int space = -1; /* index of the last space or TAB */
   int col = option (OPTMARKERS) ? (*lineInfo)[n].continuation : 0;
   size_t k;
-  int ch, vch, last_special = -1, special = 0, t;
+  int ch, vch, last_special = -1, special = 0, t = 0, old_t = 0;
   wchar_t wc;
   mbstate_t mbstate;
   int wrap_cols = mutt_window_wrap_cols (pager_window, (flags & MUTT_PAGER_NOWRAP) ? 0 : Wrap);
@@ -1223,7 +1227,10 @@ static int format_line (struct line_t **
 	 * attempt to wrap at this character. */
 	wc = ' ';
       }
+      old_t = t;
       t = wcwidth (wc);
+      if (t > 1 || old_t > 1)
+        space = ch;
       if (col + t > wrap_cols)
 	break;
       col += t;
@@ -1447,6 +1454,7 @@ display_line (FILE *f, LOFF_T *last_pos,
       {
 	buf_ptr = buf + ch;
 	/* skip trailing blanks */
+        ch--;
 	while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
 	  ch--;
         /* a very long word with leading spaces causes infinite wrapping */