]> andersk Git - moira.git/commitdiff
update for new com_err library
authormar <mar>
Mon, 26 Jun 1989 13:42:39 +0000 (13:42 +0000)
committermar <mar>
Mon, 26 Jun 1989 13:42:39 +0000 (13:42 +0000)
Fix for wrapped long lines on input

clients/moira/menu.c

index 538f7b2125a5658853207615a871ba5986e83a4c..89d40ed2c19cd8efe91be00c0147c4d3519747cb 100644 (file)
@@ -33,6 +33,10 @@ static char rcsid_menu_c[] = "$Header$";
 #include <com_err.h>
 #include "menu.h"
 
+#ifndef __STDC__
+#define const
+#endif
+
 #define MAX(A,B)       ((A) > (B) ? (A) : (B))
 #define MIN(A,B)       ((A) < (B) ? (A) : (B))
 #define CTL(ch)                ((ch) & 037)
@@ -65,11 +69,11 @@ Menu *top_menu;                     /* Root for command search */
  * curses instead of around it.
  */
 
-int
+void
 menu_com_err_hook(who, code, fmt, args)
-    char *who;
-    int code;
-    char *fmt;
+    const char *who;
+    long code;
+    const char *fmt;
     va_list args;
 {
     char buf[BUFSIZ], *cp;
@@ -103,7 +107,11 @@ Start_menu(m)
     Menu *m;
 {
     struct menu_screen *make_ms();
-    register int (*old_hook)() = set_com_err_hook(menu_com_err_hook);
+#ifdef __STDC__
+    register void (*old_hook)(const char *, long, const char *, va_list) = set_com_err_hook(menu_com_err_hook);
+#else
+    register void (*old_hook)() = set_com_err_hook(menu_com_err_hook);
+#endif
     
     if (initscr() == ERR) {
        fputs("Can't initialize curses!\n", stderr);
@@ -197,7 +205,7 @@ Do_menu(m, margc, margv)
     int margc;
     char *margv[];
 {
-    struct menu_screen *my_ms, *old_cur_ms;
+    struct menu_screen *my_ms = NULLMS, *old_cur_ms = NULLMS;
     char argvals[MAX_ARGC][MAX_ARGLEN];        /* This is where args are stored */
     char buf[MAX_ARGC * MAX_ARGLEN];
     char *argv[MAX_ARGC];
@@ -375,7 +383,7 @@ int Prompt_input(prompt, buf, buflen)
 {
     int c;
     char *p;
-    int y, x, oldx;
+    int y, x, oldx, oldy;
 
     if (cur_ms != NULLMS) {
        more_flg = 1;
@@ -388,6 +396,7 @@ int Prompt_input(prompt, buf, buflen)
        getyx(cur_ms->ms_input, y, x);
 
        oldx = x;
+       oldy = y;
        p = buf;
        while(1) {
            (void) wmove(cur_ms->ms_input, y, x);
@@ -411,6 +420,9 @@ int Prompt_input(prompt, buf, buflen)
                refresh_ms(cur_ms);
 #endif notdef
                getyx(cur_ms->ms_input, y, x);
+               oldy = y;
+               oldx = x;
+               p = buf;
                break;
 
            case '\n':
@@ -422,12 +434,19 @@ int Prompt_input(prompt, buf, buflen)
                if (p > buf) {
                    p--;
                    x--;
+                   if (x < 0) {
+                       (void) wmove(cur_ms->ms_input, y, 0);
+                       (void) wclrtoeol(cur_ms->ms_input);
+                       y--;
+                       x = cur_ms->ms_input->_maxx-1;
+                   }
                }
                break;
            case CTL('U'):
            case CTL('G'):
            case CTL('['):
                x = oldx;
+               y = oldy;
                p = buf;
                break;
            default:
@@ -436,6 +455,10 @@ int Prompt_input(prompt, buf, buflen)
                    (void) waddch(cur_ms->ms_input, c);
                    *p++ = c;
                    x++;
+                   if (x >= cur_ms->ms_input->_maxx) {
+                       x = 0;
+                       y++;
+                   }
                } else
                    putchar(CTL('G'));
                break;
This page took 0.059756 seconds and 5 git commands to generate.