source: mainwin.c @ f1645da

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