1 
2 static char rcsid[] = "@(#)$Id: a_screen.c,v 1.3 1996/03/14 17:27:48 wfp5p Exp $";
3 
4 /*******************************************************************************
5  *  The Elm Mail System  -  $Revision: 1.3 $   $State: Exp $
6  *
7  *                      Copyright (c) 1988-1995 USENET Community Trust
8  * 			Copyright (c) 1986,1987 Dave Taylor
9  *******************************************************************************
10  * Bug reports, patches, comments, suggestions should be sent to:
11  *
12  *      Bill Pemberton, Elm Coordinator
13  *      flash@virginia.edu
14  *
15  *******************************************************************************
16  * $Log: a_screen.c,v $
17  * Revision 1.3  1996/03/14  17:27:48  wfp5p
18  * Alpha 9
19  *
20  * Revision 1.2  1995/09/29  17:41:55  wfp5p
21  * Alpha 8 (Chip's big changes)
22  *
23  * Revision 1.1.1.1  1995/04/19  20:38:34  wfp5p
24  * Initial import of elm 2.4 PL0 as base for elm 2.5.
25  *
26  ******************************************************************************/
27 
28 /**  alias screen display routines for ELM program
29 
30 **/
31 
32 #include "elm_defs.h"
33 #include "elm_globals.h"
34 #include "s_aliases.h"
35 
36 char *show_status();
37 char *alias_type();
38 
alias_screen(modified)39 alias_screen(modified)
40 int modified;
41 {
42 	/* Stolen from showscreen() */
43 
44 	ClearScreen();
45 
46 	alias_title(modified);
47 
48 	last_header_page = -1;	 	/* force a redraw regardless */
49 	show_headers();
50 
51 	if (mini_menu)
52 	  show_alias_menu();
53 
54 	show_last_error();
55 
56 }
57 
alias_title(modified)58 alias_title(modified)
59 int modified;
60 {
61 	/** display a new title line, due to re-sync'ing the aliases **/
62 	/* Stolen from update_title() */
63 
64 	char buffer[SLEN];
65 	char modmsg[SLEN];
66 
67 	if (modified) {
68 	    strcpy(modmsg, catgets(elm_msg_cat, AliasesSet, AliasesModified,
69 		"(modified, resync needed) "));
70 	}
71 	else {
72 	    modmsg[0] = '\0';
73 	}
74 
75 	if (selected)
76 	  MCsprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesSelect,
77 	      "Alias mode: %d shown out of %d %s[ELM %s]"),
78 	      selected, num_aliases, modmsg, version_buff);
79 	else if (num_aliases == 1)
80 	  sprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesSingle,
81 	      "Alias mode: 1 alias %s[ELM %s]"), modmsg, version_buff);
82 	else
83 	  MCsprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesPlural,
84 	      "Alias mode: %d aliases %s[ELM %s]"),
85 	      num_aliases, modmsg, version_buff);
86 
87 	ClearLine(1);
88 	CenterLine(1, buffer);
89 }
90 
show_alias_menu()91 show_alias_menu()
92 {
93 	/** write alias menu... **/
94 	/* Moved from alias.c */
95 
96 	if (user_level == 0) {	/* Give less options  */
97 	  CenterLine(LINES-7, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn1,
98 "You can use any of the following commands by pressing the first character;"));
99 	  CenterLine(LINES-6, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn2,
100 "a)lias current message, n)ew alias, d)elete or u)ndelete an alias,"));
101 	  CenterLine(LINES-5, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn3,
102 "m)ail to alias, or r)eturn to main menu.  To view an alias, press <return>."));
103 	  CenterLine(LINES-4, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn4,
104 "j = move down, k = move up, ? = help"));
105 	}
106 	else {
107 	    CenterLine(LINES-7, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn1,
108 "Alias commands:  ?=help, <n>=set current to n, /=search pattern"));
109 	    CenterLine(LINES-6, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn2,
110 "a)lias current message, c)hange, d)elete, e)dit aliases.text, f)ully expand,"));
111 	    CenterLine(LINES-5, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn3,
112 "l)imit display, m)ail, n)ew alias, r)eturn, t)ag, u)ndelete, or e(x)it"));
113 	}
114 
115 }
116 
build_alias_line(buffer,entry,message_number,highlight)117 build_alias_line(buffer, entry, message_number, highlight)
118 char *buffer;
119 struct alias_rec *entry;
120 int message_number, highlight;
121 {
122 	/** Build in buffer the alias header ... entry is the current
123 	    message entry, 'highlight' is either TRUE or FALSE,
124 	    and 'message_number' is the number of the message.
125 	**/
126 
127 	char mybuffer[SLEN];
128 
129 	/** Note: using 'strncpy' allows us to output as much of the
130 	    subject line as possible given the dimensions of the screen.
131 	    The key is that 'strncpy' returns a 'char *' to the string
132 	    that it is handing to the dummy variable!  Neat, eh? **/
133 	/* Stolen from build_header_line() */
134 
135 	int name_width;
136 
137 	/* Note that one huge sprintf() is too hard for some compilers. */
138 
139 	sprintf(buffer, "%s%s%c%-3d ",
140 		(highlight && arrow_cursor)? "->" : "  ",
141 		show_status(entry->status),
142 		(entry->status & TAGGED?  '+' : ' '),
143 		message_number);
144 
145 	/* Set the name display width. */
146 	name_width = COLS-40;
147 
148 	/* Put the name and associated comment in local buffer */
149 	if (strlen(entry->comment))
150 	  MCsprintf(mybuffer, "%s, %s", entry->name, entry->comment);
151 	else
152 	  sprintf(mybuffer, "%s", entry->name);
153 
154 	/* complete line with name, type and alias. */
155 	sprintf(buffer + strlen(buffer), "%-*.*s %s %-18.18s",
156 		/* give max and min width parameters for 'name' */
157 		name_width, name_width, mybuffer,
158 		alias_type(entry->type),
159 		entry->alias);
160 }
161 
alias_type(type)162 char *alias_type(type)
163 int type;
164 {
165 	/** This routine returns a string showing the alias type,
166 	    'Person' or 'Group' aliases.  Additionally, a '(S)'
167 	    is appended if this is a system alias.
168 	**/
169 
170 	static char mybuffer[10];
171 
172 	if (type & GROUP) {
173 	    strcpy(mybuffer, catgets(elm_msg_cat, AliasesSet,
174 	    		AliasesGroup, " Group"));
175 	} else {
176 	    strcpy(mybuffer, catgets(elm_msg_cat, AliasesSet,
177 			AliasesPerson, "Person"));
178 	}
179 
180 	if (type & SYSTEM) {
181 	    strcat(mybuffer, catgets(elm_msg_cat, AliasesSet,
182 	    		AliasesSystemFlag, "(S)"));
183 	} else {
184 	    strcat(mybuffer, "   ");
185 	}
186 
187 	return mybuffer;
188 }
189