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. risk of sending files back to the owner of that faulty program.
Added the same check for Seenby lines. 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 v0.37.3 09-Apr-2003 - 10-May-2003

View File

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

View File

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

View File

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