static char rcsid[] = "@(#)$Id: edit.c,v 1.25 2006/04/09 07:37:17 hurtta Exp $";
/******************************************************************************
* The Elm (ME+) Mail System - $Revision: 1.25 $ $State: Exp $
*
* Modified by: Kari Hurtta <hurtta+elm@posti.FMI.FI>
* (was hurtta+elm@ozone.FMI.FI)
******************************************************************************
* The Elm Mail System
*
* Copyright (c) 1988-1992 USENET Community Trust
* Copyright (c) 1986,1987 Dave Taylor
*****************************************************************************/
/** This routine is for allowing the user to edit their current folder
as they wish.
**/
#include "def_elm.h"
#include "s_elm.h"
#include <errno.h>
#ifndef ANSI_C
extern int errno;
#endif
#ifdef ALLOW_MAILBOX_EDITING
void edit_mailbox(mailbox, page)
struct MailboxView **mailbox;
struct menu_context *page;
{
/** Allow the user to edit their folder, always resynchronizing
afterwards. Due to intense laziness on the part of the
programmer, this routine will invoke $EDITOR on the entire
file. The mailer will ALWAYS resync on the folder
even if nothing has changed since, not unreasonably, it's
hard to figure out what occurred in the edit session...
Also note that if the user wants to edit their incoming
mailbox they'll actually be editing the tempfile that is
an exact copy. More on how we resync in that case later
in this code.
**/
CONST char *edited_file = NULL;
struct folder_info * f = get_main_folder(*mailbox);
if (!f)
return;
if (!start_edit_folder(f,&edited_file))
return;
if (edit_a_file(edited_file,page) == 0)
return;
switch(end_edit_folder(f)) {
case -1:
emergency_exit(0);
case 0:
return;
}
if (sleepmsg > 0) {
error_sleep(sleepmsg);
}
menu_ClearScreen(page);
newmbox_1(f, mailbox, FALSE,
page);
showscreen(page);
return;
}
#endif
int edit_a_file(editfile, page)
CONST char *editfile;
struct menu_context *page;
{
/** Edit a file. This routine is used by edit_mailbox()
and edit_aliases_text(). It gets all the editor info
from the elmrc file.
**/
char buffer[SLEN];
int LINES, COLUMNS;
char * editor_val;
menu_get_sizes(page,&LINES, &COLUMNS);
editor_val = give_dt_estr_as_str(&editor_e,"editor");
PutLineX(LINES-2,0, CATGETS(elm_msg_cat, ElmSet, ElmInvokeEditor,
"Invoking editor..."));
if (! editor_val ||
strcmp(editor_val, "builtin") == 0 ||
strcmp(editor_val, "none") == 0) {
if (in_string(alternative_editor, "%s"))
elm_sfprintf(buffer, sizeof buffer,
FRM(alternative_editor), editfile);
else
elm_sfprintf(buffer, sizeof buffer,
FRM("%s %s"), alternative_editor, editfile);
} else {
if (in_string(editor_val, "%s"))
elm_sfprintf(buffer, sizeof buffer,
FRM(editor_val), editfile);
else
elm_sfprintf(buffer, sizeof buffer,
FRM("%s %s"), editor_val, editfile);
}
Raw(OFF);
if (system_call(buffer, SY_ENAB_SIGHUP, NULL) == -1) {
Raw(ON);
lib_error(CATGETS(elm_msg_cat, ElmSet, ElmProblemsInvokingEditor,
"Problems invoking editor %s!"),
alternative_editor);
sleep_message();
return(0);
}
Raw(ON);
InvalidateLocation();
return(1);
}
/*
* Local Variables:
* mode:c
* c-basic-offset:4
* buffer-file-coding-system: iso-8859-1
* End:
*/
syntax highlighted by Code2HTML, v. 0.9.1