在Unix下用C编写类Windows菜单
:
memcpy(buff, &menu_item[k], i-k);
buff[i-k] = 0;
strcpy(m_item.prog,buff);
k=i+1;
break;
case 6:
memcpy(buff, &menu_item[k], i-k);
buff[i-k] = 0;
m_item.submenu_code = atoi(buff);
k=i+1;
break;
default:
break;
}
}
}
}
void initial() /* 自定开启 curses 函式 */
{
initscr();
cbreak(); nonl(); noecho();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
}
/* 按键等待函数 */
void keycont()
{
fprintf(stderr, "按键继续..."); getchar();
}
/* 运行可执行程序函数 */
void execprog()
{
system("clear");
fprintf(stderr, "%s: \n", scrpos->item);
system(scrpos->prog);
keycont(); initial();
touchwin(boxwin); touchwin(curw); keypad(curw, TRUE);
wrefresh(boxwin); wrefresh(curw);
}
/* 清除窗口函数 */
void clearwin()
{
wmove(boxwin, 0, 0);
wclrtobot(boxwin); wrefresh(boxwin); delwin(curw); delwin(boxwin);
}
三 编译说明
该程序可用如下命令编译(在SCO OpenServer 5.05下编译通过):
cc -o menu menu.c -lcurses
memcpy(buff, &menu_item[k], i-k);
buff[i-k] = 0;
strcpy(m_item.prog,buff);
k=i+1;
break;
case 6:
memcpy(buff, &menu_item[k], i-k);
buff[i-k] = 0;
m_item.submenu_code = atoi(buff);
k=i+1;
break;
default:
break;
}
}
}
}
void initial() /* 自定开启 curses 函式 */
{
initscr();
cbreak(); nonl(); noecho();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
}
/* 按键等待函数 */
void keycont()
{
fprintf(stderr, "按键继续..."); getchar();
}
/* 运行可执行程序函数 */
void execprog()
{
system("clear");
fprintf(stderr, "%s: \n", scrpos->item);
system(scrpos->prog);
keycont(); initial();
touchwin(boxwin); touchwin(curw); keypad(curw, TRUE);
wrefresh(boxwin); wrefresh(curw);
}
/* 清除窗口函数 */
void clearwin()
{
wmove(boxwin, 0, 0);
wclrtobot(boxwin); wrefresh(boxwin); delwin(curw); delwin(boxwin);
}
三 编译说明
该程序可用如下命令编译(在SCO OpenServer 5.05下编译通过):
cc -o menu menu.c -lcurses

