#include <mit-copyright.h>
#include <sys/types.h>
#include <stdio.h>
+#include <string.h>
#include <signal.h>
#include <curses.h>
-#ifdef _AUX_SOURCE
-#include <sys/termio.h>
-#include <sys/ttychars.h>
-#endif /* _AUX_SOURCE */
+#ifdef POSIX
+#include <unistd.h>
+#include <termios.h>
+#endif /* POSIX */
#include <ctype.h>
-#include <strings.h>
+#ifndef sun
#include <varargs.h>
+#endif
#include <com_err.h>
+#include <moira.h>
#include "menu.h"
#ifndef __STDC__
#define MIN_INPUT 2 /* Minimum number of lines for input window */
+extern int interrupt; /* will be set if ^C is received */
extern FILE *fdopen();
+#ifndef sgi
extern int getpid();
+#endif
extern char *calloc();
extern char *whoami;
FILE *log_file = (FILE *) NULL; /* file stream of log file */
int more_flg = 1;
+#ifdef POSIX
+extern char *malloc();
+#endif
+
/* Structure for holding current displayed menu */
struct menu_screen {
WINDOW *ms_screen; /* Window for this menu */
register void (*old_hook)() = set_com_err_hook(menu_com_err_hook);
#endif
- if (initscr() == ERR) {
+ if (initscr() == (WINDOW *)ERR) {
fputs("Can't initialize curses!\n", stderr);
Start_no_menu(m);
} else {
int length;
{
struct menu_screen *ms;
- char *malloc();
if (MAX_TITLE + length + MIN_INPUT > LINES) {
fputs("Menu too big!\n", stderr);
getyx(cur_ms->ms_input, y, x);
(void) wmove(cur_ms->ms_input, y, 0);
- touchwin(cur_ms->ms_screen);
- refresh_ms(cur_ms);
+ refresh_screen();
(void) waddstr(cur_ms->ms_input, prompt);
getyx(cur_ms->ms_input, y, x);
(void) wmove(cur_ms->ms_input, y, x);
(void) touchwin(cur_ms->ms_screen);
(void) wclrtoeol(cur_ms->ms_input);
- refresh_ms(cur_ms);
+ (void) wrefresh(cur_ms->ms_input);
c = getchar() & 0x7f;
switch (c) {
case CTL('C'):
(void) wclear(cur_ms->ms_input);
(void) waddstr(cur_ms->ms_input, prompt);
(void) touchwin(cur_ms->ms_input);
- (void) mvcur(0, COLS - 1, LINES - 1, 0);
+ (void) move(LINES - 1, 0);
(void) wrefresh(curscr);
getyx(cur_ms->ms_input, y, x);
oldy = y;
}
end_input:
(void) waddch(cur_ms->ms_input, '\n');
- (void) waddch(cur_ms->ms_input, '\r');
(void) wclrtoeol(cur_ms->ms_input);
refresh_ms(cur_ms);
printf("%s", prompt);
if (gets(buf) == NULL)
return 0;
+ if (interrupt) {
+ interrupt = 0;
+ return 0;
+ }
Start_paging();
goto gotit;
}
(void) wclear(cur_ms->ms_input);
(void) waddstr(cur_ms->ms_input, prompt);
refresh_ms(cur_ms);
- (void) mvcur(0, COLS - 1, LINES - 1, 0);
+ (void) move(LINES - 1, 0);
(void) wrefresh(curscr);
getyx(cur_ms->ms_input, y, x);
break;
case '\n':
case '\r':
(void) waddch(cur_ms->ms_input, '\n');
- (void) waddch(cur_ms->ms_input, '\r');
(void) wclrtoeol(cur_ms->ms_input);
refresh_ms(cur_ms);
}
}
else {
-#ifdef _AUX_SOURCE
- struct termio ttybuf, nttybuf;
+#ifdef POSIX
+ struct termios ttybuf, nttybuf;
#else
struct sgttyb ttybuf, nttybuf;
-#endif /* _AUX_SOURCE */
+#endif /* POSIX */
printf("%s", prompt);
/* turn off echoing */
-#ifdef _AUX_SOURCE
- (void) ioctl(0, TCGETA, (char *)&ttybuf);
+#ifdef POSIX
+ tcgetattr(0, &ttybuf);
nttybuf = ttybuf;
nttybuf.c_lflag &= ~ECHO;
- (void)ioctl(0, TCSETA, (char *)&nttybuf);
+ tcsetattr(0, TCSANOW, &nttybuf);
if (gets(buf) == NULL) {
- (void) ioctl(0, TCSETA, (char *)&ttybuf);
+ tcsetattr(0, TCSANOW, &ttybuf);
putchar('\n');
return 0;
}
}
putchar('\n');
(void) ioctl(0, TIOCSETP, (char *)&ttybuf);
-#endif /* _AUX_SOURCE */
+#endif /* POSIX */
Start_paging();
return 1;
}
for (i = strlen(msg1); i < COLS - 1; i++)
msg1[i] = ' ';
(void) wprintw(cur_ms->ms_input, "%s\n", msg1);
-/* refresh_ms(cur_ms); */
}
else {
puts(msg);
refresh_ms(ms)
struct menu_screen *ms;
{
- int y, x;
-
- getyx(ms->ms_input, y, x);
- (void) wmove(ms->ms_screen, y + ms->ms_input_y, x);
- (void) wrefresh(ms->ms_screen);
+ (void) wrefresh(ms->ms_title);
+ (void) wrefresh(ms->ms_menu);
+ (void) wrefresh(ms->ms_input);
}
/* Parse buf into a list of words, which will be placed in strings specified by