]> granicus.if.org Git - mutt/commitdiff
Add a $wrapmargin configuration variable to fine-tune
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 21 Nov 2001 13:56:40 +0000 (13:56 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 21 Nov 2001 13:56:40 +0000 (13:56 +0000)
globals.h
init.h
pager.c

index f50da8b249108e399138dc12ee5c716381e459ad..b9b8d81ec2a28bd571975947deb2ac4fda0ef6b3 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -146,10 +146,13 @@ WHERE short ReadInc;
 WHERE short SendmailWait;
 WHERE short SleepTime INITVAL (1);
 WHERE short Timeout;
+WHERE short WrapMargin;
 WHERE short WriteInc;
+
 WHERE short ScoreThresholdDelete;
 WHERE short ScoreThresholdRead;
 WHERE short ScoreThresholdFlag;
+
 #ifdef USE_IMAP
 WHERE short ImapKeepalive;
 #endif
diff --git a/init.h b/init.h
index 26554b9e4af65052e873afa5ddd7c597ba79f80d..f53d13f4ab184d1e999cfa9435411a187f188452 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2324,6 +2324,12 @@ struct option_t MuttVars[] = {
   ** When set, searches will wrap around the first (or last) message. When
   ** unset, searches will not wrap.
   */
+  { "wrapmargin",      DT_NUM,  R_PAGER, UL &WrapMargin, 0 },
+  /*
+  ** .pp
+  ** Controls the margin left at the right side of the terminal when mutt's
+  ** pager does smart wrapping.
+  */
   { "write_inc",       DT_NUM,  R_NONE, UL &WriteInc, 10 },
   /*
   ** .pp
diff --git a/pager.c b/pager.c
index a86eb9179deac45639399871e10fe4c09f2ea86f..c2154d863947dcd39c6fcb8f3e48b9e61a8ca1f3 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1031,6 +1031,11 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
   wchar_t wc;
   mbstate_t mbstate;
 
+  int wrap_cols = COLS - WrapMargin;
+  
+  if (wrap_cols <= 0)
+    wrap_cols = COLS;
+  
   /* FIXME: this should come from lineInfo */
   memset(&mbstate, 0, sizeof(mbstate));
 
@@ -1051,7 +1056,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
     k = mbrtowc (&wc, (char *)buf+ch, cnt-ch, &mbstate);
     if (k == -2 || k == -1)
     {
-      if (col + 4 > COLS)
+      if (col + 4 > wrap_cols)
        break;
       col += 4;
       if (pa)
@@ -1111,7 +1116,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
       if (wc == ' ')
        space = ch;
       t = wcwidth (wc);
-      if (col + t > COLS)
+      if (col + t > wrap_cols)
        break;
       col += t;
       if (pa)
@@ -1123,7 +1128,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
     {
       space = ch;
       t = (col & ~7) + 8;
-      if (t > COLS)
+      if (t > wrap_cols)
        break;
       if (pa)
        for (; col < t; col++)
@@ -1133,7 +1138,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
     }
     else if (wc < 0x20 || wc == 0x7f)
     {
-      if (col + 2 > COLS)
+      if (col + 2 > wrap_cols)
        break;
       col += 2;
       if (pa)
@@ -1141,7 +1146,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
     }
     else if (wc < 0x100)
     {
-      if (col + 4 > COLS)
+      if (col + 4 > wrap_cols)
        break;
       col += 4;
       if (pa)
@@ -1149,7 +1154,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
     }
     else
     {
-      if (col + 1 > COLS)
+      if (col + 1 > wrap_cols)
        break;
       ++col;
       if (pa)