source: mainwin.c @ f2e36b5

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since f2e36b5 was f2e36b5, checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
* Page-down will not skip past the last message if its truncated. * Added C-t binding for transposing characters. (from jdaniel)
  • Property mode set to 100644
File size: 3.7 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  mw->lasttruncated=0;
44  j=owl_view_get_size(v);
45  for (i=topmsg; i<j; i++) {
46    if (isfull) break;
47    m=owl_view_get_element(v, i);
48
49    /* hold on to y in case this is the current message or deleted */
50    getyx(recwin, y, x);
51    savey=y;
52
53    /* if it's the current message, account for a vert_offset */
54    if (i==owl_global_get_curmsg(&g)) {
55      start=owl_global_get_curmsg_vert_offset(&g);
56      lines=owl_message_get_numlines(m)-start;
57    } else {
58      start=0;
59      lines=owl_message_get_numlines(m);
60    }
61
62    /* if we match filters set the color */
63    color=OWL_COLOR_DEFAULT;
64    filtlist=owl_global_get_filterlist(&g);
65    q=owl_list_get_size(filtlist);
66    for (p=0; p<q; p++) {
67      f=owl_list_get_element(filtlist, p);
68      if (owl_filter_message_match(f, m)) {
69        if (owl_filter_get_color(f)!=OWL_COLOR_DEFAULT) color=owl_filter_get_color(f);
70      }
71    }
72
73    /* if we'll fill the screen print a partial message */
74    if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1;
75    if (y+lines > recwinlines) mw->lasttruncated=1;
76    if (y+lines > recwinlines-1) {
77      isfull=1;
78      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
79                               start,
80                               start+recwinlines-y,
81                               owl_global_get_rightshift(&g),
82                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
83                               color);
84    } else {
85      /* otherwise print the whole thing */
86      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
87                               start,
88                               start+lines,
89                               owl_global_get_rightshift(&g),
90                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
91                               color);
92    }
93
94
95    /* is it the current message and/or deleted? */
96    getyx(recwin, y, x);
97    wattrset(recwin, A_NORMAL);
98    if (owl_global_get_rightshift(&g)==0) {   /* this lame and should be fixed */
99      if (m==owl_view_get_element(v, curmsg)) {
100        wmove(recwin, savey, 0);
101        wattron(recwin, A_BOLD);       
102        if (owl_global_get_curmsg_vert_offset(&g)>0) {
103          waddstr(recwin, "+");
104        } else {
105          waddstr(recwin, "-");
106        }
107        if (!owl_message_is_delete(m)) {
108          waddstr(recwin, ">");
109        } else {
110          waddstr(recwin, "D");
111        }
112        wmove(recwin, y, x);
113        wattroff(recwin, A_BOLD);
114      } else if (owl_message_is_delete(m)) {
115        wmove(recwin, savey, 0);
116        waddstr(recwin, " D");
117        wmove(recwin, y, x);
118      }
119    }
120    wattroff(recwin, A_BOLD);
121  }
122  mw->lastdisplayed=i-1;
123
124  wnoutrefresh(recwin);
125  owl_global_set_needrefresh(&g);
126}
127
128
129int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw) {
130  if (mw->curtruncated) return(1);
131  return(0);
132}
133
134int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw) {
135  if (mw->lasttruncated) return(1);
136  return(0);
137}
138
139int owl_mainwin_get_last_msg(owl_mainwin *mw) {
140  /* return the number of the last message displayed. -1 if none */
141  return(mw->lastdisplayed);
142}
Note: See TracBrowser for help on using the repository browser.