source: mainwin.c @ 7d4fbcd

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 7d4fbcd was 7d4fbcd, checked in by James M. Kretchmar <kretch@mit.edu>, 22 years ago
Initial check in
  • Property mode set to 100644
File size: 3.5 KB
Line 
1#include "owl.h"
2
3void owl_mainwin_init(owl_mainwin *mw) {
4  mw->curtruncated=0;
5  mw->lastdisplayed=-1;
6}
7
8void owl_mainwin_redisplay(owl_mainwin *mw) {
9  owl_message *m;
10  int i, j, p, q, lines, isfull;
11  int x, y, savey, recwinlines, start;
12  int topmsg, curmsg, color;
13  WINDOW *recwin;
14  owl_view *v;
15  owl_list *filtlist;
16  owl_filter *f;
17
18  recwin=owl_global_get_curs_recwin(&g);
19  topmsg=owl_global_get_topmsg(&g);
20  curmsg=owl_global_get_curmsg(&g);
21  v=owl_global_get_current_view(&g);
22
23  werase(recwin);
24
25  recwinlines=owl_global_get_recwin_lines(&g);
26  topmsg=owl_global_get_topmsg(&g);
27
28  /* if there are no messages, just draw a blank screen */
29  if (owl_view_get_size(v)==0) {
30    owl_global_set_topmsg(&g, 0);
31    mw->curtruncated=0;
32    mw->lastdisplayed=-1;
33    wnoutrefresh(recwin);
34    owl_global_set_needrefresh(&g);
35    return;
36  }
37
38  /* write the messages out */
39  isfull=0;
40  mw->curtruncated=0;
41  j=owl_view_get_size(v);
42  for (i=topmsg; i<j; i++) {
43    if (isfull) break;
44    m=owl_view_get_element(v, i);
45
46    /* hold on to y in case this is the current message or deleted */
47    getyx(recwin, y, x);
48    savey=y;
49
50    /* if it's the current message, account for a vert_offset */
51    if (i==owl_global_get_curmsg(&g)) {
52      start=owl_global_get_curmsg_vert_offset(&g);
53      lines=owl_message_get_numlines(m)-start;
54    } else {
55      start=0;
56      lines=owl_message_get_numlines(m);
57    }
58
59    /* if we match filters set the color */
60    color=OWL_COLOR_DEFAULT;
61    filtlist=owl_global_get_filterlist(&g);
62    q=owl_list_get_size(filtlist);
63    for (p=0; p<q; p++) {
64      f=owl_list_get_element(filtlist, p);
65      if (owl_filter_message_match(f, m)) {
66        if (owl_filter_get_color(f)!=OWL_COLOR_DEFAULT) color=owl_filter_get_color(f);
67      }
68    }
69
70    /* if we'll fill the screen print a partial message */
71    if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1;
72    if (y+lines > recwinlines-1) {
73      isfull=1;
74      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
75                               start,
76                               start+recwinlines-y,
77                               owl_global_get_rightshift(&g),
78                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
79                               color);
80    } else {
81      /* otherwise print the whole thing */
82      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
83                               start,
84                               start+lines,
85                               owl_global_get_rightshift(&g),
86                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
87                               color);
88    }
89
90
91    /* is it the current message and/or deleted? */
92    getyx(recwin, y, x);
93    wattrset(recwin, A_NORMAL);
94    if (owl_global_get_rightshift(&g)==0) {   /* this lame and should be fixed */
95      if (m==owl_view_get_element(v, curmsg)) {
96        wmove(recwin, savey, 0);
97        wattron(recwin, A_BOLD);       
98        if (owl_global_get_curmsg_vert_offset(&g)>0) {
99          waddstr(recwin, "+");
100        } else {
101          waddstr(recwin, "-");
102        }
103        if (!owl_message_is_delete(m)) {
104          waddstr(recwin, ">");
105        } else {
106          waddstr(recwin, "D");
107        }
108        wmove(recwin, y, x);
109        wattroff(recwin, A_BOLD);
110      } else if (owl_message_is_delete(m)) {
111        wmove(recwin, savey, 0);
112        waddstr(recwin, " D");
113        wmove(recwin, y, x);
114      }
115    }
116    wattroff(recwin, A_BOLD);
117  }
118  mw->lastdisplayed=i-1;
119
120  wnoutrefresh(recwin);
121  owl_global_set_needrefresh(&g);
122}
123
124
125int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw) {
126  if (mw->curtruncated) return(1);
127  return(0);
128}
129
130int owl_mainwin_get_last_msg(owl_mainwin *mw) {
131  /* return the number of the last message displayed. -1 if none */
132  return(mw->lastdisplayed);
133}
Note: See TracBrowser for help on using the repository browser.