source: mainwin.c @ 1aee7d9

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