1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
/* Copyright (c) 2002,2003,2004,2009 James M. Kretchmar
*
* This file is part of Owl.
*
* Owl is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Owl is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Owl. If not, see <http://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------
*
* As of Owl version 2.1.12 there are patches contributed by
* developers of the branched BarnOwl project, Copyright (c)
* 2006-2009 The BarnOwl Developers. All rights reserved.
*/
#include "owl.h"
static const char fileIdent[] = "$Id: mainwin.c,v 1.8 2009/03/29 12:38:21 kretch Exp $";
void owl_mainwin_init(owl_mainwin *mw)
{
mw->curtruncated=0;
mw->lastdisplayed=-1;
}
void owl_mainwin_redisplay(owl_mainwin *mw)
{
owl_message *m;
int i, p, q, lines, isfull, viewsize;
int x, y, savey, recwinlines, start;
int topmsg, curmsg, color;
WINDOW *recwin;
owl_view *v;
owl_list *filtlist;
owl_filter *f;
recwin=owl_global_get_curs_recwin(&g);
topmsg=owl_global_get_topmsg(&g);
curmsg=owl_global_get_curmsg(&g);
v=owl_global_get_current_view(&g);
if (v==NULL) {
owl_function_debugmsg("Hit a null window in owl_mainwin_redisplay.");
return;
}
werase(recwin);
recwinlines=owl_global_get_recwin_lines(&g);
topmsg=owl_global_get_topmsg(&g);
viewsize=owl_view_get_size(v);
/* if there are no messages or if topmsg is past the end of the messages,
* just draw a blank screen */
if (viewsize==0 || topmsg>=viewsize) {
if (viewsize==0) {
owl_global_set_topmsg(&g, 0);
}
mw->curtruncated=0;
mw->lastdisplayed=-1;
wnoutrefresh(recwin);
owl_global_set_needrefresh(&g);
return;
}
/* write the messages out */
isfull=0;
mw->curtruncated=0;
mw->lasttruncated=0;
for (i=topmsg; i<viewsize; i++) {
if (isfull) break;
m=owl_view_get_element(v, i);
/* hold on to y in case this is the current message or deleted */
getyx(recwin, y, x);
savey=y;
/* if it's the current message, account for a vert_offset */
if (i==owl_global_get_curmsg(&g)) {
start=owl_global_get_curmsg_vert_offset(&g);
lines=owl_message_get_numlines(m)-start;
} else {
start=0;
lines=owl_message_get_numlines(m);
}
/* if we match filters set the color */
color=OWL_COLOR_DEFAULT;
filtlist=owl_global_get_filterlist(&g);
q=owl_list_get_size(filtlist);
for (p=0; p<q; p++) {
f=owl_list_get_element(filtlist, p);
if (owl_filter_message_match(f, m)) {
if (owl_filter_get_color(f)!=OWL_COLOR_DEFAULT) color=owl_filter_get_color(f);
}
}
/* if we'll fill the screen print a partial message */
if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1;
if (y+lines > recwinlines) mw->lasttruncated=1;
if (y+lines > recwinlines-1) {
isfull=1;
owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
start,
start+recwinlines-y,
owl_global_get_rightshift(&g),
owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
color);
} else {
/* otherwise print the whole thing */
owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
start,
start+lines,
owl_global_get_rightshift(&g),
owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1,
color);
}
/* is it the current message and/or deleted? */
getyx(recwin, y, x);
wattrset(recwin, A_NORMAL);
if (owl_global_get_rightshift(&g)==0) { /* this lame and should be fixed */
if (m==owl_view_get_element(v, curmsg)) {
wmove(recwin, savey, 0);
wattron(recwin, A_BOLD);
if (owl_global_get_curmsg_vert_offset(&g)>0) {
waddstr(recwin, "+");
} else {
waddstr(recwin, "-");
}
if (!owl_message_is_delete(m)) {
waddstr(recwin, ">");
} else {
waddstr(recwin, "D");
}
wmove(recwin, y, x);
wattroff(recwin, A_BOLD);
} else if (owl_message_is_delete(m)) {
wmove(recwin, savey, 0);
waddstr(recwin, " D");
wmove(recwin, y, x);
}
}
wattroff(recwin, A_BOLD);
}
mw->lastdisplayed=i-1;
wnoutrefresh(recwin);
owl_global_set_needrefresh(&g);
}
int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw)
{
if (mw->curtruncated) return(1);
return(0);
}
int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw)
{
if (mw->lasttruncated) return(1);
return(0);
}
int owl_mainwin_get_last_msg(owl_mainwin *mw)
{
/* return the number of the last message displayed. -1 if none */
return(mw->lastdisplayed);
}
|