source: mainwin.c @ 985f85b

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 985f85b was 5eeea3b, checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
Modified the behavior of last so that "> >" will clear the screen. The new behavior of last is: Moves the pointer to the last message in the view. If we are already at the last message in the view, blanks the screen and moves just past the end of the view so that new messages will appear starting at the top of the screen. Fixed a typo in the help for smartzpunt. Fixed functions to handle curmsg being past the end of the view.
  • Property mode set to 100644
File size: 3.8 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, p, q, lines, isfull, viewsize;
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  viewsize=owl_view_get_size(v);
30
31  /* if there are no messages or if topmsg is past the end of the messages,
32   * just draw a blank screen */
33  if (viewsize==0 || topmsg>=viewsize) {
34    if (viewsize==0) {
35      owl_global_set_topmsg(&g, 0);
36    }
37    mw->curtruncated=0;
38    mw->lastdisplayed=-1;
39    wnoutrefresh(recwin);
40    owl_global_set_needrefresh(&g);
41    return;
42  }
43
44  /* write the messages out */
45  isfull=0;
46  mw->curtruncated=0;
47  mw->lasttruncated=0;
48
49  for (i=topmsg; i<viewsize; i++) {
50    if (isfull) break;
51    m=owl_view_get_element(v, i);
52
53    /* hold on to y in case this is the current message or deleted */
54    getyx(recwin, y, x);
55    savey=y;
56
57    /* if it's the current message, account for a vert_offset */
58    if (i==owl_global_get_curmsg(&g)) {
59      start=owl_global_get_curmsg_vert_offset(&g);
60      lines=owl_message_get_numlines(m)-start;
61    } else {
62      start=0;
63      lines=owl_message_get_numlines(m);
64    }
65
66    /* if we match filters set the color */
67    color=OWL_COLOR_DEFAULT;
68    filtlist=owl_global_get_filterlist(&g);
69    q=owl_list_get_size(filtlist);
70    for (p=0; p<q; p++) {
71      f=owl_list_get_element(filtlist, p);
72      if (owl_filter_message_match(f, m)) {
73        if (owl_filter_get_color(f)!=OWL_COLOR_DEFAULT) color=owl_filter_get_color(f);
74      }
75    }
76
77    /* if we'll fill the screen print a partial message */
78    if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1;
79    if (y+lines > recwinlines) mw->lasttruncated=1;
80    if (y+lines > recwinlines-1) {
81      isfull=1;
82      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
83                               start,
84                               start+recwinlines-y,
85                               owl_global_get_rightshift(&g),
86                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
87                               color);
88    } else {
89      /* otherwise print the whole thing */
90      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
91                               start,
92                               start+lines,
93                               owl_global_get_rightshift(&g),
94                               owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
95                               color);
96    }
97
98
99    /* is it the current message and/or deleted? */
100    getyx(recwin, y, x);
101    wattrset(recwin, A_NORMAL);
102    if (owl_global_get_rightshift(&g)==0) {   /* this lame and should be fixed */
103      if (m==owl_view_get_element(v, curmsg)) {
104        wmove(recwin, savey, 0);
105        wattron(recwin, A_BOLD);       
106        if (owl_global_get_curmsg_vert_offset(&g)>0) {
107          waddstr(recwin, "+");
108        } else {
109          waddstr(recwin, "-");
110        }
111        if (!owl_message_is_delete(m)) {
112          waddstr(recwin, ">");
113        } else {
114          waddstr(recwin, "D");
115        }
116        wmove(recwin, y, x);
117        wattroff(recwin, A_BOLD);
118      } else if (owl_message_is_delete(m)) {
119        wmove(recwin, savey, 0);
120        waddstr(recwin, " D");
121        wmove(recwin, y, x);
122      }
123    }
124    wattroff(recwin, A_BOLD);
125  }
126  mw->lastdisplayed=i-1;
127
128  wnoutrefresh(recwin);
129  owl_global_set_needrefresh(&g);
130}
131
132
133int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw) {
134  if (mw->curtruncated) return(1);
135  return(0);
136}
137
138int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw) {
139  if (mw->lasttruncated) return(1);
140  return(0);
141}
142
143int owl_mainwin_get_last_msg(owl_mainwin *mw) {
144  /* return the number of the last message displayed. -1 if none */
145  return(mw->lastdisplayed);
146}
Note: See TracBrowser for help on using the repository browser.