static char rcsid[] = "@(#)$Id: message_screen.c,v 1.8 2006/04/09 07:37:42 hurtta Exp $";
/******************************************************************************
* The Elm (ME+) Mail System - $Revision: 1.8 $ $State: Exp $
*
* Author: Kari Hurtta <hurtta+elm@posti.FMI.FI>
******************************************************************************
* Inludes code from screen.c which have following copyright:
*
* The Elm Mail System
*
* Copyright (c) 1988-1992 USENET Community Trust
* Copyright (c) 1986,1987 Dave Taylor
*****************************************************************************/
#include "def_mcommon.h"
#include "s_elm.h"
static void print_dummy_header_line P_((int message_number,int selected,
struct menu_context *page));
static void print_header_line P_((struct header_rec *entry, int message_number,
int selected, struct string *from,
int really_to, struct menu_context *page,
char *status, int tagged));
void mc_screen_print_mbx_line(u,idx, page)
union mcommon_union *u;
int idx;
struct menu_context *page;
{
struct MailboxView *mbxview = u->mbx.mw;
/* from function show_headers() */
int current = get_current(mbxview);
struct header_rec * hdr = give_header(mbxview,idx);
if (hdr) {
char * status = show_status_message(mbxview,idx);
struct string * newfrom = NULL;
int using_to = DisplayAddress(hdr,&newfrom);
int tagged = ' ';
if (ison_status_message(mbxview,idx,status_basic,TAGGED))
tagged = '+';
else if (ison_status_message(mbxview,idx,status_1,S1_FLAGGED))
tagged = 'F';
else
tagged = ' ';
if (idx == current-1)
print_header_line(hdr, idx+1, TRUE, newfrom, using_to, page,
status,tagged);
else
print_header_line(hdr, idx+1, FALSE, newfrom, using_to, page,
status,tagged);
free_string(&newfrom);
} else {
if (idx == current-1)
print_dummy_header_line(idx+1,TRUE, page);
else
print_dummy_header_line(idx+1,FALSE, page);
}
}
static void print_dummy_header_line(message_number,selected,page)
int message_number;
int selected;
struct menu_context *page;
{
int l;
int X;
struct string * buffer = NULL;
struct string * buffer1 = NULL;
int LINES, COLUMNS;
menu_get_sizes(page, &LINES, &COLUMNS);
if (selected && has_highlighting && ! arrow_cursor)
menu_StartXX(page,pg_INVERSE);
buffer = format_string(CATGETS(elm_msg_cat, ElmSet,
ElmNotCollected,
"%.2s-- %-3d <--- message not collected --->"),
(selected && arrow_cursor)? "->" : " ",
message_number);
X = 0;
buffer1 = curses_printable_clip(buffer,&X,COLUMNS,
&l,
COLUMNS);
free_string(&buffer);
if (buffer1) {
menu_Write_to_screen(page,FRM("%S"),buffer1);
free_string(&buffer1);
}
if (selected && !arrow_cursor) {
while (l < COLUMNS) {
menu_Writechar(page,' ');
l++;
}
}
if (selected && has_highlighting && ! arrow_cursor)
menu_EndXX(page,pg_INVERSE);
menu_Writechar(page,'\r');
menu_Writechar(page,'\n');
}
static void print_header_line(entry,message_number,selected,from,really_to,
page,status,tagged)
struct header_rec *entry;
int message_number;
int selected;
struct string *from;
int really_to;
struct menu_context *page;
char * status;
int tagged;
{
/** Print in buffer the message header ... entry is the current
message entry, 'from' is a modified (displayable) from line,
'highlight' is either TRUE or FALSE, and 'message_number'
is the number of the message.
**/
int who_width = 18, subj_width = 0;
int header_without_subj_width;
struct string * buffer = NULL;
struct string * buffer1 = NULL;
struct string * bufferwho = NULL;
int X,len1,fill_len;
int was_len;
int LINES, COLUMNS;
if (!status)
status = "??";
menu_get_sizes(page, &LINES, &COLUMNS);
/* truncate 'from' to 18 characters -
* this includes the leading "To" if really_to is true.
*/
if (*entry->time_menu == '\0')
make_menu_date(entry);
/* show "To " in a way that it can never be truncated. */
if (really_to) {
who_width -= 3;
}
if (selected && has_highlighting && ! arrow_cursor)
menu_StartXX(page,pg_INVERSE);
X = 0;
bufferwho = curses_printable_clip(from,&X,who_width,&len1,who_width);
if (!bufferwho) {
bufferwho = new_string(display_charset);
fill_len = who_width;
} else
fill_len = who_width - len1;
if (fill_len < 0)
fill_len = 0;
if (entry->lines < 0) {
buffer = format_string(FRM("%.2s%.2s%c%-3d %.10s %.3s%S%*s (?) "),
(selected && arrow_cursor)? "->" : " ",
status,
tagged,
message_number,
entry->time_menu,
(really_to ? "To " : ""),
/* give max and min width parameters for 'from' */
bufferwho,
fill_len,""
);
} else
buffer = format_string(FRM("%.2s%.2s%c%-3d %.10s %.3s%S%*s (%d) %s"),
(selected && arrow_cursor)? "->" : " ",
status,
tagged,
message_number,
entry->time_menu,
(really_to ? "To " : ""),
/* give max and min width parameters for 'from' */
bufferwho,
fill_len,"",
entry->lines,
(entry->lines / 1000 > 0? "" : /* spacing the */
entry->lines / 100 > 0? " " : /* same for the */
entry->lines / 10 > 0? " " : /* lines in () */
" ") /* [wierd] */
);
free_string(&bufferwho);
X = 0;
/* clip_from_string updates X */
buffer1 = curses_printable_clip(buffer,&X,COLUMNS,
&header_without_subj_width,
COLUMNS);
free_string(&buffer);
/* Max printable width of subject -- note that
this may be longer than number of characters
on line -- we can't use string_len as subj_width
because some characters may consume several positions
(double width characters)
*/
subj_width = COLUMNS-header_without_subj_width;
if (buffer1) {
menu_Write_to_screen(page,FRM("%S"),buffer1);
free_string(&buffer1);
}
/* complete line with subject. */
if (subj_width > 0 && entry->subject) {
struct string * buffer2 = NULL;
X = 0;
/* clip_from_string updates X */
buffer2 = curses_printable_clip(entry->subject,&X,subj_width,
&was_len,subj_width);
if (buffer2) {
menu_Write_to_screen(page,FRM("%S"),buffer2);
free_string(&buffer2);
}
} else
was_len = 0; /* No subject ? */
/* If it is highlighted but not with the arrow cursor,
* expand subject to fit so that the reverse video bar extends
* aesthetically the full length of the line.
*/
if (selected && !arrow_cursor) {
while (was_len < subj_width) {
menu_Writechar(page,' ');
was_len++;
}
}
if (selected && has_highlighting && ! arrow_cursor)
menu_EndXX(page,pg_INVERSE);
menu_Writechar(page,'\r');
menu_Writechar(page,'\n');
}
/*
* Local Variables:
* mode:c
* c-basic-offset:4
* buffer-file-coding-system: iso-8859-1
* End:
*/
syntax highlighted by Code2HTML, v. 0.9.1