// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "_ldefs.h"
#include "lora.h"
TEditor::TEditor (void)
{
Embedded = NULL;
Text.Clear ();
Wrap[0] = '\0';
StartCol = StartRow = 1;
Width = 79;
Height = 24;
UseFullScreen = FALSE;
}
TEditor::~TEditor (void)
{
Clear ();
}
USHORT TEditor::AppendText (VOID)
{
Text.Last ();
Embedded->Printf ("\n\x16\x01\012Continue entering text. Type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself when you are\ndone. (Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
return (InputText ());
}
VOID TEditor::ChangeText (VOID)
{
USHORT i, usRows, usEditLine;
CHAR szTemp[20], *szText, *szLine, *szReplace;
usRows = 0;
if (Text.First () != NULL)
do {
usRows++;
} while (Text.Next () != NULL);
do {
if (Embedded->AbortSession () == TRUE)
return;
Embedded->Printf ("\n\x16\x01\013Change text in what line (1-%d)? ", usRows);
while (Embedded->AbortSession () == FALSE && c != '\r') {
if (Embedded->KBHit ()) {
if ((c = Embedded->Getch ()) == 0)
c = (SHORT)(Embedded->Getch () << 8);
if (c != '\r') {
if (c == 8 || c == 127) {
if (len > 0) {
Embedded->Printf ("%c %c", 8, 8);
p--;
len--;
}
}
else if (c >= 32 && c < 256) {
if (len < usMaxlen) {
*p++ = (char)c;
len++;
Embedded->Putch ((UCHAR)c);
if (len >= usMaxlen) {
*p = '\0';
if (c != ' ') {
mp = p;
p--;
count = 1;
while (p > pszBuffer && *p != ' ') {
p--;
count++;
}
if (p > pszBuffer) {
*p++ = '\0';
strcpy (Wrap, p);
for (i = 0; i < count; i++)
Embedded->Printf ("%c %c", 8, 8);
}
else
p = mp;
}
c = '\r';
}
}
}
}
}
Embedded->Idle ();
}
*p = '\0';
Embedded->Printf ("\n");
return (pszBuffer);
}
USHORT TEditor::InputText (VOID)
{
USHORT RetVal = FALSE, Number;
CHAR *Line;
Number = 1;
if ((Line = (CHAR *)Text.Value ()) != NULL) {
Text.First ();
while ((CHAR *)Text.Value () != Line && Text.Value () != NULL) {
Number++;
Text.Next ();
}
Number++;
}
if ((Line = (CHAR *)malloc (Width)) != NULL) {
do {
Embedded->Printf ("%3u: ", Number);
GetString (Line, (USHORT)(Width - 10));
if (!strcmp (Line, "/?"))
Embedded->Printf ("\n\x16\x01\012Continue entering text. Type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself when you are\ndone. (Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n");
else if (stricmp (Line, "/OK") && stricmp (Line, "/SAVE")) {
Embedded->Printf ("\n\x16\x01\x0DSorry, that line number is out of range!\n");
} while (usEditLine > usRows);
Text.First ();
for (i = 1; i < usEditLine; i++)
Text.Next ();
Embedded->Printf ("\n\x16\x01\012Continue entering text. Type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself when you are\ndone. (Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐", Width - 10);
Embedded->Printf ("\n\x16\x01\x0AWho do you wish to send this message to?\n\x16\x01\013Enter User-Name, ? for help, or RETURN for '\x16\x01\013All\x16\x01\013': ");
// Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n");
if (Line[0] != 0x01 && strnicmp (Line, "SEEN-BY: ", 9))
Text.Add (Line, (USHORT)(strlen (Line) + 1));
} while ((Line = (PSZ)Msg->Text.Next ()) != NULL);
strcpy (To, Msg->To);
strcpy (Subject, Msg->Subject);
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
if ((RetVal = InputText ()) == FALSE)
Save ();
}
return (RetVal);
}
VOID TMsgEditor::QuoteText (VOID)
{
USHORT Line, Current;
USHORT Start, End;
CHAR Temp[16], *p;
if (Msg->Text.First () != NULL) {
while (Embedded->AbortSession () == FALSE) {
Embedded->Printf ("\n\026\001\013Start quoting from line number (or ? displays message): ");
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
if ((RetVal = InputText ()) == FALSE)
Save ();
}
return (RetVal);
}
USHORT TMsgEditor::Write (VOID)
{
FILE *fp;
USHORT RetVal = FALSE;
_dos_getdate (&d_date);
_dos_gettime (&d_time);
Embedded->Printf ("\n\026\001\014You are entering a message into an \026\001\015ECHOMAIL \026\001\014conference which is to be\n");
Embedded->Printf ("transmitted and read on other BBSes\n\n");
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
Embedded->Printf ("\n\x16\x01\012Type your comment now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
Embedded->Printf ("\n\x16\x01\012Type your comment now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
// Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐", Width - 10);
if (Line[0] != 0x01 && strnicmp (Line, "SEEN-BY: ", 9))
Text.Add (Line, (USHORT)(strlen (Line) + 1));
} while ((Line = (PSZ)Msg->Text.Next ()) != NULL);
strcpy (To, Msg->To);
strcpy (Subject, Msg->Subject);
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
if ((RetVal = InputText ()) == FALSE)
Save ();
}
return (RetVal);
}
VOID TMailEditor::QuoteText (VOID)
{
USHORT Line, Current;
USHORT Start, End;
CHAR Temp[16], *p;
if (Msg->Text.First () != NULL) {
while (Embedded->AbortSession () == FALSE) {
Embedded->Printf ("\n\026\001\013Start quoting from line number (or ? displays message): ");
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);
Embedded->Printf ("\n\x16\x01\012Type your message now. When done, type '\x16\x01\x0B/OK\x16\x01\012' on a line by itself.\n(Or, type '\x16\x01\x0B/SAVE\x16\x01\012' to save and proceed, without editing).\n\n ┌\031─%c┐\n", Width - 10);