Simplification
[apps/madmutt.git] / pager.c
diff --git a/pager.c b/pager.c
index 87c075b..e0643b5 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -590,8 +590,6 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
     return class;
 }
 
-static int brailleCol = -1;
-
 static int check_attachment_marker (char *);
 
 static void
@@ -747,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;
@@ -914,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) {
@@ -1305,8 +1238,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
   int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
 
   MUTTMENU *pager_index = NULL;       /* the Pager Index (PI) */
-  int indexoffset = 0;          /* offset for the PI */
-  int indexlen = PagerIndexLines;       /* indexlen not always == PIL */
+  int indexlen = PagerIndexLines;     /* indexlen not always == PIL */
   int indicator = indexlen / 3; /* the indicator line of the PI */
   int old_PagerIndexLines;      /* some people want to resize it
                                  * while inside the pager... */
@@ -1363,19 +1295,10 @@ 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;
-      }
+      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);
@@ -1408,8 +1331,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  = 1;
         pager_index->pagelen = indexlen - 1;
 
         /* some fudge to work out where abouts the indicator should go */
@@ -1522,7 +1444,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, 0, 0);
       SETCOLOR(main_w, MT_COLOR_STATUS);
       BKGDSET(main_w, MT_COLOR_STATUS);
       mutt_paddstr(main_w, getmaxx(main_w), buffer);