⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.cpp

📁 用汇编写的编辑器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        {case ESC:goto Exit;
         case PGDN:
                 if(cur+height>=num) continue;
                 cur+=height;
                 break;
         case PGUP:
                 if(cur==0) continue;
                 cur-=height;
                 break;
         case CTRL_PGDN:
                 if(cur+height>=num) continue;
                for(;cur+height<num;cur+=height) ;
                 break;
         case CTRL_PGUP:
                 if(cur==0) continue;
                 cur=0;
                 break;
         default:continue;
        }
      clrscr();
    for(i=0;cur+i<num&&i<height;i++)
      {cputs(line[cur+i]);
       gotoxy(1,wherey()+1);
       }
     }

  Exit:
       for(i=0;i<=num;i++)
	 free(line[i]);
       return;

  OverFlow:
	fclose(stream);
	cputs("Too large file!!!");
	for(i=0;i<MAXLINE;i++)
	   free(line[i]);
	getch();
 }
/*-----------------Change_Cursor&Hide_Cursor Function------------*/
//
//光标改变
void Change_Cursor(char top,char end)

 {
   union REGS reg;
   reg.h.ah=1;
   reg.h.ch=top;
   reg.h.cl=end;
   int86(0x10,&reg,&reg);
  }

//隐藏光标
void Hide_Cursor(void)
 {
   Change_Cursor(15,0);
  }

//主程序

/**********************************************************\
*       |\/|   /\     |  |\  |                             *
*       |  |  /--\    |  | \ |                             *
*       |  | /    \   |  |  \|                             *
\************************Main Program**********************/

#define LEFT 331
#define RIGHT 333
#define UPPER 328
#define DOWN 336
#define ALT_X 301
#define ESC 27
#define ENTER 13

void WriteMnMenu(void);
void WriteSbMenu(void);
void SelectMenu(void);
void SelectMnMenu(void);
void SelectSbMenu(void);
int GetKey(void);
void SbFunGo(void);
void Screen(void);
void Wind(int,int,int,int,int,int,int,int,int);
void Quit(void);
void Hide_Cursor(void);

int Mm=0;                             //数据
int Smm[4];                         
int SbNum[4]={6,6,4,3};           
int SbWid[4]={10,10,10,10};
int SbX[4]={7,27,47,67};
int Key=0;
char Buf[1000];
char *Main[4]={"File","Edit","Run","About"};
char *Sub[4][6]={
		{"New",
		 "Open...",
		 "Save",
		 "Save as...",
		 "DOS shell",
		 "Quit"
		},
		{"Cut",
		 "Copy",
		 "Paste",
		 "Clear",
		 "Copy ",
		 "Search..."
		},
		{"Run",
		 "Program1",
		 "Program2",
		 "Go to..."
		},
		{"About",
		 "Help",
		 "Read me"
		}
		};
//####################################################
//主函数
int main(void)
{

  WINDOW *w,*w1,*w2;
  clrscr();
  Hide_Cursor();
 //&&&&&&&&&&&&&&&
  //////////////*********** 
  //显示主屏幕
  Screen();
  WriteMnMenu(); 
 //显示版权信息
 w=Window_Creat(24,8,56,18,
		201,205,187,186,188,205,200,186,
		YELLOW,REVERSE,"Welcome to");
  char fname[256];
  w1=Window_Creat(8,12,50,18,
		 201,205,187,186,188,205,200,186,
		 BRIGHT,REVERSE,"NEW");
  w2=Window_Creat(11,14,54,22,
		 201,205,187,186,188,205,200,186,
		 BRIGHT,REVERSE,"YEAR!");

 ////////////////
  Window_Open(w);
  cprintf("        Happy New Year!        ");          //显示版权信息
  cprintf("\n\r     Welcome To My Program!     ");
  cprintf("\n\r          Copyright           ");
  cprintf("\n\r         by Wan ZhiXin        ");
  cprintf("\n\r           2001-2002            ");
  cprintf("\n\r SouthWest JiaoTong University");
  getch();
  clrscr();
  Window_Title(w,"About...");
  cprintf("  This program is programed under the Turbo C++ 3.0 IDE.");
  cprintf("It is for the homework only!\n\r");
  cprintf("  It is an open source program,welcome to copy,welcome to paste!\n\r");
  cprintf("         ------Wan ZhiXin");
  getch();
  clrscr();
  cputs("\n\rThen,Press any key to watch the first demo!");
  getch();
  Window_Close(w);
//*************************


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

  Window_Open(w);
  Window_Change(w,5,10,48,16);
  Window_Title(w,"HAPPY");
  cputs("  \r*   *       *       * *     * *     *   *");
  cputs("\n\r*   *      * *      *  *    *  *     * * ");
  cputs("\n\r*****     *****     * *     * *       *  ");
  cputs("\n\r*   *    *     *    *       *         *  ");
  cputs("\n\r*   *   *       *   *       *         *  ");
  getch();
  Window_Open(w1);
  Window_Title(w1,"NEW");
  cputs("  \r *     *    ******    *       *       *");
  cputs("\n\r * *   *    *          *     * *     * ");
  cputs("\n\r *  *  *    ******      *   *   *   *  ");
  cputs("\n\r *   * *    *            * *     * *   ");
  cputs("\n\r *     *    ******        *       *    ");
  getch();
  Window_Open(w2);
  Window_Title(w2,"YEAR!");
  cputs("\r*   *   ******       *        * *       *");
cputs("\n\r * *    *           * *       *   *     *");
cputs("\n\r  *     ******     *****      * *       *");
cputs("\n\r  *     *         *     *     *  *      *");
cputs("\n\r  *     ******   *       *    *   *     @");
  getch();
  Window_Close(w2);
  getch();
  Window_Close(w1);
  getch();
  Window_Close(w);
  getch();
/////////////////*************
  Window_Open(w);
  Window_Change(w,1,1,25,12);
  Window_Title(w,"Change one");
  cputs("  This is a demo to change the window's position.");
  cputs("----Press any key...");
  getch();
  Window_Change(w,56,13,79,23);
  Window_Title(w,"Change two");
  cputs("  This is the second window.");
  cputs("\n\r----Press any key...to see the next demo!");
  getch();
  Window_Close(w);
  Window_Kill(w);  //w is dead
  ///////
  Window_Open(w1);
  Window_Change(w1,2,3,25,5);
  Window_Title(w1,"Input File Name");
  Window_Get(w1,fname);
  Window_Open(w2);
  Window_Change(w2,2,6,79,22);
  Window_Title(w2,fname);
  Window_File(w2,fname);
  getch();
   Window_Close(w1);
    Window_Close(w2);

    ///   // w1 dead
    // w2 dead
  //////
  Window_Kill(w1);
  Window_Kill(w2);

 //while(1).....

 ////////////////end while
    WriteSbMenu();
    SelectMenu();
    Quit();
    return 0;

}
//###########################################################
//设置屏幕
void Screen(void)
{
  window(1,1,80,25);        //
  textattr(0x17);          //设置背景颜色为蓝色
  clrscr();
  window(1,1,80,1);        //
  textattr(0x74);          //设置菜单条颜色为银灰色
  clrscr();
  window(1,24,80,24);      //
  textattr(0x74);          //设置底菜单颜色
  clrscr();
  textattr(0x74);cputs("  Enter ");
  textattr(0x7e);cputs("to do  ");
  textattr(0x74);cputs("ALT+X ");
  textattr(0x7e);cputs("or ");
  textattr(0x74);cputs("ESC ");
  textattr(0x7e);cputs("to quit");
  window(1,25,80,25);       //
  textattr(0x6E);           //设置底菜单颜色
  clrscr();
  cputs("  Copyright (C)2001-2002 SouthWest JiaoTong University by Wan ZhiXin ");
  Wind(1,2,80,23,2,0,1,15,1);
  window(1,1,80,25);
}
/*--------------------------------------------------------------------*/
/*设置边框属性:x1,y1左上角坐标,x2,y2右下角坐标,FrmTp为边框ASCII码
  BCl为文本框颜色,TCl为边框颜色    */
//绘制窗口
void Wind(int x1,int y1,int x2,int y2,
	  int FrmTp,int IsBk,int BCl,
	  int TCl,int BgCl)
{
   int i;
   int c[2][6]={{0xda,0xc4,0xbf,0xb3,0xc0,0xd9},
		{0xc9,0xcd,0xbb,0xba,0xc8,0xbc}};
   textcolor(TCl);
   textbackground(BCl);
   window(x1,y1,x2,y2);
   clrscr();
   if(FrmTp)
   {
     window(1,1,80,25);
     gotoxy(x1,y1);
     putch(c[FrmTp-1][0]);
     for(i=x1+1;i<x2;i++)
	putch(c[FrmTp-1][1]);
     putch(c[FrmTp-1][2]);
     for(i=y1+1;i<y2;i++)
     {
       gotoxy(x1,i);
       putch(c[FrmTp-1][3]);
       gotoxy(x2,i);
       putch(c[FrmTp-1][3]);
     }
     gotoxy(x1,y2);
     putch(c[FrmTp-1][4]);
     for(i=x1+1;i<x2;i++)
	putch(c[FrmTp-1][1]);
     putch(c[FrmTp-1][5]);
   }
   if(IsBk)
   {
      textcolor(BgCl);
      textbackground(0);
      for(i=y1+1;i<y2+1;i++)
      {
	gotoxy(x2+1,i);
	putch(0xb1);
      }
       for(i=x1+1;i<x2+2;i++)
      {
	gotoxy(i,y2+1);
	putch(0xb1);
      }
   }
   window(x1+1,y1+1,x2-1,y2-1);
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//绘制主菜单
void WriteMnMenu(void)
{
  int i=4;
  window(1,1,80,25);
  textattr(0x3e);
  for(i=0;i<4;i++)
  {
    gotoxy(SbX[i],1);
    cputs(Main[i]);
  }
  gotoxy(SbX[Mm],1);
  textattr(0x4e);
  cputs(Main[Mm]);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void WriteSbMenu(void)
{
  int i;
  gettext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf);
  Wind(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm],SbNum[Mm]+3,1,1,3,15,1);
  textattr(0x3f);
  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]]);
}
//================================================
void SelectMenu(void)
{
  while(Key!=ALT_X&&Key!=ESC)
  {
    Key=GetKey();
    if(Key==LEFT||Key==RIGHT) SelectMnMenu();
    if(Key==UPPER||Key==DOWN) SelectSbMenu();
    if(Key==ENTER) SbFunGo();
  }
  return;
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//选择主菜单
void SelectMnMenu(void)
{
  window(1,1,80,25);
  textattr(0x3e);
  gotoxy(SbX[Mm],1);
  cputs(Main[Mm]);
  textattr(0x31);
  puttext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf);
  if(Key==LEFT) Mm=Mm==0?3:Mm-1;
  if(Key==RIGHT) Mm=Mm==3?0:Mm+1;
  textattr(0x4e);
  gotoxy(SbX[Mm],1);
  cputs(Main[Mm]);
  WriteSbMenu();
}
//################################################
//选择子菜单
void SelectSbMenu(void)
{
  textattr(0x3f);
  gotoxy(2,1+Smm[Mm]);
  cputs(Sub[Mm][Smm[Mm]]);
  if(Key==UPPER) Smm[Mm]=Smm[Mm]==0?SbNum[Mm]-1:Smm[Mm]-1;
  if(Key==DOWN) Smm[Mm]=Smm[Mm]==SbNum[Mm]-1?0:Smm[Mm]+1;
  textattr(0x1e);
  gotoxy(2,Smm[Mm]+1);
  cputs(Sub[Mm][Smm[Mm]]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int GetKey(void)
{
  int Ch,Low,Hig;
  Ch=bioskey(0);
  Low=Ch&0x00ff;
  Hig=(Ch&0xff00)>>8;
  return(Low==0?Hig+256:Low);
}
//========================================================
void SbFunGo(void)
{
  switch(Mm)
  {
    case 0:
	 switch(Smm[0])
	 {
	   case 0: break;
	   case 1: break;
	   case 2: break;
	   case 3: break;
	   case 4: break;
	   case 5: break;
	   case 6: break;
	 }break;
    case 1:
	 switch(Smm[1])
	 {
	   case 0: break;
	   case 1: break;
	   case 2: break;
	   case 3: break;
	   case 4: break;
	   case 5: break;
	 }break;
    case 2:
	 switch(Smm[2])
	 {
	   case 0: break;
	   case 1: break;
	   case 2: break;
	   case 3: break;
	 }break;
    case 3:
	 switch(Smm[0])
	 {
	   case 0: break;
	   case 1: break;
	   case 2: break;
	 }break;
  }
}
/*----------------------------------------------------------------*/

void Quit(void)
{
   textbackground(0);
   textcolor(7);
   window(1,1,80,25);
   clrscr();
   printf("Copyright(C)2001-2002 by Wan ZhiXin SouthWest JiaoTong University.");
   exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -