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