if (c == keyesc) { if ((value = top_menu(wintab, top, 1)) == 0) return 0; buf[0] = '~'; switch (value) { case 0x01: { buf[1] = 'r';
if (c == keyesc) { if ((value = top_menu(wintab, top, 1)) == 0) return 0; buf[0] = '~'; switch (value) { case 0x01: { buf[1] = 'r'; return 2; } case 0x02: { buf[1] = '.'; return 2; } case 0x11: { buf[1] = 'o'; getstring(wintab, "Please enter filename: ", &buf[2]); return strlen(buf); } case 0x12: { buf[1] = 'c'; return 2; } case 0x13: case 0x14: case 0x15: { switch (value) { case 0x13: buf[1] = 'u'; break; case 0x14: buf[1] = 'b'; break; case 0x15: buf[1] = 'a'; } getstring(wintab, "Please enter filename: ", buf + 2); return strlen(buf); } case 0x21: { buf[1] = '1'; return 2; } case 0x22: { buf[1] = '2'; return 2; } case 0x23: { buf[1] = '0'; return 2; } case 0x31: return -1; } wrefresh(win_out->ptr);
int readoutg(t_win * win_out, wint * wintab, menuitem * top, char buf[], int keyesc){    int out_cnt;    int c;    int ypos = 0, xpos = 0;    int value;    c = getch();    if (c == ERR)	return 0;    if (c == keyesc) {	if ((value = top_menu(wintab, top, 1)) == 0)	    return 0;	buf[0] = '~';	switch (value) {	case 0x01:	    {		buf[1] = 'r';		return 2;	    }	case 0x02:	    {		buf[1] = '.';		return 2;	    }	case 0x11:	    {		buf[1] = 'o';		getstring(wintab, "Please enter filename: ", &buf[2]);		return strlen(buf);	    }	case 0x12:	    {		buf[1] = 'c';		return 2;	    }	case 0x13:	case 0x14:	case 0x15:	    {		switch (value) {		case 0x13:		    buf[1] = 'u';		    break;		case 0x14:		    buf[1] = 'b';		    break;		case 0x15:		    buf[1] = 'a';		}		getstring(wintab, "Please enter filename: ", buf + 2);		return strlen(buf);	    }	case 0x21:	    {		buf[1] = '1';		return 2;	    }	case 0x22:	    {		buf[1] = '2';		return 2;	    }	case 0x23:	    {		buf[1] = '0';		return 2;	    }	case 0x31:	    return -1;	}	wrefresh(win_out->ptr);	return 2;    }    switch (c) {    case KEY_BACKSPACE:    case 127:	{	    getyx(win_out->ptr, ypos, xpos);	    if (win_out->bytes > 0) {		if (win_out->curs_pos < win_out->bytes) {		    mvwaddnstr(win_out->ptr, ypos, --xpos, &win_out->string[win_out->curs_pos], win_out->bytes - win_out->curs_pos);		    waddch(win_out->ptr, ' ');		    memmove(&win_out->string[win_out->curs_pos - 1], &win_out->string[win_out->curs_pos], win_out->bytes - win_out->curs_pos);		} else		    mvwaddch(win_out->ptr, ypos, --xpos, ' ');		wmove(win_out->ptr, ypos, xpos);		win_out->bytes--;		win_out->curs_pos--;	    }	}	break;    case KEY_LEFT:	if (win_out->curs_pos > 0) {	    win_out->curs_pos--;	    getyx(win_out->ptr, ypos, xpos);	    wmove(win_out->ptr, ypos, xpos - 1);	}	break;    case KEY_RIGHT:	if (win_out->curs_pos < win_out->bytes) {	    win_out->curs_pos++;	    getyx(win_out->ptr, ypos, xpos);	    wmove(win_out->ptr, ypos, xpos + 1);	}	break;    case KEY_ENTER:    case (int) '\n':    case (int) '\r':	{	    if (win_out->curs_pos < win_out->bytes) {		getyx(win_out->ptr, ypos, xpos);		wmove(win_out->ptr, ypos, xpos + win_out->bytes - win_out->curs_pos);	    }	    waddch(win_out->ptr, '\n');	    win_out->string[win_out->bytes++] = (char) '\n';	    wrefresh(win_out->ptr);	    strncpy(buf, win_out->string, win_out->bytes);	    wrefresh(win_out->ptr);	    out_cnt = win_out->bytes;	    win_out->bytes = 0;	    win_out->curs_pos = 0;	    return out_cnt;	}	break;    default:	{	    waddch(win_out->ptr, (char) c);	    if (win_out->curs_pos < win_out->bytes) {		getyx(win_out->ptr, ypos, xpos);		waddnstr(win_out->ptr, &win_out->string[win_out->curs_pos], win_out->bytes - win_out->curs_pos);		memmove(&win_out->string[win_out->curs_pos + 1], &win_out->string[win_out->curs_pos], win_out->bytes - win_out->curs_pos);		win_out->string[win_out->curs_pos] = (char) c;		wmove(win_out->ptr, ypos, xpos);	    } else		win_out->string[win_out->bytes] = (char) c;	    win_out->bytes++;	    win_out->curs_pos++;	}    }    wrefresh(win_out->ptr);    return 0;}