Remove lots of useless stupid, and code greedy options.
[apps/madmutt.git] / pager.c
diff --git a/pager.c b/pager.c
index 7132f32..eee9b83 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -745,73 +745,6 @@ static int check_attachment_marker(char *p)
     return (int)(*p - *q);
 }
 
-static int grok_ansi (unsigned char *buf, int pos, ansi_attr * a)
-{
-    int x = pos;
-
-    while (isdigit (buf[x]) || buf[x] == ';')
-        x++;
-
-    /* Character Attributes */
-    if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm') {
-        if (pos == x) {
-            if (a->pair != -1)
-                mutt_free_color (a->fg, a->bg);
-            a->attr = ANSI_OFF;
-            a->pair = -1;
-        }
-        a->bg = -2;
-        a->fg = -2;
-        while (pos < x) {
-            if (buf[pos] == '1' && (pos + 1 == x || buf[pos + 1] == ';')) {
-                a->attr |= ANSI_BOLD;
-                pos += 2;
-            }
-            else if (buf[pos] == '4' && (pos + 1 == x || buf[pos + 1] == ';')) {
-                a->attr |= ANSI_UNDERLINE;
-                pos += 2;
-            }
-            else if (buf[pos] == '5' && (pos + 1 == x || buf[pos + 1] == ';')) {
-                a->attr |= ANSI_BLINK;
-                pos += 2;
-            }
-            else if (buf[pos] == '7' && (pos + 1 == x || buf[pos + 1] == ';')) {
-                a->attr |= ANSI_REVERSE;
-                pos += 2;
-            }
-            else if (buf[pos] == '0' && (pos + 1 == x || buf[pos + 1] == ';')) {
-                a->bg = -2;
-                a->fg = -2;
-                pos += 2;
-            }
-            else if (buf[pos] == '3' && isdigit (buf[pos + 1])) {
-                if (a->pair != -1)
-                    mutt_free_color (a->fg, a->bg);
-                a->pair = -1;
-                a->attr |= ANSI_COLOR;
-                if (buf[pos + 1] != '9')
-                    a->fg = buf[pos + 1] - '0';
-                pos += 3;
-            }
-            else if (buf[pos] == '4' && isdigit (buf[pos + 1])) {
-                if (a->pair != -1)
-                    mutt_free_color (a->fg, a->bg);
-                a->pair = -1;
-                a->attr |= ANSI_COLOR;
-                if (buf[pos + 1] != '9')
-                    a->bg = buf[pos + 1] - '0';
-                pos += 3;
-            } else {
-                while (pos < x && buf[pos] != ';')
-                    pos++;
-                pos++;
-            }
-        }
-    }
-    pos = x;
-    return pos;
-}
-
 /* trim tail of buf so that it contains complete multibyte characters */
 static int trim_incomplete_mbyte(unsigned char *buf, size_t len) {
     mbstate_t mbstate;
@@ -912,8 +845,10 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
   for (ch = 0, vch = 0; ch < cnt; ch += k, vch += k) {
     /* Handle ANSI sequences */
     while (cnt - ch >= 2 && buf[ch] == '\033' && buf[ch + 1] == '[' &&
-           is_ansi (buf + ch + 2))
-      ch = grok_ansi (buf, ch + 2, pa) + 1;
+           is_ansi (buf + ch + 2)) {
+      while (isdigit(buf[ch]) || buf[ch] == ';')
+        ch++;
+    }
 
     while (cnt - ch >= 2 && buf[ch] == '\033' && buf[ch + 1] == ']' &&
            check_attachment_marker ((char *) buf + ch) == 0) {
@@ -1361,19 +1296,11 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
 
       indicator = indexlen / 3;
 
-      if (option (OPTSTATUSONTOP)) {
-        indexoffset = 0;
-        statusoffset = IsHeader (extra) ? indexlen : 0;
-        bodyoffset = statusoffset + 1;
-        helpoffset = LINES - 2;
-        bodylen = helpoffset - bodyoffset;
-      } else {
-        helpoffset = 0;
-        indexoffset = 1;
-        statusoffset = LINES - 2;
-        bodyoffset = indexoffset + (IsHeader (extra) ? indexlen : 0);
-        bodylen = statusoffset - bodyoffset;
-      }
+      indexoffset = 0;
+      statusoffset = IsHeader (extra) ? indexlen : 0;
+      bodyoffset = statusoffset + 1;
+      helpoffset = LINES - 2;
+      bodylen = helpoffset - bodyoffset;
 
       SETCOLOR(main_w, MT_COLOR_STATUS);
       wmove(main_w, helpoffset, 0);
@@ -1406,7 +1333,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
         }
 
         SETCOLOR(main_w, MT_COLOR_NORMAL);
-        pager_index->offset = indexoffset + (option (OPTSTATUSONTOP) ? 1 : 0);
+        pager_index->offset = indexoffset + 1;
 
         pager_index->pagelen = indexlen - 1;
 
@@ -1520,7 +1447,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
       sidebar_draw ();
       /* print out the pager_index status bar */
       menu_status_line (buffer, sizeof (buffer), pager_index, NONULL (Status));
-      wmove(main_w, indexoffset + (option(OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
+      wmove(main_w, indexoffset + 0, 0);
       SETCOLOR(main_w, MT_COLOR_STATUS);
       BKGDSET(main_w, MT_COLOR_STATUS);
       mutt_paddstr(main_w, getmaxx(main_w), buffer);