source: mainwin.c @ b4ef908

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since b4ef908 was c2c5c77, checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 18 years ago
Adding 256-color support. This requires a version of ncurses that supports ABI-6. Colors beyond the first eight are refered to by number. Perl now has the number of colors exposed to it by way of BarnOwl::getnumcolors() and also has a mechanism for undefining filters using BarnOwl::_remove_filter([filter-name]) You can't remove the 'all' filter or the current filter.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1#include "owl.h"
2
3static const char fileIdent[] = "$Id$";
4
5void owl_mainwin_init(owl_mainwin *mw)
6{
7  mw->curtruncated=0;
8  mw->lastdisplayed=-1;
9}
10
11void owl_mainwin_redisplay(owl_mainwin *mw)
12{
13  owl_message *m;
14  int i, p, q, lines, isfull, viewsize;
15  int x, y, savey, recwinlines, start;
16  int topmsg, curmsg, fgcolor, bgcolor;
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  owl_fmtext_reset_colorpairs();
27
28  if (v==NULL) {
29    owl_function_debugmsg("Hit a null window in owl_mainwin_redisplay.");
30    return;
31  }
32
33  werase(recwin);
34
35  recwinlines=owl_global_get_recwin_lines(&g);
36  topmsg=owl_global_get_topmsg(&g);
37  viewsize=owl_view_get_size(v);
38
39  /* if there are no messages or if topmsg is past the end of the messages,
40   * just draw a blank screen */
41  if (viewsize==0 || topmsg>=viewsize) {
42    if (viewsize==0) {
43      owl_global_set_topmsg(&g, 0);
44    }
45    mw->curtruncated=0;
46    mw->lastdisplayed=-1;
47    wnoutrefresh(recwin);
48    owl_global_set_needrefresh(&g);
49    return;
50  }
51
52  /* write the messages out */
53  isfull=0;
54  mw->curtruncated=0;
55  mw->lasttruncated=0;
56
57  for (i=topmsg; i<viewsize; i++) {
58    if (isfull) break;
59    m=owl_view_get_element(v, i);
60
61    /* hold on to y in case this is the current message or deleted */
62    getyx(recwin, y, x);
63    savey=y;
64
65    /* if it's the current message, account for a vert_offset */
66    if (i==owl_global_get_curmsg(&g)) {
67      start=owl_global_get_curmsg_vert_offset(&g);
68      lines=owl_message_get_numlines(m)-start;
69    } else {
70      start=0;
71      lines=owl_message_get_numlines(m);
72    }
73
74    /* if we match filters set the color */
75    fgcolor=OWL_COLOR_DEFAULT;
76    bgcolor=OWL_COLOR_DEFAULT;
77    filtlist=owl_global_get_filterlist(&g);
78    q=owl_list_get_size(filtlist);
79    for (p=0; p<q; p++) {
80      f=owl_list_get_element(filtlist, p);
81      if ((owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) ||
82          (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT)) {
83        if (owl_filter_message_match(f, m)) {
84          if (owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) fgcolor=owl_filter_get_fgcolor(f);
85          if (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT) bgcolor=owl_filter_get_bgcolor(f);
86        }
87      }
88    }
89
90    /* if we'll fill the screen print a partial message */
91    if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1;
92    if (y+lines > recwinlines) mw->lasttruncated=1;
93    if (y+lines > recwinlines-1) {
94      isfull=1;
95      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
96                               start,
97                               start+recwinlines-y,
98                               owl_global_get_rightshift(&g),
99                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
100                               fgcolor, bgcolor);
101    } else {
102      /* otherwise print the whole thing */
103      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
104                               start,
105                               start+lines,
106                               owl_global_get_rightshift(&g),
107                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
108                               fgcolor, bgcolor);
109    }
110
111
112    /* is it the current message and/or deleted? */
113    getyx(recwin, y, x);
114    wattrset(recwin, A_NORMAL);
115    if (owl_global_get_rightshift(&g)==0) {   /* this lame and should be fixed */
116      if (m==owl_view_get_element(v, curmsg)) {
117        wmove(recwin, savey, 0);
118        wattron(recwin, A_BOLD);       
119        if (owl_global_get_curmsg_vert_offset(&g)>0) {
120          waddstr(recwin, "+");
121        } else {
122          waddstr(recwin, "-");
123        }
124        if (!owl_message_is_delete(m)) {
125          waddstr(recwin, ">");
126        } else {
127          waddstr(recwin, "D");
128        }
129        wmove(recwin, y, x);
130        wattroff(recwin, A_BOLD);
131      } else if (owl_message_is_delete(m)) {
132        wmove(recwin, savey, 0);
133        waddstr(recwin, " D");
134        wmove(recwin, y, x);
135      }
136    }
137    wattroff(recwin, A_BOLD);
138  }
139  mw->lastdisplayed=i-1;
140
141  wnoutrefresh(recwin);
142  owl_global_set_needrefresh(&g);
143}
144
145
146int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw)
147{
148  if (mw->curtruncated) return(1);
149  return(0);
150}
151
152int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw)
153{
154  if (mw->lasttruncated) return(1);
155  return(0);
156}
157
158int owl_mainwin_get_last_msg(owl_mainwin *mw)
159{
160  /* return the number of the last message displayed. -1 if none */
161  return(mw->lastdisplayed);
162}
Note: See TracBrowser for help on using the repository browser.