/**** SCME.C + S_BOOK4.C ***************/
#include <stdio.h>
#include <bios.h>
#define UPPER (72+256)
#define LEFT (75+256)
#define RIGHT (77+256)
#define DOWN (80+256)
#define ENTER 13
#define ESC 27
#include <stdlib.h>
struct node
{ char name[10];
int price;
char pub[15];
};
struct node *head=NULL;
int Hj=20,Mm=0,Smm[5],SbNum[5]={5,6,2,4,6};/*子菜单的个数*/
int SbWid[5]={10,10,10,10,10};
int SbX[5]={5,15,25,35,45};
int Key=0;
char buf[1000]; /*用于保存屏幕的存储区*/
char *edithelp = " Move Cursor: Left,Right,Up,Down,PgUp,PgDn | Alt+c-Copy,Alt+y-Cut Alt+p-Paste";
char *mainhelp = " F1-Save F2-Open F3-Search F4-Replace F5-Undo F6-Redo ESC-Menu";
char *Main[5]={"File","Edit","Search","Option","book"};
char *Sub[5][6]={
{ "New","Open","Save","Save as","Exit"},
{ "Cut ","Copy","Paste","Del","Select All","Edit"},
{ "Find ","Replace"},
{ "Undo ","Redo","Config","Help"},
{ "add","list","search","del","save","load"}
};
void main( )
{
InitScreen(); /*初始化屏幕*/
WMainMenu(); /*显示主菜单*/
WSubMenu(); /*显示子菜单*/
SelectMenu(); /*根据用户按键,处理相事务*/
Quit(); /*恢复屏幕*/
}
void disp_menu_item(int x,int y,int fcolor,int bcolor,char *string)
{ textbackground(bcolor);
textcolor(fcolor);
gotoxy(x,y);
cputs(string); /*显示字符串*/
}
WMainMenu(void)
{
int i;
window(1,1,80,25);
textattr(0x3e);
for(i=0;i<5;i++)
{
gotoxy(SbX[i],1);
cputs(Main[i]);
}
gotoxy(SbX[Mm],1);
textattr(0x4e); /*同时设置前景和背景颜色*/
cputs(Main[Mm]); /*以上3句是设置默认选择File菜单*/
}
WSubMenu(void)
{
int i;
gettext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4+1,buf); /*保存和恢复屏幕区域*/
Wind(SbX[Mm]-2,2+1,SbX[Mm]+SbWid[Mm],SbNum[Mm]+3+1,1,3,15);
textattr(0x3f);
clrscr();
for(i=0;i<SbNum[Mm];i++)
{
gotoxy(2,1+i);
cputs(Sub[Mm][i]);
}
textattr(0x1e);
gotoxy(2,Smm[Mm]+1);
cputs(Sub[Mm][Smm[Mm]]); /*以上3句是设置默认选择File菜单下的Open*/
}
Quit(void)
{
textbackground(0);
textcolor(7);
window(1,1,80,25);
clrscr();
}
int SubFunGo()
{
switch(Mm)
{
case 0: /*file: new