[7d4fbcd] | 1 | #include "owl.h" |
---|
| 2 | |
---|
[37eab7f] | 3 | void owl_mainwin_init(owl_mainwin *mw) |
---|
| 4 | { |
---|
[7d4fbcd] | 5 | mw->curtruncated=0; |
---|
| 6 | mw->lastdisplayed=-1; |
---|
| 7 | } |
---|
| 8 | |
---|
[37eab7f] | 9 | void owl_mainwin_redisplay(owl_mainwin *mw) |
---|
| 10 | { |
---|
[7d4fbcd] | 11 | owl_message *m; |
---|
[129e609] | 12 | int i, lines, isfull, viewsize; |
---|
[7d4fbcd] | 13 | int x, y, savey, recwinlines, start; |
---|
[f63a681] | 14 | int topmsg, curmsg, markedmsgid, fgcolor, bgcolor; |
---|
[7d4fbcd] | 15 | WINDOW *recwin; |
---|
[9e5c9f3] | 16 | const owl_view *v; |
---|
[129e609] | 17 | GList *fl; |
---|
[4542047] | 18 | const owl_filter *f; |
---|
[7d4fbcd] | 19 | |
---|
[f63a681] | 20 | recwin = owl_global_get_curs_recwin(&g); |
---|
| 21 | topmsg = owl_global_get_topmsg(&g); |
---|
| 22 | curmsg = owl_global_get_curmsg(&g); |
---|
| 23 | markedmsgid = owl_global_get_markedmsgid(&g); |
---|
| 24 | v = owl_global_get_current_view(&g); |
---|
[8fa9562] | 25 | owl_fmtext_reset_colorpairs(); |
---|
[7d4fbcd] | 26 | |
---|
[f2f9314] | 27 | if (v==NULL) { |
---|
| 28 | owl_function_debugmsg("Hit a null window in owl_mainwin_redisplay."); |
---|
| 29 | return; |
---|
| 30 | } |
---|
| 31 | |
---|
[7d4fbcd] | 32 | werase(recwin); |
---|
| 33 | |
---|
| 34 | recwinlines=owl_global_get_recwin_lines(&g); |
---|
[5eeea3b] | 35 | viewsize=owl_view_get_size(v); |
---|
[7d4fbcd] | 36 | |
---|
[5eeea3b] | 37 | /* if there are no messages or if topmsg is past the end of the messages, |
---|
| 38 | * just draw a blank screen */ |
---|
| 39 | if (viewsize==0 || topmsg>=viewsize) { |
---|
| 40 | if (viewsize==0) { |
---|
| 41 | owl_global_set_topmsg(&g, 0); |
---|
| 42 | } |
---|
[7d4fbcd] | 43 | mw->curtruncated=0; |
---|
| 44 | mw->lastdisplayed=-1; |
---|
| 45 | owl_global_set_needrefresh(&g); |
---|
| 46 | return; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /* write the messages out */ |
---|
| 50 | isfull=0; |
---|
| 51 | mw->curtruncated=0; |
---|
[f2e36b5] | 52 | mw->lasttruncated=0; |
---|
[5eeea3b] | 53 | |
---|
| 54 | for (i=topmsg; i<viewsize; i++) { |
---|
[7d4fbcd] | 55 | if (isfull) break; |
---|
| 56 | m=owl_view_get_element(v, i); |
---|
| 57 | |
---|
| 58 | /* hold on to y in case this is the current message or deleted */ |
---|
| 59 | getyx(recwin, y, x); |
---|
| 60 | savey=y; |
---|
| 61 | |
---|
| 62 | /* if it's the current message, account for a vert_offset */ |
---|
| 63 | if (i==owl_global_get_curmsg(&g)) { |
---|
| 64 | start=owl_global_get_curmsg_vert_offset(&g); |
---|
| 65 | lines=owl_message_get_numlines(m)-start; |
---|
| 66 | } else { |
---|
| 67 | start=0; |
---|
| 68 | lines=owl_message_get_numlines(m); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | /* if we match filters set the color */ |
---|
[8fa9562] | 72 | fgcolor=OWL_COLOR_DEFAULT; |
---|
| 73 | bgcolor=OWL_COLOR_DEFAULT; |
---|
[129e609] | 74 | for (fl = g.filterlist; fl; fl = g_list_next(fl)) { |
---|
| 75 | f = fl->data; |
---|
[c2c5c77] | 76 | if ((owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) || |
---|
| 77 | (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT)) { |
---|
| 78 | if (owl_filter_message_match(f, m)) { |
---|
| 79 | if (owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) fgcolor=owl_filter_get_fgcolor(f); |
---|
| 80 | if (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT) bgcolor=owl_filter_get_bgcolor(f); |
---|
| 81 | } |
---|
[7d4fbcd] | 82 | } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | /* if we'll fill the screen print a partial message */ |
---|
| 86 | if ((y+lines > recwinlines) && (i==owl_global_get_curmsg(&g))) mw->curtruncated=1; |
---|
[f2e36b5] | 87 | if (y+lines > recwinlines) mw->lasttruncated=1; |
---|
[7d4fbcd] | 88 | if (y+lines > recwinlines-1) { |
---|
| 89 | isfull=1; |
---|
| 90 | owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g), |
---|
| 91 | start, |
---|
| 92 | start+recwinlines-y, |
---|
| 93 | owl_global_get_rightshift(&g), |
---|
| 94 | owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1, |
---|
[8fa9562] | 95 | fgcolor, bgcolor); |
---|
[7d4fbcd] | 96 | } else { |
---|
| 97 | /* otherwise print the whole thing */ |
---|
| 98 | owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g), |
---|
| 99 | start, |
---|
| 100 | start+lines, |
---|
| 101 | owl_global_get_rightshift(&g), |
---|
| 102 | owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1, |
---|
[8fa9562] | 103 | fgcolor, bgcolor); |
---|
[7d4fbcd] | 104 | } |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /* is it the current message and/or deleted? */ |
---|
| 108 | getyx(recwin, y, x); |
---|
| 109 | wattrset(recwin, A_NORMAL); |
---|
| 110 | if (owl_global_get_rightshift(&g)==0) { /* this lame and should be fixed */ |
---|
| 111 | if (m==owl_view_get_element(v, curmsg)) { |
---|
| 112 | wmove(recwin, savey, 0); |
---|
| 113 | wattron(recwin, A_BOLD); |
---|
| 114 | if (owl_global_get_curmsg_vert_offset(&g)>0) { |
---|
| 115 | waddstr(recwin, "+"); |
---|
| 116 | } else { |
---|
| 117 | waddstr(recwin, "-"); |
---|
| 118 | } |
---|
[f63a681] | 119 | if (owl_message_is_delete(m)) { |
---|
[7d4fbcd] | 120 | waddstr(recwin, "D"); |
---|
[f63a681] | 121 | } else if (markedmsgid == owl_message_get_id(m)) { |
---|
| 122 | waddstr(recwin, "*"); |
---|
| 123 | } else { |
---|
| 124 | waddstr(recwin, ">"); |
---|
[7d4fbcd] | 125 | } |
---|
| 126 | wmove(recwin, y, x); |
---|
| 127 | wattroff(recwin, A_BOLD); |
---|
| 128 | } else if (owl_message_is_delete(m)) { |
---|
| 129 | wmove(recwin, savey, 0); |
---|
| 130 | waddstr(recwin, " D"); |
---|
| 131 | wmove(recwin, y, x); |
---|
[f63a681] | 132 | } else if (markedmsgid == owl_message_get_id(m)) { |
---|
| 133 | wmove(recwin, savey, 0); |
---|
| 134 | waddstr(recwin, " *"); |
---|
| 135 | wmove(recwin, y, x); |
---|
[7d4fbcd] | 136 | } |
---|
| 137 | } |
---|
| 138 | wattroff(recwin, A_BOLD); |
---|
| 139 | } |
---|
| 140 | mw->lastdisplayed=i-1; |
---|
| 141 | |
---|
| 142 | owl_global_set_needrefresh(&g); |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | |
---|
[eaa9053] | 146 | int owl_mainwin_is_curmsg_truncated(const owl_mainwin *mw) |
---|
[37eab7f] | 147 | { |
---|
[7d4fbcd] | 148 | if (mw->curtruncated) return(1); |
---|
| 149 | return(0); |
---|
| 150 | } |
---|
| 151 | |
---|
[eaa9053] | 152 | int owl_mainwin_is_last_msg_truncated(const owl_mainwin *mw) |
---|
[37eab7f] | 153 | { |
---|
[f2e36b5] | 154 | if (mw->lasttruncated) return(1); |
---|
| 155 | return(0); |
---|
| 156 | } |
---|
| 157 | |
---|
[eaa9053] | 158 | int owl_mainwin_get_last_msg(const owl_mainwin *mw) |
---|
[37eab7f] | 159 | { |
---|
[7d4fbcd] | 160 | /* return the number of the last message displayed. -1 if none */ |
---|
| 161 | return(mw->lastdisplayed); |
---|
| 162 | } |
---|