]> andersk Git - moira.git/blobdiff - clients/moira/menu.c
randomized continuation lines
[moira.git] / clients / moira / menu.c
index 892e3db881a6c07890bd86a73e92d50c0faea6f5..6c0ae53fc23bd50f5487ded3723adb36e37b8573 100644 (file)
@@ -25,16 +25,19 @@ static char rcsid_menu_c[] = "$Header$";
 #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__
@@ -47,14 +50,21 @@ static char rcsid_menu_c[] = "$Header$";
 
 #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 */
@@ -114,7 +124,7 @@ Start_menu(m)
     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 {
@@ -158,7 +168,6 @@ make_ms(length)
     int length;
 {
     struct menu_screen *ms;
-    char *malloc();
 
     if (MAX_TITLE + length + MIN_INPUT > LINES) {
        fputs("Menu too big!\n", stderr);
@@ -429,8 +438,7 @@ int Prompt_input(prompt, buf, buflen)
        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);
 
@@ -441,7 +449,7 @@ int Prompt_input(prompt, buf, buflen)
            (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'):
@@ -455,7 +463,7 @@ int Prompt_input(prompt, buf, buflen)
                (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;
@@ -504,7 +512,6 @@ int Prompt_input(prompt, buf, buflen)
        }
     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);
@@ -515,6 +522,10 @@ int Prompt_input(prompt, buf, buflen)
        printf("%s", prompt);
        if (gets(buf) == NULL)
            return 0;
+       if (interrupt) {
+           interrupt = 0;
+           return 0;
+       }
        Start_paging();
        goto gotit;
     }
@@ -561,14 +572,13 @@ int Password_input(prompt, buf, buflen)
                (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);
@@ -593,20 +603,20 @@ int Password_input(prompt, buf, buflen)
        }
     }
     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;
        }
@@ -624,7 +634,7 @@ int Password_input(prompt, buf, buflen)
        }
        putchar('\n');
        (void) ioctl(0, TIOCSETP, (char *)&ttybuf);
-#endif /* _AUX_SOURCE */
+#endif /* POSIX */
        Start_paging();
        return 1;
     }
@@ -725,7 +735,6 @@ char *msg;
        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);
@@ -736,11 +745,9 @@ char *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
This page took 0.063423 seconds and 4 git commands to generate.