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

📄 山海网络.htm

📁 curses界面编程
💻 HTM
📖 第 1 页 / 共 3 页
字号:
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
        <tr>
          <td width="2%" height="80" rowspan="2"></td>
          <td width="98%" height="69" valign="top" class="big" style="word-break:break-all;">#include<curses.h><BR> #include<stdlib.h><BR> #defineESC27<BR> #define<B style='color:black;background-color:#99ff99'>ENTER</B>10</font></P><P style="font-size:pt;line-height:pt"> #defineITEM_NUM_13<BR> #defineITEM_NUM_22<BR> #defineITEM_NUM_33<BR> #defineITEM_NUM_44</font></P><P style="font-size:pt;line-height:pt"> #defineITEM_NO_11<BR> #defineITEM_NO_22<BR> #defineITEM_NO_33<BR> #defineITEM_NO_44</font></P><P style="font-size:pt;line-height:pt"> voidinit_<B style='color:black;background-color:#ff9999'>curses</B>(void);<BR> voidDraw_menuhead(WINDOW*menuhead);<BR> WINDOW**Draw_menu(intstart_cols,intitemNo);<BR> intview_menu(WINDOW**items,/*intitemNum,*/intstart_cols,intitemNo);<BR> voidDel_menu(WINDOW**items,intitemNum);<BR> intitem_num(intitemNo);</font></P><P style="font-size:pt;line-height:pt"> main()<BR> {<BR> WINDOW*menuhead,*message;<BR> WINDOW**items;/*菜单项目指针,数组元素指向菜单项子项*/<BR> intKey;<BR> intcount;/*菜单子项的数目*/<BR> intRe_item;/*菜单浏览返回值*/</font></P><P style="font-size:pt;line-height:pt"> init_<B style='color:black;background-color:#ff9999'>curses</B>();</font></P><P style="font-size:pt;line-height:pt"> wbkgd(stdscr,COLOR_PAIR(1));<BR> menuhead=subwin(stdscr,1,80,0,0);<BR> message=subwin(stdscr,1,79,23,1);</font></P><P style="font-size:pt;line-height:pt"> Draw_menuhead(menuhead);/*绘制菜单头部*/<BR> move(2,1);<BR> printw("PleaseF1--F4SelectMenu...");<BR> move(3,1);<BR> printw("PleaseESCQuit...");<BR> do{<BR> Key=getch();<BR> switch(Key){<BR> case<B style='color:black;background-color:#ffff66'>KEY_</B>F(1):<BR> items=Draw_menu(3,ITEM_NO_1);/*第3列,第1菜单*/<BR> Re_item=view_menu(items,/*ITEM_NUM_1,*/3,ITEM_NO_1);<BR> touchwin(stdscr);<BR> refresh();<BR> break;<BR> case<B style='color:black;background-color:#ffff66'>KEY_</B>F(2):<BR> items=Draw_menu(23,ITEM_NO_2);/*第23列,第2菜单*/<BR> Re_item=view_menu(items,/*ITEM_NUM_2,*/23,ITEM_NO_2);<BR> touchwin(stdscr);<BR> refresh();<BR> break;</font></P><P style="font-size:pt;line-height:pt"> case<B style='color:black;background-color:#ffff66'>KEY_</B>F(3):<BR> items=Draw_menu(43,ITEM_NO_3);/*第43列,第3菜单*/<BR> Re_item=view_menu(items,/*ITEM_NUM_3,*/43,ITEM_NO_3);<BR> touchwin(stdscr);<BR> refresh();<BR> break;<BR> case<B style='color:black;background-color:#ffff66'>KEY_</B>F(4):<BR> items=Draw_menu(63,ITEM_NO_4);/*第63列,第4菜单*/<BR> Re_item=view_menu(items,/*ITEM_NUM_4,*/63,ITEM_NO_4);<BR> touchwin(stdscr);<BR> refresh();<BR> break;<BR> default:break;<BR> }<BR> }while(Key!=ESC);</font></P><P style="font-size:pt;line-height:pt"> delwin(message);<BR> delwin(menuhead);<BR> endwin();<BR> exit(0);<BR> }</font></P><P style="font-size:pt;line-height:pt"> voidDraw_menuhead(WINDOW*menuhead)<BR> {<BR> wbkgd(menuhead,COLOR_PAIR(2));<BR> wrefresh(menuhead);<BR> wmove(menuhead,0,0);<BR> waddstr(menuhead,"菜单1");<BR> wattron(menuhead,COLOR_PAIR(3));<BR> waddstr(menuhead,"(F1)");<BR> wattroff(menuhead,COLOR_PAIR(3));<BR> wmove(menuhead,0,20);<BR> waddstr(menuhead,"菜单2");<BR> wattron(menuhead,COLOR_PAIR(3));<BR> waddstr(menuhead,"(F2)");<BR> wattroff(menuhead,COLOR_PAIR(3));<BR> wmove(menuhead,0,40);<BR> waddstr(menuhead,"菜单3");<BR> wattron(menuhead,COLOR_PAIR(3));<BR> waddstr(menuhead,"F(3)");<BR> wattroff(menuhead,COLOR_PAIR(3));<BR> wmove(menuhead,0,60);<BR> waddstr(menuhead,"菜单4");<BR> wattron(menuhead,COLOR_PAIR(3));<BR> waddstr(menuhead,"F(4)");<BR> wattroff(menuhead,COLOR_PAIR(3));<BR> }</font></P><P style="font-size:pt;line-height:pt"> voidinit_<B style='color:black;background-color:#ff9999'>curses</B>(void)<BR> {<BR> initscr();<BR> noecho();<BR> keypad(stdscr,TRUE);<BR> /*intrflush(stdscr,FALSE);*/<BR> start_color();/*初始化*/<BR> init_pair(1,COLOR_WHITE,COLOR_BLUE);<BR> init_pair(2,COLOR_BLUE,COLOR_WHITE);<BR> init_pair(3,COLOR_RED,COLOR_WHITE);</font></P><P style="font-size:pt;line-height:pt"> curs_set(0);/*设置光标不可见*/<BR> }</font></P><P style="font-size:pt;line-height:pt"> WINDOW**Draw_menu(intstart_cols,intitemNo)<BR> {<BR> WINDOW**items;</font></P><P style="font-size:pt;line-height:pt"> switch(itemNo){<BR> case1:<BR> items=(WINDOW**)malloc((ITEM_NUM_1+1)*sizeof(WINDOW*));</font></P><P style="font-size:pt;line-height:pt"> items[0]=newwin(ITEM_NUM_1+2,19,1,start_cols);<BR> wbkgd(items[0],COLOR_PAIR(2));<BR> box(items[0],ACS_VLINE,ACS_HLINE);</font></P><P style="font-size:pt;line-height:pt"> items[1]=subwin(items[0],1,17,2,start_cols+1);<BR> wprintw(items[1],"子项A1");<BR> items[2]=subwin(items[0],1,17,3,start_cols+1);<BR> wprintw(items[2],"子项A2");<BR> items[3]=subwin(items[0],1,17,4,start_cols+1);<BR> wprintw(items[3],"子项A3");<BR> /*items[4]=subwin(items[0],1,17,5,start_cols+1);<BR> wprintw(items[4],"子项A4");*/<BR> break;<BR> case2:<BR> items=(WINDOW**)malloc((ITEM_NUM_2+1)*sizeof(WINDOW*));</font></P><P style="font-size:pt;line-height:pt"> items[0]=newwin(ITEM_NUM_2+2,19,1,start_cols);<BR> wbkgd(items[0],COLOR_PAIR(2));<BR> box(items[0],ACS_VLINE,ACS_HLINE);</font></P><P style="font-size:pt;line-height:pt"> items[1]=subwin(items[0],1,17,2,start_cols+1);<BR> wprintw(items[1],"子项B1");<BR> items[2]=subwin(items[0],1,17,3,start_cols+1);<BR> wprintw(items[2],"子项B2");<BR> /*items[3]=subwin(items[0],1,17,4,start_cols+1);<BR> wprintw(items[3],"子项B3");<BR> items[4]=subwin(items[0],1,17,5,start_cols+1);<BR> wprintw(items[4],"子项B4");*/<BR> break;<BR> case3:<BR> items=(WINDOW**)malloc((ITEM_NUM_3+1)*sizeof(WINDOW*));</font></P><P style="font-size:pt;line-height:pt"> items[0]=newwin(ITEM_NUM_3+2,19,1,start_cols);<BR> wbkgd(items[0],COLOR_PAIR(2));<BR> box(items[0],ACS_VLINE,ACS_HLINE);</font></P><P style="font-size:pt;line-height:pt"> items[1]=subwin(items[0],1,17,2,start_cols+1);<BR> wprintw(items[1],"子项C1");<BR> items[2]=subwin(items[0],1,17,3,start_cols+1);<BR> wprintw(items[2],"子项C2");<BR> items[3]=subwin(items[0],1,17,4,start_cols+1);<BR> wprintw(items[3],"子项C3");<BR> /*items[4]=subwin(items[0],1,17,5,start_cols+1);<BR> wprintw(items[4],"子项C4");*/<BR> break;<BR> case4:<BR> items=(WINDOW**)malloc((ITEM_NUM_4+1)*sizeof(WINDOW*));</font></P><P style="font-size:pt;line-height:pt"> items[0]=newwin(ITEM_NUM_4+2,19,1,start_cols);<BR> wbkgd(items[0],COLOR_PAIR(2));<BR> box(items[0],ACS_VLINE,ACS_HLINE);</font></P><P style="font-size:pt;line-height:pt"> items[1]=subwin(items[0],1,17,2,start_cols+1);<BR> wprintw(items[1],"子项D1");<BR> items[2]=subwin(items[0],1,17,3,start_cols+1);<BR> wprintw(items[2],"子项D2");<BR> items[3]=subwin(items[0],1,17,4,start_cols+1);<BR> wprintw(items[3],"子项D3");<BR> items[4]=subwin(items[0],1,17,5,start_cols+1);<BR> wprintw(items[4],"子项D4");<BR> break;<BR> default:break;<BR> }<BR> wbkgd(items[1],COLOR_PAIR(1));<BR> wrefresh(items[0]);<BR> returnitems;<BR> }</font></P><P style="font-size:pt;line-height:pt"> view_menu(WINDOW**items,/*intitemNum,*/intstart_cols,intitemNo)<BR> {<BR> intselect=0;/*适应求余算法,0--itemNum-1,对应1--itemNum*/<BR> intKey;<BR> intitemNum;</font></P><P style="font-size:pt;line-height:pt"> itemNo=itemNo-1;/*适应求余算法,0--3对应1--4*/<BR> wrefresh(items[0]);<BR> A1:<BR> itemNum=item_num(itemNo+1);<BR> while(1){<BR> Key=getch();<BR> if(Key==<B style='color:black;background-color:#ffff66'>KEY_</B>DOWN||Key==<B style='color:black;background-color:#ffff66'>KEY_</B>UP){<BR> wbkgd(items[select+1],COLOR_PAIR(2));<BR> wnoutrefresh(items[select+1]);<BR> if(Key==<B style='color:black;background-color:#ffff66'>KEY_</B>DOWN)<BR> select=(select+1)%itemNum;<BR> else<BR> select=(select+itemNum-1)%itemNum;<BR> wbkgd(items[select+1],COLOR_PAIR(1));<BR> wnoutrefresh(items[select+1]);/*select+1为第几项目1/2/3../itemNum*/<BR> doupdate();<BR> }<BR> else{<BR> if(Key==<B style='color:black;background-color:#ffff66'>KEY_</B>LEFT||Key==<B style='color:black;background-color:#ffff66'>KEY_</B>RIGHT){<BR> Del_menu(items,itemNum+1);<BR> touchwin(stdscr);<BR> refresh();<BR> if(Key==<B style='color:black;background-color:#ffff66'>KEY_</B>RIGHT)<BR> if(start_cols<63){<BR> itemNo=(itemNo+1)%4;/*4:一共4个菜单*/<BR> start_cols=start_cols+20;/*20:菜单之间原点间隔数*/<BR> }<BR> else{<BR> itemNo=0;<BR> start_cols=3;<BR> }<BR> else<BR> if(start_cols>3){<BR> itemNo=(itemNo+4-1)%4;<BR> start_cols=start_cols-20;<BR> }<BR> else{<BR> itemNo=3;<BR> start_cols=63;<BR> }</font></P><P style="font-size:pt;line-height:pt"> items=Draw_menu(start_cols,itemNo+1);/*itemNo+1为菜单号1\2\3\4*/<BR> select=0;</font></P><P style="font-size:pt;line-height:pt"> gotoA1;<BR> /*returnview_menu(items,4,start_cols);*/<BR> }<BR> if(Key==ESC)return-1;<BR> else<BR> if(Key==<B style='color:black;background-color:#99ff99'>ENTER</B>){<BR> return1;/**/<BR> }<BR> }<BR> }<BR> }</font></P><P style="font-size:pt;line-height:pt"> <BR> voidDel_menu(WINDOW**items,intitemNum)<BR> {<BR> inti;</font></P><P style="font-size:pt;line-height:pt"> for(i=0;idelwin(items[i]);<BR> free(items);<BR> }</font></P><P style="font-size:pt;line-height:pt"> <BR> item_num(intitemNo)/*根据菜单号找出对应项目数*/<BR> {<BR> switch(itemNo){<BR> case1:returnITEM_NUM_1;<BR> case2:returnITEM_NUM_2;<BR> case3:returnITEM_NUM_3;<BR> case4:returnITEM_NUM_4;<BR> }<BR> }</font></P><P style="font-size:pt;line-height:pt"> </font></P><P style="font-size:pt;line-height:pt"> <BR> </td>
        </tr>
        <tr>
          <td width="98%" height="11" valign="top" class="big">
		  -----------------------------------------------------------------------<br>我的QQ号是240031756,手机13197486034,电话07168084062,真诚希望广大计算机爱好者加我为好友。
		  </td>
        </tr>
        <tr>
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1>
  <tr>
    <td width="657"><img border="0" src="images/reply_a.gif"> </td>
    <td width="89" align="center">	  
	<a href=#top><font color=blue><b>Top</b></font></a>
	 </td>
  </tr>
</table>
<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1>
  <tr bgcolor=#e3f1d1>
    <td width="100%" height="22" class="big"> shuilinger         
      (<font color=blue></font>)            
      2004-6-17 14:23:20             
	 <img src=images/level1.gif>
	  </td>
  </tr>
</table>
<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1 height="42">
  <tr>
    <td width="100%" height="40">
      <table border="0" cellpadding="0" cellspacing="0" width="100%" height="120">
        <tr>
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
        <tr>
          <td width="2%" height="80" rowspan="2"></td>
          <td width="98%" height="69" valign="top" class="big" style="word-break:break-all;">哇~~~!都做好了,谢谢夕辉哥哥喽*_*<BR> </td>
        </tr>
        <tr>
          <td width="98%" height="11" valign="top" class="big">
		  -----------------------------------------------------------------------<br>
		  </td>
        </tr>
        <tr>
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1>
  <tr>
    <td width="657"><img border="0" src="images/reply_a.gif"> </td>
    <td width="89" align="center">	  
	<a href=#top><font color=blue><b>Top</b></font></a>
	 </td>
  </tr>
</table>
<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1>
  <tr bgcolor=#e3f1d1>
    <td width="100%" height="22" class="big"> shuilinger         
      (<font color=blue></font>)            
      2004-6-17 14:42:14             
	 <img src=images/level1.gif>
	  </td>
  </tr>
</table>
<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1 height="42">
  <tr>
    <td width="100%" height="40">
      <table border="0" cellpadding="0" cellspacing="0" width="100%" height="120">
        <tr>
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
        <tr>
          <td width="2%" height="80" rowspan="2"></td>
          <td width="98%" height="69" valign="top" class="big" style="word-break:break-all;">这两天要考试了,特别忙,我怎么运行不成啊,我用的是你写的第一个程序,好象说不能打开你开头的那5个函数,是不是我的编译器没装对??</font></P><P style="font-size:pt;line-height:pt"> </td>
        </tr>
        <tr>
          <td width="98%" height="11" valign="top" class="big">
		  -----------------------------------------------------------------------<br>
		  </td>
        </tr>
        <tr>
          <td width="2%" height="20"></td>
          <td width="98%" height="20"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="751" align=center>
  <tr>
    <td width="100%" class="big">
      <p align="right"></td>
  </tr>
</table>

<table bordercolor=#333333 cellspacing=0 cellpadding=0 width=751 align=center border=1>
  <tr>
    <td width="100%" height="17"></td>
  </tr>
  <tr>
    <td width="100%" height="101">
      <p align="center"><font color="#0000FF">你尚未登陆,如果回复,请先登陆</font>               
					   </td>
  </tr>
  <tr>
    <td width="100%" height="25">
      <p align="right"><input type="submit" value="回复" name="B1"> 
    </td>
  </tr>
</table>
 <table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td bgcolor="#6DB178" height="4"></td>
  </tr>
  <tr>
    <td bgcolor="#eeeeee" height="12"></td>
  </tr>
</table>
<table border="0" cellPadding="0" cellSpacing="0" width="760" align="center" height="85">
  <tr align="middle">
      <td height="23"></td> 
    </tr>
    <tr align="middle">
      
    <td height="24"> 
      <p align="center"> 版权所有<img src="images/logo3.gif" width="80" height="20" align="absmiddle"> 
        <a href="mailto:webmaster@156.com">webmaster@156ok.com</a></p>
      </td>
    </tr>
    <tr align="middle">
      <td  height="20">
        <p align="center">Copyright (c) 156ok.com, Inc. All rights reserved</p> 
      </td> 
    </tr>
    <tr>
      <td height="18"></td>
    </tr>
</table>

⌨️ 快捷键说明

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