EMAIL can now pass filename to be edited to EDIT.

This commit is contained in:
Bobbi Webber-Manners 2020-07-15 20:15:57 -04:00
parent c02af8d466
commit 2ad28c454c
2 changed files with 57 additions and 42 deletions

View File

@ -170,6 +170,8 @@ uint8_t load_file(char *filename) {
fclose(fp);
return 2;
}
if ((gapbegin % 1000) == 0)
putchar('.');
}
--gapbegin; // Eat EOF character
fclose(fp);
@ -588,12 +590,13 @@ void load_email(void) {
/*
* Main editor routine
*/
int edit() {
int edit(char *filename) {
char c;
uint16_t pos;
uint8_t i;
videomode(VIDEOMODE_80COL);
if (load_file("test.txt")) {
printf("Loading file %s ", filename);
if (load_file(filename)) {
puts("load_file error");
exit(1);
}
@ -668,8 +671,11 @@ int edit() {
}
}
int main() {
edit();
int main(int argc, char *argv[]) {
if (argc == 2) {
edit(argv[1]);
} else
edit(NULL);
}

View File

@ -77,6 +77,24 @@ static unsigned char buf[READSZ];
#define ERR_NONFATAL 0
#define ERR_FATAL 1
// Shove this up in the Language Card out of an abundance of caution
#pragma code-name (push, "LC")
void load_editor(void) {
sprintf(userentry, "%s/EDIT.SYSTEM", cfg_instdir);
exec(userentry, filename);
}
void load_pop65(void) {
sprintf(filename, "%s/POP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
void load_smtp65(void) {
sprintf(filename, "%s/SMTP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
#pragma code-name (pop)
/*
* Put cursor at beginning of PROMPT_ROW
*/
@ -1274,6 +1292,27 @@ uint8_t write_email_headers(FILE *fp1, FILE *fp2, struct emailhdrs *h,
return 0;
}
/*
* Prompt ok?
*/
char prompt_okay(char *msg) {
char c;
goto_prompt_row();
printf("%sSure? (y/n)", msg);
while (1) {
c = cgetc();
if ((c == 'y') || (c == 'Y') || (c == 'n') || (c == 'N'))
break;
putchar(BELL);
}
if ((c == 'y') || (c == 'Y'))
c = 1;
else
c = 0;
putchar(CLRLINE);
return c;
}
/*
* Copies the current message to mailbox mbox.
* h is a pointer to the emailheaders for the message to copy
@ -1388,30 +1427,13 @@ void copy_to_mailbox(struct emailhdrs *h, uint16_t idx,
sprintf(filename, "Created %s %s/OUTBOX/EMAIL.%u",
(mode == 'R' ? "reply" : "fwded msg"), cfg_emaildir, num);
error(ERR_NONFATAL, filename);
if (prompt_okay("Open in editor - ")) {
sprintf(filename, "%s/OUTBOX/EMAIL.%u", cfg_emaildir, num);
load_editor();
}
}
}
/*
* Prompt ok?
*/
char prompt_okay(char *msg) {
char c;
goto_prompt_row();
printf("%sSure? (y/n)", msg);
while (1) {
c = cgetc();
if ((c == 'y') || (c == 'Y') || (c == 'n') || (c == 'N'))
break;
putchar(BELL);
}
if ((c == 'y') || (c == 'Y'))
c = 1;
else
c = 0;
putchar(CLRLINE);
return c;
}
/*
* Return index into EMAIL.DB for current selection.
*/
@ -1524,26 +1546,13 @@ void create_blank_outgoing() {
// Not really an error but useful to have an alert
sprintf(filename, "Created file %s/OUTBOX/EMAIL.%u", cfg_emaildir, num);
error(ERR_NONFATAL, filename);
}
// Shove this up in the Language Card out of an abundance of caution
#pragma code-name (push, "LC")
void load_editor(void) {
sprintf(filename, "%s/EDIT.SYSTEM", cfg_instdir);
exec(filename, NULL);
if (prompt_okay("Open in editor - ")) {
sprintf(filename, "%s/OUTBOX/EMAIL.%u", cfg_emaildir, num);
load_editor();
}
}
void load_pop65(void) {
sprintf(filename, "%s/POP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
void load_smtp65(void) {
sprintf(filename, "%s/SMTP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
#pragma code-name (pop)
/*
* Keyboard handler
*/