home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / SHOWMAIL.C < prev    next >
Text File  |  1990-08-03  |  6KB  |  308 lines

  1.  /*
  2.  
  3. Title:    MsgEd
  4.  
  5. File:    Showmail.c
  6.  
  7. Author: Jim Nutt
  8.  
  9. Copr:    released into the PUBLIC DOMAIN 30 jul 1990 by jim nutt
  10.  
  11. Description:
  12.  
  13.     routines to display messages
  14.  
  15. */
  16.  
  17. #include "msged.h"
  18. #include "date.h"
  19.  
  20. LINE   *top = NULL, *bottom = NULL;
  21.  
  22. extern LINE *anchorpt;
  23.  
  24. static void _pascal up(void);
  25. static void _pascal down(void);
  26. static void _pascal pgdown(void);
  27. static void _pascal pgup(void);
  28.  
  29. void _pascal refresh(LINE * c, int y);
  30. extern void _pascal putl(LINE *l);
  31.  
  32. int _pascal showmsg(MSG *m)
  33.  
  34. {
  35.     int     command;
  36.  
  37.     showheader(m);
  38.  
  39.     refresh(m->text, 1);
  40.  
  41.     for (;;) {
  42.         gotoxy(1,1);
  43.         video_update();
  44.         switch (command = getkey()) {
  45.  
  46.                 case PGUP:
  47.             if (m->text != NULL)
  48.                                 pgup();
  49.             break;
  50.  
  51.                 case UP:
  52.             if (m->text != NULL)
  53.                                 up();
  54.             break;
  55.  
  56.         case SPACE:
  57.                 case PGDN:
  58.             if (m->text != NULL)
  59.                                 pgdown();
  60.             break;
  61.  
  62.                 case DOWN:
  63.             if (m->text != NULL)
  64.                                 down();
  65.             break;
  66.  
  67.         default:
  68.             return (command);
  69.         }
  70.     }
  71. }
  72.  
  73. void _pascal showheader(MSG *m)
  74.  
  75. {
  76.     int i;
  77.  
  78.     set_color(co_info);
  79.  
  80.         clrwnd(1, 1, maxx, 6);
  81.  
  82.     gotoxy(1, 1);
  83.  
  84.     bprintf("%03d/%03d %s", arealist[area].current+1, arealist[area].messages,
  85.         atime(m->timestamp));
  86.  
  87.     if (m->replyto)
  88.         bprintf("  Reply to #%d", m->replyto);
  89.  
  90.     if (m->replyfrom)
  91.         bprintf("  See #%d", m->replyfrom);
  92.  
  93.     gotoxy(1, 2);
  94.     bputs("From:   ");
  95.     set_color(co_normal);
  96.  
  97.     if (m->from.fidonet) {
  98.         bputs(m->isfrom);
  99.         set_color(co_info);
  100.         bputs(" of ");
  101.         set_color((m->from.notfound)?co_warn:co_normal);
  102.         bputs(show_address(m->from));
  103.     }
  104.     else {
  105.         bputs(show_address(m->from));
  106.         if (m->isfrom)
  107.             bprintf(" (%s)",m->isfrom);
  108.     }
  109.  
  110.     set_color(co_info);
  111.     gotoxy(1, 3);
  112.  
  113.     bputs("To:     ");
  114.  
  115.     if (!(m->isto == NULL)) {                               /*WRA*/
  116.         if (strcmpl(username,m->isto)==0)
  117.             set_color(co_hilite);
  118.         else
  119.             set_color(co_normal);
  120.  
  121.         if (m->to.fidonet) {
  122.             bputs(m->isto);
  123.             if (arealist[area].netmail) {
  124.                 set_color(co_info);
  125.                 bputs(" of ");
  126.                 set_color((m->to.notfound)?co_warn:co_normal);
  127.                 bputs(show_address(m->to));
  128.             }
  129.         }
  130.         else {
  131.             bputs(show_address(m->to));
  132.             if (m->isto)
  133.                 bprintf(" (%s)",m->isto);
  134.         }
  135.     }                                                       /*WRA*/
  136.  
  137.     set_color(co_info);
  138.     gotoxy(1, 4);
  139.  
  140.     if (m->attrib.attached)
  141.         bputs("Files:  ");
  142.     else
  143.         bputs("Subj:   ");
  144.  
  145.     set_color(co_normal);
  146.     bputs(m->subj);
  147.  
  148.     gotoxy(1, 5);
  149.  
  150.     set_color(co_info);
  151.     bputs("Attr:   ");
  152.  
  153.     set_color(co_normal);
  154.     if (m->attrib.private)
  155.         bputs("privileged ");
  156.     if (m->attrib.crash)
  157.         bputs("crash ");
  158.     if (m->attrib.recvd)
  159.         bputs("recvd ");
  160.     if (m->attrib.sent)
  161.         bputs("sent ");
  162.     if (m->attrib.attached)
  163.         bputs("f/a ");
  164.     if (m->attrib.killsent)
  165.         bputs("kill/sent ");
  166.     if (m->attrib.freq)
  167.         bputs("freq ");
  168.     if (m->attrib.ureq)
  169.         bputs("ureq ");
  170.     if (m->attrib.hold)
  171.         bputs("hold ");
  172.     if (m->attrib.orphan)
  173.         bputs("orphan ");
  174.     if (m->attrib.forward)
  175.         bputs("in transit ");
  176.     if (m->attrib.local)
  177.         bputs("local ");
  178.     if (m->attrib.direct)
  179.         bputs("direct ");
  180.     if (m->attrib.rreq)
  181.         bputs("rreq ");
  182.     if (m->attrib.rcpt)
  183.         bputs("rcpt ");
  184.     if (m->attrib.areq)
  185.         bputs("areq ");
  186.  
  187.     for (i = 1; i < maxx; i++) {
  188.            gotoxy(i,6);
  189.            bputc('_');
  190.     }
  191.  
  192.     gotoxy(1, 6);
  193.     set_color(co_hilite);
  194.     bprintf ("%s (%d)",arealist[area].description,m->msgnum);
  195.     set_color(co_normal);
  196. }
  197.  
  198. static void _pascal up()
  199.  
  200. {
  201.         int     i = 1;
  202.  
  203.     while (top->prev) {
  204.         top = top->prev;
  205.         if (shownotes || (*(top->text) != '\01')) {
  206.             scrolldown(1, 7, maxx, maxy, 1);
  207.             gotoxy(1, 7);
  208.             putl(top);
  209.             break;
  210.         }
  211.     }
  212.  
  213.     for (bottom = top;
  214.          (bottom->next != NULL) && (i < (maxy - 6));
  215.          bottom = bottom->next)
  216.         if ((*(bottom->text) != '\01') || shownotes)
  217.             i++;
  218. }
  219.  
  220. static void _pascal down()
  221.  
  222. {
  223.         int     i = 1;
  224.  
  225.     while (bottom->next) {
  226.         bottom = bottom->next;
  227.         if (shownotes || (*(bottom->text) != '\01')) {
  228.             scrollup(1, 7, maxx, maxy, 1);
  229.             gotoxy(1, maxy);
  230.             putl(bottom);
  231.             break;
  232.         }
  233.     }
  234.  
  235.     for (top = bottom; (top->prev != NULL) && (i < (maxy - 6)); top = top->prev)
  236.         if ((*(top->text) != '\01') || shownotes)
  237.             i++;
  238. }
  239.  
  240. static void _pascal pgup()
  241.  
  242. {
  243.     int i = 0;
  244.  
  245.     if ((top->prev == NULL) || ((*(top->prev->text) == 1) && !shownotes))
  246.         return;
  247.  
  248.     for (bottom = top; (top->prev != NULL) && (i < (maxy - 6)); top = top->prev)
  249.         if ((*(top->text) != '\01') || shownotes)
  250.             i++;
  251.  
  252.     refresh(top, 1);
  253. }
  254.  
  255. static void _pascal pgdown()
  256.  
  257. {
  258.     int     i = 1;
  259.  
  260.     if ((bottom->next == NULL) || ((*(bottom->next->text) == 1) && !shownotes))
  261.         return;
  262.  
  263.     clrwnd(1, 7, maxx, maxy);
  264.  
  265.     for (top = bottom; (bottom->next != NULL) && (i < (maxy - 6)); bottom = bottom->next) {
  266.         if ((*(bottom->text) != '\01') || shownotes) {
  267.             gotoxy(1, 6 + i++);
  268.             putl(bottom);
  269.         }
  270.     }
  271.     if ((*(bottom->text) != '\01') || shownotes) {
  272.         gotoxy(1, 6 + i);
  273.         putl(bottom);
  274.     }
  275. }
  276.  
  277. void _pascal refresh(LINE * c, int y)
  278.  
  279. {
  280.     int     i = y;
  281.  
  282.     top = bottom = c;
  283.     clrwnd(1, (i + 6), maxx, maxy);
  284.  
  285.     if ((top == NULL) || (top->text == NULL))
  286.         return;
  287.  
  288.     while ((top != NULL) && ((*top->text == '\01') && !shownotes))
  289.         top = top->next;
  290.  
  291.     if (top == NULL)
  292.         return;
  293.  
  294.         for (bottom = top; (bottom->next != NULL) && (i < (maxy - 6)); bottom = bottom->next) {
  295.         if ((*(bottom->text) != '\01') || shownotes) {
  296.             gotoxy(1, 6 + i++);
  297.             putl(bottom);
  298.         }
  299.     }
  300.  
  301.     if ((*(bottom->text) != '\01') || shownotes) {
  302.         gotoxy(1, 6 + i);
  303.         putl(bottom);
  304.     }
  305. }
  306.  
  307.  
  308.