Updated fullscreen editor

This commit is contained in:
Michiel Broek 2003-07-01 20:02:58 +00:00
parent 0742fa3dd0
commit fdd4377785
4 changed files with 508 additions and 539 deletions

View File

@ -34,6 +34,10 @@ v0.37.4 10-May-2003
risk of sending files back to the owner of that faulty program.
Added the same check for Seenby lines.
mbsebbs:
Increased internal message buffer size to 700 lines.
Fullscreen editor code cleanup, debug messages removed.
v0.37.3 09-Apr-2003 - 10-May-2003

View File

@ -4,7 +4,7 @@
* Purpose ...............: FullScreen Message editor.
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -189,12 +189,6 @@ void Refresh(void)
}
void Debug(void)
{
/* Syslog('b', "FSEDIT: Col=%d Row=%d TopVisible=%d Lines=%d CurRow=%d Len=%d", */
/* Col, Row, TopVisible, Line, Row+TopVisible-1, strlen(Message[Row+TopVisible-1])); */
}
void GetstrLC(char *sStr, int iMaxlen)
{
@ -213,8 +207,9 @@ void GetstrLC(char *sStr, int iMaxlen)
if (iPos > 0) {
printf("\b \b");
sStr[--iPos] = '\0';
} else
putchar('\007');
} else {
Beep();
}
}
if (ch > 31 && ch < 127) {
@ -222,8 +217,9 @@ void GetstrLC(char *sStr, int iMaxlen)
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
} else {
Beep();
}
}
}
@ -233,7 +229,6 @@ void GetstrLC(char *sStr, int iMaxlen)
void ScrollUp()
{
Syslog('b', "FSEDIT: Scroll up");
if (TopVisible > 12) {
TopVisible -= 12;
Row += 12;
@ -242,27 +237,23 @@ void ScrollUp()
TopVisible = 1;
}
Refresh();
/* Debug(); */
}
void ScrollDown()
{
Syslog('b', "FSEDIT: Scroll down");
if ((TopVisible + 12) <= Line) {
Row -= 12;
TopVisible += 12;
}
Refresh();
/* Debug(); */
}
void FsMove(unsigned char Direction)
{
switch (Direction) {
case KEY_RIGHT:
Syslog('b', "FSEDIT: Cursor Right");
Debug();
/*
* FIXME: FsMove KEY_RIGHT
* Handle long lines better.
@ -281,8 +272,6 @@ void FsMove(unsigned char Direction)
break;
case KEY_LEFT:
Syslog('b', "FSEDIT: Cursor left");
Debug();
if (Col > 1) {
Col--;
Setcursor();
@ -293,8 +282,10 @@ void FsMove(unsigned char Direction)
* Handle long lines better.
* For now, we will just refuse to go past col 80
*/
if (Col > 80) Col = 80;
if (Row == 1) ScrollUp();
if (Col > 80)
Col = 80;
if (Row == 1)
ScrollUp();
Row--;
Setcursor();
} else
@ -302,8 +293,6 @@ void FsMove(unsigned char Direction)
break;
case KEY_UP:
Syslog('b', "FSEDIT: Cursor up");
Debug();
if (CurRow > 1) {
Row--;
if (Col > strlen(Message[CurRow-1]) + 1)
@ -317,8 +306,6 @@ void FsMove(unsigned char Direction)
break;
case KEY_DOWN:
Syslog('b', "FSEDIT: Cursor down");
Debug();
if (Row < (Line - TopVisible + 1)) {
Row++;
if (Col > strlen(Message[CurRow+1]) + 1)
@ -333,6 +320,8 @@ void FsMove(unsigned char Direction)
}
}
int FsWordWrap()
{
int WCol, i = 0;
@ -350,7 +339,10 @@ int FsWordWrap()
WCol = 79;
while (Message[CurRow][WCol] != ' ' && WCol > 0)
WCol--;
if ((WCol > 0) && (WCol < 80)) WCol++; else WCol=80;
if ((WCol > 0) && (WCol < 80))
WCol++;
else
WCol=80;
if (WCol <= strlen(Message[CurRow])) {
/*
* If WCol = 80 (no spaces in line) be sure to grab
@ -405,6 +397,8 @@ int FsWordWrap()
return WCol;
}
int Fs_Edit()
{
unsigned char ch;
@ -425,7 +419,6 @@ int Fs_Edit()
Col = 1;
Row = 1;
Refresh();
Debug();
while (TRUE) {
Nopper();
@ -435,8 +428,6 @@ int Fs_Edit()
switch (ch) {
case KEY_ENTER:
Syslog('b', "FSEDIT: Enter pressed");
Debug();
if (Col == 1) {
/* Enter at beginning of line */
for (i = Line; i >= CurRow; i--) {
@ -460,41 +451,36 @@ int Fs_Edit()
Line++;
Row++;
Col = 1;
if (Row >= (exitinfo.iScreenLen -1)) ScrollDown();
if (Row >= (exitinfo.iScreenLen -1))
ScrollDown();
Refresh();
/* Debug(); */
Changed = TRUE;
break;
case ('N' - 64): /* Insert line, scroll down */
Syslog('b', "FSEDIT: Insert line");
Debug();
for (i = Line; i >= CurRow; i--)
sprintf(Message[i+1], "%s", Message[i]);
Message[CurRow][0] = '\0';
Line++;
Col = 1;
Refresh();
/* Debug(); */
Changed = TRUE;
break;
case ('Y' - 64): /* Erase line, scroll up */
Syslog('b', "FSEDIT: Erase line");
Debug();
if (Line == CurRow) {
/* Erasing last line */
if ((Line > 1) || (strlen(Message[CurRow]) > 0)) {
Message[CurRow][0] = '\0';
if (Line > 1) {
Line--;
if (Row == 1) ScrollUp();
if (Row == 1)
ScrollUp();
Row--;
}
if (Col > strlen(Message[CurRow]))
Col = strlen(Message[CurRow]);
Refresh();
/* Debug(); */
Changed = TRUE;
} else
Beep();
@ -508,7 +494,6 @@ int Fs_Edit()
if (Col > strlen(Message[CurRow]) + 1)
Col = strlen(Message[CurRow]) + 1;
Refresh();
/* Debug(); */
Changed = TRUE;
}
break;
@ -534,8 +519,6 @@ int Fs_Edit()
break;
case KEY_DEL:
Syslog('b', "FSEDIT: DEL key");
Debug();
if (Col <= strlen(Message[CurRow])) {
/*
* If before the end of the line...
@ -549,8 +532,7 @@ int Fs_Edit()
Message[CurRow][i-1] = '\0';
Setcursor();
} else if (((strlen(Message[CurRow]) + strlen(Message[CurRow+1]) < 75)
|| (strlen(Message[CurRow]) == 0))
&& (CurRow < Line)) {
|| (strlen(Message[CurRow]) == 0)) && (CurRow < Line)) {
for (i = 0; i < strlen(Message[CurRow+1]); i++)
sprintf(Message[CurRow], "%s%c", Message[CurRow], Message[CurRow+1][i]);
for (i = CurRow+1; i < Line; i++)
@ -565,37 +547,31 @@ int Fs_Edit()
* Trap the extra code so it isn't
* inserted in the text
*/
if (ch == KEY_DEL) Readkey();
if (ch == KEY_DEL)
Readkey();
break;
case KEY_BACKSPACE:
case KEY_RUBOUT:
Syslog('b', "FSEDIT: BS (Backspace)");
Debug();
if (Col == 1 && CurRow == 1) {
/* BS on first character in message */
Beep();
} else if (Col == 1) {
/* BS at beginning of line */
if ((strlen(Message[CurRow-1]) + strlen(Message[CurRow]) < 75)
|| strlen(Message[CurRow]) == 0) {
if ((strlen(Message[CurRow-1]) + strlen(Message[CurRow]) < 75) || strlen(Message[CurRow]) == 0) {
Col = strlen(Message[CurRow-1]) + 1;
strcat(Message[CurRow-1], Message[CurRow]);
for ( i = CurRow; i < Line; i++)
sprintf(Message[i], "%s", Message[i+1]);
Message[i+1][0] = '\0';
Line--;
if (Row == 1) ScrollUp();
if (Row == 1)
ScrollUp();
Row--;
Refresh();
/* Debug(); */
Changed = TRUE;
} else {
i = strlen(Message[CurRow-1]) + strlen(Message[CurRow]);
/* Syslog('b', "FSEDIT: BS lines are too big! %d + %d = %d", */
/* strlen(Message[CurRow]), */
/* strlen(Message[CurRow-1]), */
/* i); */
Beep();
}
} else {
@ -628,16 +604,15 @@ int Fs_Edit()
Show_Ins();
colour(CFG.TextColourF, CFG.TextColourB);
Setcursor();
Syslog('b', "FSEDIT: InsertMode now %s", InsMode ? "True" : "False");
/*
* Trap the extra code so it isn't
* inserted in the text
*/
if (ch == KEY_INS) Readkey();
if (ch == KEY_INS)
Readkey();
break;
case ('L' - 64): /* Refresh screen */
Syslog('b', "FSEDIT: Refresh()");
Refresh();
break;
@ -661,7 +636,6 @@ int Fs_Edit()
free(filname);
free(tmpname);
Refresh();
/* Debug(); */
break;
}
@ -673,7 +647,6 @@ int Fs_Edit()
free(tmpname);
free(filname);
Refresh();
/* Debug(); */
break;
}
@ -704,6 +677,8 @@ int Fs_Edit()
filname[1] = '+';
sprintf(Message[Line], "%s", filname);
Line++;
if ((Line - 1) == TEXTBUFSIZE)
break;
}
fclose(fd);
Changed = TRUE;
@ -714,11 +689,9 @@ int Fs_Edit()
free(filname);
Col = 1;
Refresh();
/* Debug(); */
break;
case KEY_ESCAPE: /* Editor menu */
Syslog('b', "FSEDIT: Escape pressed");
Top_Menu();
ch = toupper(Readkey());
@ -726,11 +699,8 @@ int Fs_Edit()
Syslog('b', "FSEDIT: %s message (%c)", (ch == 'S' && Changed) ? "Saving" : "Aborting", ch);
Unsetraw();
close(ttyfd);
Debug();
clear();
fflush(stdout);
/* for (i = 1; i <= Line; i++) */
/* Syslog('b', "%3d \"%s\"", i, Message[i]); */
if (ch == 'S' && Changed) {
Syslog('+', "FSEDIT: Message saved");
return TRUE;
@ -741,7 +711,6 @@ int Fs_Edit()
}
if (ch == 'H') {
Syslog('b', "FSEDIT: User wants help");
Full_Help();
ch = Readkey();
Refresh();
@ -758,7 +727,6 @@ int Fs_Edit()
* Normal printable characters
*/
if (Col == strlen(Message[CurRow]) + 1) {
/* Syslog('b', "FSEDIT: Append character to end"); */
/*
* Append to line
*/
@ -777,8 +745,6 @@ int Fs_Edit()
/*
* Insert or overwrite
*/
/* Syslog('b', "FSEDIT: %s in line", */
/* InsMode ? "Insert" : "Overwrite"); */
if (InsMode) {
for (i = strlen(Message[CurRow]); i >= (Col-1); i--) {
/*
@ -792,7 +758,8 @@ int Fs_Edit()
i = FsWordWrap();
if (Col > strlen(Message[CurRow])+1) {
Col = Col - strlen(Message[CurRow]);
if (Col > 1) Col--;
if (Col > 1)
Col--;
Row++;
}
if (Row > (exitinfo.iScreenLen -1))
@ -813,8 +780,7 @@ int Fs_Edit()
Changed = TRUE;
}
}
} else
Syslog('b', "FSEDIT: Pressed %d (unsupported)", ch);
}
}
}

View File

@ -26,7 +26,6 @@ void Full_Help(void);
void Setcursor(void);
void Beep(void);
void Refresh(void);
void Debug(void);
void GetstrLC(char *, int);
void ScrollUp(void);
void ScrollDown(void);

View File

@ -3,7 +3,7 @@
#ifndef _MAIL_H
#define _MAIL_H
#define TEXTBUFSIZE 500
#define TEXTBUFSIZE 700
int LC(int); /* More prompt for reading messages */