📄 9第九章:窗口机制(all about window functions).htm
字号:
1'> </span><span style='mso-tab-count:1'> </span>/*</span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>计算窗口中心位置的列数</span><span lang=EN-US><span style='mso-tab-count:1'> </span>*/</span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>printw("</span></b><spanlang=EN-US style='font-family:Tahoma'>Press F1 to exit<b style='mso-bidi-font-weight:normal'>");<o:p></o:p></b></span></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>refresh();<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>my_win= create_newwin(height, width, starty, startx);<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>while((ch= getch()) != KEY_F(1))<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>{<spanstyle='mso-tab-count:1'> </span>switch(ch)<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:2'> </span>{<spanstyle='mso-tab-count:1'> </span>case KEY_LEFT:<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>destroy_win(my_win);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>my_win= create_newwin(height, width, starty,--startx);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>break;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:3'> </span>caseKEY_RIGHT:<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>destroy_win(my_win);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>my_win= create_newwin(height, width, starty,++startx);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>break;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:3'> </span>caseKEY_UP:<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>destroy_win(my_win);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>my_win= create_newwin(height, width, --starty,startx);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>break;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:3'> </span>caseKEY_DOWN:<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>destroy_win(my_win);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>my_win= create_newwin(height, width, ++starty,startx);<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:4'> </span>break;<spanstyle='mso-tab-count:1'> </span><o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:2'> </span>}<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>}<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:2'> </span><o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>endwin();<spanstyle='mso-tab-count:3'> </span></span></b><spanlang=EN-US>/*</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>结束</span><span lang=EN-US> curses</span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>模式</span><span lang=EN-US><span style='mso-tab-count:1'> </span>*/</span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'><o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><span style='mso-tab-count:1'> </span>return0;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>}<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><o:p> </o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>WINDOW *create_newwin(int height, int width, intstarty, int startx)<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>{<span style='mso-tab-count:1'> </span>WINDOW*local_win;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><o:p> </o:p></span></b></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>local_win= newwin(height, width, starty, startx);<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>box(local_win,0 , 0);</span></b><span lang=EN-US><span style='mso-tab-count:2'> </span>/*0, 0</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>是字符默认的行列起始位置</span> <span lang=EN-US>*/</span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>wrefresh(local_win);</span></b><spanlang=EN-US style='font-family:Tahoma'><span style='mso-tab-count:1'> </span></span><spanlang=EN-US><span style='mso-tab-count:1'> </span>/*</span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>刷新窗口缓冲,显示</span> <span lang=EN-US>box <spanstyle='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>*/</span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>returnlocal_win;<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>}<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'><o:p> </o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>void destroy_win(WINDOW *local_win)<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span lang=EN-USstyle='font-family:Tahoma'>{<span style='mso-tab-count:1'> </span><o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US>/* box(local_win, ' ', ' '); </span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>:不会按照预期的那样清除窗口。他只会留下四个窗口角落的在残余字符。</span><span lang=EN-US>*/</span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span></span><bstyle='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:Tahoma'>wborder(local_win,' ', ' ', ' ',' ',' ',' ',' ',' ');<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span>/*</span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>参数注解</span><span lang=EN-US>9.3</span><spanstyle='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>:</span><span lang=EN-US> </span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>* 1. win:</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>当前操作的窗口</span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>* 2. ls:</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>用于显示窗口左边界的字符</span><spanlang=EN-US> </span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>* 3. rs:</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>用于显示窗口右边界的字符</span><spanlang=EN-US> </span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>* 4. ts:</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>用于显示窗口上边界的字符</span><spanlang=EN-US> </span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><spanstyle='mso-spacerun:yes'> </span>* 5. bs:</span><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>用于显示窗口下边界的字符</span><spanlang=EN-US> </span></p><p class=MsoNormal><span lang=EN-US><span style='mso-tab-count:1'> </span><span
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -