1 
2 static char rcsid[] = "@(#)$Id: showmsg_c.c,v 1.6 1999/03/24 14:04:05 wfp5p Exp $";
3 
4 /*******************************************************************************
5  *  The Elm Mail System  -  $Revision: 1.6 $   $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: showmsg_c.c,v $
17  * Revision 1.6  1999/03/24  14:04:05  wfp5p
18  * elm 2.5PL0
19  *
20  * Revision 1.5  1996/03/14  17:29:52  wfp5p
21  * Alpha 9
22  *
23  * Revision 1.4  1995/09/29  17:42:28  wfp5p
24  * Alpha 8 (Chip's big changes)
25  *
26  * Revision 1.3  1995/07/18  19:00:09  wfp5p
27  * Alpha 6
28  *
29  * Revision 1.2  1995/05/24  15:34:38  wfp5p
30  * Change to deal with parenthesized comments in when eliminating members from
31  * an alias. (from Keith Neufeld <neufeld@pvi.org>)
32  *
33  * Allow a shell escape from the alias screen (just like from
34  * the index screen).  It does not put the shell escape onto the alias
35  * screen menu. (from Keith Neufeld <neufeld@pvi.org>)
36  *
37  * Allow the use of "T" from the builtin pager. (from Keith Neufeld
38  * <neufeld@pvi.org>)
39  *
40  * Revision 1.1.1.1  1995/04/19  20:38:38  wfp5p
41  * Initial import of elm 2.4 PL0 as base for elm 2.5.
42  *
43  ******************************************************************************/
44 
45 /** This is an interface for the showmsg command line.  The possible
46     functions that could be invoked from the showmsg command line are
47     almost as numerous as those from the main command line and include
48     the following;
49 
50 	   |    = pipe this message to command...
51 	   !    = call Unix command
52 	   <    = scan message for calendar info
53 	   b    = bounce (remail) message
54 	   d    = mark message for deletion
55 	   f    = forward message
56 	   g    = group reply
57 	   h    = redisplay this message from line #1, showing headers
58 	   <CR> = redisplay this message from line #1, weeding out headers
59 	   i,q  = move back to the index page (simply returns from function)
60 	   J    = move to body of next message
61 	   j,n  = move to body of next undeleted message
62 	   K    = move to body of previous message
63 	   k    = move to body of previous undeleted message
64 	   m    = mail a message out to someone
65 	   p    = print this (all tagged) message
66 	   r    = reply to this message
67 	   s    = save this message to a maibox/folder
68 	   t    = tag this message
69 	   u    = undelete message
70 	   x    = Exit Elm NOW
71 
72     all commands not explicitly listed here are beeped at.  Use i)ndex
73     to get back to the main index page, please.
74 
75     This function returns when it is ready to go back to the index
76     page.
77 **/
78 
79 #include "elm_defs.h"
80 #include "elm_globals.h"
81 #include "s_elm.h"
82 
83 static int screen_mangled = 0;
84 static char msg_line[SLEN];
85 static char *put_help_prompt = NULL;
86 #define store_msg(a)	(void)strcpy(msg_line,a)
87 #define put_prompt()	PutLine0(LINES-3, 0, nls_Prompt)
88 #define put_help()	PutLine0(LINES-3, 45, put_help_prompt)
89 #define POST_PROMPT_COL	strlen(nls_Prompt)
90 
91 
92 int
process_showmsg_cmd(command)93 process_showmsg_cmd(command)
94 int command;
95 {
96 	int ch, i;
97 
98 	if (put_help_prompt == NULL) {
99 		put_help_prompt = catgets(elm_msg_cat, ElmSet, ElmUseIToReturnIndex,
100 				"(Use 'i' to return to index.)");
101 	}
102 	Raw(ON);
103 
104 	for (;;) {
105 
106 	  ch = (command == 0 ? GetKey(0) : command);
107 	  command = 0;
108 
109 	  clear_error();
110 	  switch (ch) {
111 	    case '?' : if (help(TRUE)) {
112 			 ClearScreen();
113 			 build_bottom();
114 		       } else screen_mangled = TRUE;
115 		       break;
116 
117 	    case '|' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPipe, "Pipe"), TRUE);
118 		       (void) do_pipe();     /* do pipe - ignore return val */
119 		       ClearScreen();
120 		       build_bottom();
121 		       break;
122 
123 #ifdef ALLOW_SUBSHELL
124 	    case '!' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmSystemCall,
125 				"System call"), TRUE);
126 		       (void) subshell();
127 		       ClearScreen();
128 		       build_bottom();
129 		       break;
130 #endif
131 
132 	    case '<' :
133 #ifdef ENABLE_CALENDAR
134 		       put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmScanForCalendarCmd,
135 				"Scan messages for calendar entries"), TRUE);
136 		       scan_calendar();
137 #else
138 		       store_msg(catgets(elm_msg_cat, ElmSet, ElmCantScanForCalendar,
139 				"Can't scan for calendar entries!"));
140 #endif
141 		       break;
142 
143 	    case '%' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmDisplayReturnAdd,
144 				"Display return address"), TRUE);
145 		       get_return(msg_line, curr_folder.curr_mssg-1);
146 		       break;
147 
148 	    case 'b' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmBounceMessage,
149 				"Bounce message"), TRUE);
150 		       remail();
151 		       break;
152 
153 	    case 'd' : delete_msg(TRUE, FALSE); /* really delete it, silent */
154 		       if (! resolve_mode)
155 			 store_msg(catgets(elm_msg_cat, ElmSet, ElmMessageMarkedForDeleteion,
156 				"Message marked for deletion."));
157 		       else
158 			 goto next_undel_msg;
159 		       break;
160 
161 	    case 'f' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmForwardMessage,
162 				"Forward message"), TRUE);
163 		       if(forward()) put_border();
164 		       break;
165 
166 	    case 'g' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmGroupReply,
167 				"Group reply"), TRUE);
168 		       (void) reply_to_everyone();
169 		       break;
170 
171 	    case 'h' : screen_mangled = 0;
172 		       if (filter) {
173 		         filter = 0;
174 		         i = show_msg(curr_folder.curr_mssg);
175 		         filter = 1;
176 			 return(i);
177 		       } else
178 		         return(show_msg(curr_folder.curr_mssg));
179 
180 	    case 'q' :
181 	    case 'i' : (void) get_page(curr_folder.curr_mssg);
182 		       clear_error();		/* zero out pending msg   */
183 		       EnableFkeys(ON);
184 		       screen_mangled = 0;
185 		       return(0);		/* avoid <return> looping */
186 
187 next_undel_msg :	/* a target for resolve mode actions */
188 
189 	    case KEY_DOWN:
190 	    case ' ' :
191 	    case 'j' :
192 	    case 'n' : screen_mangled = 0;
193 		       if((i=next_message(curr_folder.curr_mssg-1, TRUE)) != -1)
194 			 return(show_msg(curr_folder.curr_mssg = i+1));
195 		       else return(0);
196 
197 next_msg:
198 	    case 'J' : screen_mangled = 0;
199 		       if((i=next_message(curr_folder.curr_mssg-1, FALSE)) != -1)
200 			 return(show_msg(curr_folder.curr_mssg = i+1));
201 		       else return(0);
202 
203 	    case KEY_UP:
204 	    case 'k' : screen_mangled = 0;
205 		       if((i=prev_message(curr_folder.curr_mssg-1, TRUE)) != -1)
206 			 return(show_msg(curr_folder.curr_mssg = i+1));
207 		       else return(0);
208 
209 	    case 'K' : screen_mangled = 0;
210 		       if((i=prev_message(curr_folder.curr_mssg-1, FALSE)) != -1)
211 			 return(show_msg(curr_folder.curr_mssg = i+1));
212 		       else return(0);
213 
214 	    case 'm' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmMailMessage,
215 				"Mail message"), TRUE);
216 		       if (send_message((char *)NULL, (char *)NULL,
217 			         (char *)NULL, SM_ORIGINAL))
218 			 put_border();
219 		       break;
220 
221 	    case 'p' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPrintMessage,
222 				"Print message"), FALSE);
223 		       (void) print_msg(FALSE);
224 		       break;
225 
226 	    case 'r' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmReplyToMessage,
227 				"Reply to message"), TRUE);
228 		       if(reply()) put_border();
229 		       break;
230 
231 	    case '>' :
232 	    case 'C' :
233 	    case 's' :
234 		       put_cmd_name("", TRUE);
235 		       if (save(&i, TRUE, (ch != 'C')) &&
236 			   resolve_mode && ch != 'C')
237 			 goto next_undel_msg;
238 		       break;
239 
240 	    case 't' :
241  	    case 'T' :
242 		       if(tag_message(FALSE))
243 			 store_msg(catgets(elm_msg_cat, ElmSet, ElmMessageTagged,
244 				"Message tagged."));
245 		       else
246 			 store_msg(catgets(elm_msg_cat, ElmSet, ElmMessageUntagged,
247 				"Message untagged."));
248 		       if (ch == 'T')
249 			 goto next_undel_msg;
250 		       break;
251 
252 	    case 'u' : undelete_msg(FALSE); /* undelete it, silently */
253 		       if (! resolve_mode)
254 			 store_msg(catgets(elm_msg_cat, ElmSet, ElmMessageUndeleted,
255 				"Message undeleted."));
256 		       else {
257 /******************************************************************************
258  ** We're special casing the U)ndelete command here *not* to move to the next
259  ** undeleted message ; instead it'll blindly move to the next message in the
260  ** list.  See 'elm.c' and the command by "case 'u'" for further information.
261  ** The old code was:
262 			 goto next_undel_msg;
263 *******************************************************************************/
264 			 goto next_msg;
265 		       }
266 		       break;
267 
268 	    case 'X' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmQuickExit,
269 				"Quick Exit"), TRUE);
270 		       quit_abandon(FALSE);
271 		       break;
272 
273 	    case 'x' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmExit, "Exit"), TRUE);
274 		       quit_abandon(TRUE);
275 		       break;
276 
277 	    case ctrl('J'):
278 	    case ctrl('M'):  screen_mangled = 0;
279 			     return(show_msg(curr_folder.curr_mssg));
280 
281 	    default  : Beep();
282 	  }
283 
284 	  /* display prompt */
285 	  if (screen_mangled) {
286 	    /* clear what was left over from previous command
287 	     * and display last generated message.
288 	     */
289 	    put_prompt();
290 	    CleartoEOS();
291 	    put_help();
292 	    CenterLine(LINES, msg_line);
293 	    MoveCursor(LINES-3, POST_PROMPT_COL);
294 	  } else {
295 	    /* display bottom line prompt with last generated message */
296 	    MoveCursor(LINES, 0);
297 	    CleartoEOS();
298 	    if (Term.status & TERM_CAN_SO)
299 	      StartStandout();
300 	    PutLine1(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmCommandLine,
301 		"%s Command ('i' to return to index): "), msg_line);
302 	    if (Term.status & TERM_CAN_SO)
303 	      EndStandout();
304 	  }
305 	  *msg_line = '\0';	/* null last generated message */
306 
307 	}
308 }
309 
put_cmd_name(command,will_mangle)310 put_cmd_name(command, will_mangle)
311 char *command;
312 int will_mangle;
313 {
314 
315 	/* If screen is or will be mangled display the command name
316 	 * and erase the bottom of the screen.
317 	 * But first if the border line hasn't yet been drawn, draw it.
318 	 */
319 	if(will_mangle && !screen_mangled) {
320 	  build_bottom();
321 	  screen_mangled = TRUE;
322 	}
323 	if(screen_mangled) {
324 	  PutLine0(LINES-3, POST_PROMPT_COL, command);
325 	  CleartoEOS();
326 	}
327 }
328 
put_border()329 put_border()
330 {
331 	 PutLine0(LINES-4, 0,
332 "--------------------------------------------------------------------------\n");
333 }
334 
build_bottom()335 build_bottom()
336 {
337 	 MoveCursor(LINES-4, 0);
338 	 CleartoEOS();
339 	 put_border();
340 	 put_prompt();
341 	 put_help();
342 }
343