2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-04 16:41:54 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Utilities
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (C) 1997-2001
|
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS 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, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MB BBS 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 MB BBS; see the file COPYING. If not, write to the Free
|
|
|
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/libs.h"
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../lib/memwatch.h"
|
2002-10-20 20:58:55 +00:00
|
|
|
#include "../lib/mberrors.h"
|
2003-03-24 19:44:38 +00:00
|
|
|
#include "../lib/structs.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "mutil.h"
|
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
extern int lines, columns;
|
|
|
|
extern int ttyfd;
|
|
|
|
int bbs_free;
|
2001-08-25 19:53:11 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
unsigned char readkey(int y, int x, int fg, int bg)
|
|
|
|
{
|
2003-03-20 22:43:40 +00:00
|
|
|
int rc = -1, i;
|
|
|
|
unsigned char ch = 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
|
|
|
|
perror("open /dev/tty");
|
|
|
|
exit(MBERR_TTYIO_ERROR);
|
|
|
|
}
|
|
|
|
Setraw();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
i = 0;
|
|
|
|
while (rc == -1) {
|
|
|
|
if ((i % 10) == 0)
|
|
|
|
show_date(fg, bg, 0, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
locate(y, x);
|
|
|
|
fflush(stdout);
|
|
|
|
rc = Waitchar(&ch, 5);
|
|
|
|
if ((rc == 1) && (ch != KEY_ESCAPE))
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
if ((rc == 1) && (ch == KEY_ESCAPE))
|
|
|
|
rc = Escapechar(&ch);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
if (rc == 1)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
Nopper();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
Unsetraw();
|
|
|
|
close(ttyfd);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
return ch;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char testkey(int y, int x)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
unsigned char ch = 0;
|
|
|
|
|
|
|
|
Nopper();
|
|
|
|
locate(y, x);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
|
2002-10-20 20:58:55 +00:00
|
|
|
perror("open /dev/tty");
|
|
|
|
exit(MBERR_TTYIO_ERROR);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
Setraw();
|
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
rc = Waitchar(&ch, 50);
|
2001-08-17 05:46:24 +00:00
|
|
|
if (rc == 1) {
|
|
|
|
if (ch == KEY_ESCAPE)
|
|
|
|
rc = Escapechar(&ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
Unsetraw();
|
|
|
|
close(ttyfd);
|
|
|
|
|
|
|
|
if (rc == 1)
|
|
|
|
return ch;
|
|
|
|
else
|
|
|
|
return '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void show_field(int y, int x, char *str, int length, int fill)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(y, x, padleft(str, length, fill));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int insertflag = 0;
|
|
|
|
|
|
|
|
void newinsert(int i, int fg, int bg)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
insertflag = i;
|
|
|
|
set_color(YELLOW, RED);
|
|
|
|
if (insertflag != 0) {
|
|
|
|
mvprintw(2,36," INS ");
|
|
|
|
} else {
|
|
|
|
mvprintw(2,36," OVR ");
|
|
|
|
}
|
|
|
|
set_color(fg, bg);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *edit_field(int y, int x, int w, int p, char *s_)
|
|
|
|
{
|
|
|
|
int i, charok, first, curpos;
|
|
|
|
static char s[256];
|
|
|
|
unsigned int ch;
|
|
|
|
|
|
|
|
memset((char *)s, 0, 256);
|
|
|
|
sprintf(s, "%s", s_);
|
|
|
|
curpos = 0;
|
|
|
|
first = 1;
|
|
|
|
newinsert(1, YELLOW, BLUE);
|
|
|
|
|
|
|
|
do {
|
|
|
|
set_color(YELLOW, BLUE);
|
|
|
|
show_field(y, x, s, w, '_');
|
|
|
|
locate(y, x + curpos);
|
|
|
|
do {
|
|
|
|
ch = readkey(y, x + curpos, YELLOW, BLUE);
|
|
|
|
set_color(YELLOW, BLUE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test if the pressed key is a valid key.
|
|
|
|
*/
|
|
|
|
charok = 0;
|
|
|
|
if ((ch >= ' ') && (ch <= '~')) {
|
|
|
|
switch(p) {
|
|
|
|
case '!':
|
|
|
|
ch = toupper(ch);
|
|
|
|
charok = 1;
|
|
|
|
break;
|
|
|
|
case 'X':
|
|
|
|
charok = 1;
|
|
|
|
break;
|
|
|
|
case '9':
|
|
|
|
if (ch == ' ' || ch == '-' || ch == ',' ||
|
|
|
|
ch == '.' || isdigit(ch))
|
|
|
|
charok = 1;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
ch = toupper(ch);
|
|
|
|
if (isupper(ch))
|
|
|
|
charok = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
putchar(7);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (charok == 0 && ch != KEY_ENTER && ch != KEY_LINEFEED &&
|
|
|
|
ch != KEY_DEL && ch != KEY_INS && ch != KEY_HOME &&
|
|
|
|
ch != KEY_LEFT && ch != KEY_RIGHT && ch != KEY_ESCAPE &&
|
|
|
|
ch != KEY_BACKSPACE && ch != KEY_RUBOUT && ch != KEY_END);
|
|
|
|
|
|
|
|
|
|
|
|
if (charok == 1) {
|
|
|
|
if (first == 1) {
|
|
|
|
first = 0;
|
|
|
|
memset((char *)s, 0, 256);
|
|
|
|
curpos = 0;
|
|
|
|
}
|
|
|
|
if (curpos < w) {
|
|
|
|
if (insertflag == 1) {
|
|
|
|
/*
|
|
|
|
* Insert mode
|
|
|
|
*/
|
|
|
|
if (strlen(s) < w) {
|
|
|
|
if (curpos < strlen(s)) {
|
|
|
|
for (i = strlen(s); i >= curpos; i--)
|
|
|
|
s[i+1] = s[i];
|
|
|
|
}
|
|
|
|
s[curpos] = ch;
|
|
|
|
if (curpos < w)
|
|
|
|
curpos++;
|
|
|
|
} else {
|
|
|
|
putchar(7);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Overwrite mode
|
|
|
|
*/
|
|
|
|
s[curpos] = ch;
|
|
|
|
if (curpos < w)
|
|
|
|
curpos++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* The field is full
|
|
|
|
*/
|
|
|
|
putchar(7);
|
|
|
|
}
|
|
|
|
} /* if charok */
|
|
|
|
|
|
|
|
first = 0;
|
|
|
|
switch (ch) {
|
|
|
|
case KEY_HOME:
|
|
|
|
curpos = 0;
|
|
|
|
break;
|
|
|
|
case KEY_END:
|
|
|
|
curpos = strlen(s);
|
|
|
|
break;
|
|
|
|
case KEY_LEFT:
|
|
|
|
if (curpos > 0)
|
|
|
|
curpos--;
|
|
|
|
else
|
|
|
|
putchar(7);
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
if (curpos < strlen(s))
|
|
|
|
curpos++;
|
|
|
|
else
|
|
|
|
putchar(7);
|
|
|
|
break;
|
|
|
|
case KEY_INS:
|
|
|
|
if (insertflag == 1)
|
|
|
|
newinsert(0, YELLOW, BLUE);
|
|
|
|
else
|
|
|
|
newinsert(1, YELLOW, BLUE);
|
|
|
|
break;
|
|
|
|
case KEY_BACKSPACE:
|
2002-09-27 17:58:24 +00:00
|
|
|
case KEY_RUBOUT:
|
2001-08-17 05:46:24 +00:00
|
|
|
if (strlen(s) > 0) {
|
|
|
|
if (curpos >= strlen(s)) {
|
|
|
|
curpos--;
|
|
|
|
s[curpos] = '\0';
|
|
|
|
} else {
|
|
|
|
for (i = curpos; i < strlen(s); i++)
|
|
|
|
s[i] = s[i+1];
|
|
|
|
s[i] = '\0';
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
putchar(7);
|
|
|
|
break;
|
|
|
|
case KEY_DEL:
|
|
|
|
if (strlen(s) > 0) {
|
|
|
|
if ((curpos) == (strlen(s) -1)) {
|
|
|
|
s[curpos] = '\0';
|
|
|
|
} else {
|
|
|
|
for (i = curpos; i < strlen(s); i++)
|
|
|
|
s[i] = s[i+1];
|
|
|
|
s[i] = '\0';
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
putchar(7);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ((ch != KEY_ENTER) && (ch != KEY_LINEFEED) && (ch != KEY_ESCAPE));
|
|
|
|
|
|
|
|
set_color(LIGHTGRAY, BLUE);
|
|
|
|
mvprintw(2,36, " ");
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select menu, max is the highest item to pick. Returns zero if
|
|
|
|
* "-" (previous level) is selected.
|
|
|
|
*/
|
|
|
|
int select_menu(int max)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
static char *menu=(char *)"-";
|
|
|
|
char help[80];
|
|
|
|
int pick;
|
|
|
|
|
|
|
|
sprintf(help, "Select menu item (1..%d) or ^\"-\"^ for previous level.", max);
|
|
|
|
showhelp(help);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop forever until it's right.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
mvprintw(lines - 2, 6, "Enter your choice >");
|
|
|
|
menu = (char *)"-";
|
|
|
|
menu = edit_field(lines - 2, 26, 3, '9', menu);
|
|
|
|
locate(lines -2, 6);
|
|
|
|
clrtoeol();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
if (strncmp(menu, "-", 1) == 0)
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
pick = atoi(menu);
|
|
|
|
if ((pick >= 1) && (pick <= max))
|
|
|
|
return pick;
|
|
|
|
|
|
|
|
working(2, 0, 0);
|
|
|
|
working(0, 0, 0);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clrtoeol()
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
printf("\r");
|
|
|
|
for (i = 0; i < columns; i++)
|
|
|
|
putchar(' ');
|
|
|
|
printf("\r");
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hor_lin(int y, int x, int len)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
locate(y, x);
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
putchar('-');
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int old_f = -1;
|
|
|
|
static int old_b = -1;
|
|
|
|
|
|
|
|
void set_color(int f, int b)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
if ((f != old_f) || (b != old_b)) {
|
|
|
|
old_f = f;
|
|
|
|
old_b = b;
|
|
|
|
colour(f, b);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static time_t lasttime;
|
|
|
|
|
|
|
|
/*
|
2003-03-20 22:43:40 +00:00
|
|
|
* Show the current date & time in the second status row.
|
|
|
|
* Show user paging status in third screen row.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
|
|
|
void show_date(int fg, int bg, int y, int x)
|
|
|
|
{
|
2003-03-20 22:43:40 +00:00
|
|
|
time_t now;
|
|
|
|
char *p, buf[128], *pid, *page, *reason;
|
|
|
|
|
|
|
|
now = time(NULL);
|
|
|
|
if (now != lasttime) {
|
|
|
|
lasttime = now;
|
|
|
|
set_color(LIGHTGREEN, BLUE);
|
|
|
|
p = ctime(&now);
|
|
|
|
Striplf(p);
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(1, columns - 36, (char *)"%s TZUTC %s", p, gmtoffset(now));
|
2003-03-20 22:43:40 +00:00
|
|
|
p = asctime(gmtime(&now));
|
|
|
|
Striplf(p);
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(2, columns - 36, (char *)"%s UTC", p);
|
2003-03-20 22:43:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Indicator if bbs is free
|
|
|
|
*/
|
|
|
|
strcpy(buf, SockR("SFRE:0;"));
|
|
|
|
if (strncmp(buf, "100:0;", 6) == 0) {
|
|
|
|
strcpy(buf, SockR("SBBS:0;"));
|
|
|
|
if (strncmp(buf, "100:2,1", 7) == 0) {
|
|
|
|
set_color(WHITE, RED);
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(2,columns - 6, (char *)" Down ");
|
2003-03-20 22:43:40 +00:00
|
|
|
} else {
|
|
|
|
set_color(WHITE, BLUE);
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(2,columns - 6, (char *)" Free ");
|
2003-03-20 22:43:40 +00:00
|
|
|
}
|
|
|
|
bbs_free = TRUE;
|
|
|
|
} else {
|
|
|
|
set_color(WHITE, RED);
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(2,columns - 6, (char *)" Busy ");
|
2003-03-20 22:43:40 +00:00
|
|
|
bbs_free = FALSE;
|
|
|
|
}
|
2002-05-04 19:45:19 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
/*
|
|
|
|
* Check paging status
|
|
|
|
*/
|
|
|
|
strcpy(buf, SockR("CCKP:0;"));
|
|
|
|
if (strcmp(buf, "100:0;") == 0) {
|
|
|
|
locate(3, 1);
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
clrtoeol();
|
|
|
|
} else {
|
|
|
|
pid = strtok(buf, ",");
|
|
|
|
pid = strtok(NULL, ",");
|
|
|
|
page = strtok(NULL, ",");
|
|
|
|
reason = strtok(NULL, "\0");
|
|
|
|
reason[strlen(reason)-1] = '\0';
|
|
|
|
if (strlen(reason) > 60)
|
|
|
|
reason[60] = '\0';
|
|
|
|
|
|
|
|
locate(3, 1);
|
|
|
|
if (strcmp(page, "1")) {
|
|
|
|
set_color(RED, BLACK);
|
|
|
|
mvprintw(3, 1, " Old page (%s) %-60s", pid, reason);
|
|
|
|
if ((now % 10) == 0) /* Every 10 seconds */
|
|
|
|
putchar(7);
|
|
|
|
} else {
|
|
|
|
set_color(LIGHTRED, BLACK);
|
|
|
|
mvprintw(3, 1, " Sysop page (%s) %-60s", pid, reason);
|
|
|
|
putchar(7); /* Each second */
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-20 22:43:40 +00:00
|
|
|
|
|
|
|
if (y && x)
|
|
|
|
locate(y, x);
|
|
|
|
set_color(fg, bg);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void center_addstr(int y, char *s)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
mvprintw(y, (columns / 2) - (strlen(s) / 2), s);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Curses and screen initialisation.
|
|
|
|
*/
|
|
|
|
void screen_start(char *name)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Overwrite screen the first time, if user had it black on white
|
|
|
|
* it will change to white on black. clear() won't do the trick.
|
|
|
|
*/
|
|
|
|
set_color(LIGHTGRAY, BLUE);
|
|
|
|
locate(1, 1);
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
if (i == 3)
|
|
|
|
colour(LIGHTGRAY, BLACK);
|
|
|
|
clrtoeol();
|
|
|
|
if (i < lines)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
set_color(WHITE, BLUE);
|
|
|
|
locate(1, 1);
|
|
|
|
printf((char *)"%s for MBSE BBS version %s", name, VERSION);
|
|
|
|
set_color(YELLOW, BLUE);
|
|
|
|
locate(2, 1);
|
|
|
|
printf((char *)SHORTRIGHT);
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Screen deinit
|
|
|
|
*/
|
|
|
|
void screen_stop()
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
clear();
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Message at the upperright window about actions
|
|
|
|
*/
|
|
|
|
void working(int txno, int y, int x)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
/*
|
|
|
|
* If txno not 0 there will be something written. The
|
|
|
|
* reversed attributes for mono, or white on red for
|
|
|
|
* color screens is set. The cursor is turned off and
|
|
|
|
* original cursor position is saved.
|
|
|
|
*/
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
if (txno != 0)
|
|
|
|
set_color(YELLOW, RED);
|
|
|
|
else
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
switch (txno) {
|
|
|
|
case 0: mvprintw(4, columns - 14, (char *)" ");
|
2001-08-17 05:46:24 +00:00
|
|
|
break;
|
2003-03-23 21:27:14 +00:00
|
|
|
case 1: mvprintw(4, columns - 14, (char *)"Working . . .");
|
2001-08-17 05:46:24 +00:00
|
|
|
break;
|
2003-03-23 21:27:14 +00:00
|
|
|
case 2: mvprintw(4, columns - 14, (char *)">>> ERROR <<<");
|
2001-08-17 05:46:24 +00:00
|
|
|
for (i = 1; i <= 5; i++) {
|
2003-03-23 21:27:14 +00:00
|
|
|
putchar(7);
|
|
|
|
fflush(stdout);
|
|
|
|
usleep(150000);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
usleep(550000);
|
|
|
|
break;
|
2003-03-23 21:27:14 +00:00
|
|
|
case 3: mvprintw(4, columns - 14, (char *)"Form inserted");
|
2001-08-17 05:46:24 +00:00
|
|
|
putchar(7);
|
|
|
|
fflush(stdout);
|
|
|
|
sleep(1);
|
|
|
|
break;
|
2003-03-23 21:27:14 +00:00
|
|
|
case 4: mvprintw(4, columns - 14, (char *)"Form deleted ");
|
2001-08-17 05:46:24 +00:00
|
|
|
putchar(7);
|
|
|
|
fflush(stdout);
|
|
|
|
sleep(1);
|
|
|
|
break;
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
if (y && x)
|
|
|
|
locate(y, x);
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear the middle window
|
|
|
|
*/
|
|
|
|
void clr_index()
|
|
|
|
{
|
2003-03-20 22:43:40 +00:00
|
|
|
int i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-20 22:43:40 +00:00
|
|
|
set_color(LIGHTGRAY, BLACK);
|
2003-03-23 21:27:14 +00:00
|
|
|
for (i = 4; i <= (lines); i++) {
|
2003-03-20 22:43:40 +00:00
|
|
|
locate(i, 1);
|
|
|
|
clrtoeol();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show help at the bottom of the screen.
|
|
|
|
*/
|
|
|
|
void showhelp(char *T)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int f, i, x, forlim;
|
|
|
|
|
|
|
|
f = FALSE;
|
|
|
|
locate(lines, 1);
|
|
|
|
set_color(WHITE, RED);
|
|
|
|
clrtoeol();
|
|
|
|
x = 0;
|
|
|
|
forlim = strlen(T);
|
|
|
|
|
|
|
|
for (i = 0; i < forlim; i++) {
|
|
|
|
if (T[i] == '^') {
|
|
|
|
if (f == FALSE) {
|
|
|
|
f = TRUE;
|
|
|
|
set_color(YELLOW, RED);
|
|
|
|
} else {
|
|
|
|
f = FALSE;
|
|
|
|
set_color(WHITE, RED);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
putchar(T[i]);
|
|
|
|
x++;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
fflush(stdout);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|