Rocco Rutte:
[apps/madmutt.git] / pager.c
diff --git a/pager.c b/pager.c
index 752792b..25396d7 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -105,7 +105,7 @@ struct syntax_t {
 };
 
 struct line_t {
-  long offset;
+  LOFF_T offset;
   short type;
   short continuation;
   short chunks;
@@ -647,6 +647,9 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
   return class;
 }
 
+static int brailleLine = -1;
+static int brailleCol = -1;
+
 static int check_attachment_marker (char *);
 
 static void
@@ -659,8 +662,10 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
   int found, offset, null_rx, i;
 
   if (n == 0 || ISHEADER (lineInfo[n - 1].type)) {
-    if (buf[0] == '\n')
+    if (buf[0] == '\n') {
       lineInfo[n].type = MT_COLOR_NORMAL;
+      getyx(stdscr, brailleLine, brailleCol);
+    }
     else if (n > 0 && (buf[0] == ' ' || buf[0] == '\t')) {
       lineInfo[n].type = lineInfo[n - 1].type;  /* wrapped line */
       (lineInfo[n].syntax)[0].color = (lineInfo[n - 1].syntax)[0].color;
@@ -903,7 +908,7 @@ static int trim_incomplete_mbyte(unsigned char *buf, size_t len) {
 }
 
 static int
-fill_buffer (FILE * f, long *last_pos, long offset, unsigned char *buf,
+fill_buffer (FILE * f, LOFF_T *last_pos, LOFF_T offset, unsigned char *buf,
              unsigned char *fmt, size_t blen, int *buf_ready)
 {
   unsigned char *p;
@@ -912,12 +917,12 @@ fill_buffer (FILE * f, long *last_pos, long offset, unsigned char *buf,
   if (*buf_ready == 0) {
     buf[blen - 1] = 0;
     if (offset != *last_pos)
-      fseek (f, offset, 0);
+      fseeko (f, offset, 0);
     if (fgets ((char *) buf, blen - 1, f) == NULL) {
       fmt[0] = 0;
       return (-1);
     }
-    *last_pos = ftell (f);
+    *last_pos = ftello (f);
     b_read = (int) (*last_pos - offset);
     *buf_ready = 1;
 
@@ -1125,7 +1130,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
  */
 
 static int
-display_line (FILE * f, long *last_pos, struct line_t **lineInfo, int n,
+display_line (FILE * f, LOFF_T *last_pos, struct line_t **lineInfo, int n,
               int *last, int *max, int flags, struct q_class_t **QuoteList,
               int *q_level, int *force_redraw, regex_t * SearchRE)
 {
@@ -1418,7 +1423,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
   int r = -1;
   int redraw = REDRAW_FULL;
   FILE *fp = NULL;
-  long last_pos = 0, last_offset = 0;
+  LOFF_T last_pos = 0, last_offset = 0;
   int old_smart_wrap, old_markers;
   struct stat sb;
   regex_t SearchRE;
@@ -1695,7 +1700,13 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
 
     redraw = 0;
 
-    move (statusoffset, COLS - 1);
+    if (option(OPTBRAILLEFRIENDLY)) {
+      if (brailleLine!=-1) {
+        move(brailleLine+1, 0);
+        brailleLine = -1;
+      }
+    } else
+      move (statusoffset, COLS-1);
     mutt_refresh ();
 
     if (IsHeader (extra) && OldHdr == extra->hdr && TopLine != topline
@@ -2609,7 +2620,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
   fclose (fp);
   if (IsHeader (extra)) {
     Context->msgnotreadyet = -1;
-    if (rc != -1) {
+    if (rc == -1)
+      OldHdr = NULL;
+    else {
       TopLine = topline;
       OldHdr = extra->hdr;
     }