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

📄 ch22_02.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<em class="replaceable"><tt>attr</tt></em>.</p><p>Optionally, you can specify a clipping region with<em class="replaceable"><tt>cleft</em>, <em class="replaceable">ctop</tt></em>,<em class="replaceable"><tt>cright</tt></em>, and<em class="replaceable"><tt>cbottom</tt></em> so that the contents of theconsole outside this rectangle are unchanged. Returns<tt class="literal">undef</tt> on error or a nonzero value on success.</p><blockquote><pre class="code"># Scrolls the screen 10 lines down, filling with black spaces$CONSOLE-&gt;Scroll(0, 0, 80, 25, 0, 10, " ", $FG_BLACK | $BG_BLACK);</pre></blockquote></div><a name="INDEX-3200" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Select</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;Select(<em class="replaceable">standard_handle</em>)</pre><p><a name="INDEX-3200" />Redirects a standard handleto the specified console. <em class="replaceable"><tt>standard_handle</tt></em>can have one of the following values:</p><blockquote><pre class="code">STD_INPUT_HANDLESTD_OUTPUT_HANDLESTD_ERROR_HANDLE</pre></blockquote><p>Returns <tt class="literal">undef</tt> on error or a nonzero value onsuccess.</p></div><a name="INDEX-3201" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Size</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;Size([<em class="replaceable">col</em>, <em class="replaceable">row</em>])</pre><p><a name="INDEX-3201" />Gets or sets the console buffer size.</p></div><a name="INDEX-3202" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Title</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;Title([<em class="replaceable">title</em>])</pre><p><a name="INDEX-3202" />Gets or sets the title barstring of the current console window.</p></div><a name="INDEX-3203" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Window</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;Window([<em class="replaceable">flag</em>, <em class="replaceable">left</em>, <em class="replaceable">top</em>, <em class="replaceable">right</em>, <em class="replaceable">bottom</em>])</pre><p><a name="INDEX-3203" />Gets or sets the currentconsole window size. If called without arguments, returns afour-element list containing the current window coordinates in theform of (<em class="replaceable"><tt>left</tt></em>,<em class="replaceable"><tt>top</em>, <em class="replaceable">right</tt></em>,<em class="replaceable"><tt>bottom</tt></em>). To set the window size, you haveto specify an additional flag parameter. If it is<tt class="literal">0</tt>, coordinates are considered relative to thecurrent coordinates; if it is nonzero, coordinates are absolute.</p></div><a name="INDEX-3204" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Write</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;Write(<em class="replaceable">string</em>)</pre><p><a name="INDEX-3204" />Writes <em class="replaceable">string</em>on the console, using the current attribute, which you can set with<tt class="literal">Attr</tt>, and advances the cursor as needed. Thisisn't that different from Perl's<tt class="literal">print</tt> statement. Returns the number of characterswritten, or <tt class="literal">undef</tt> on error.</p></div><a name="INDEX-3205" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>WriteAttr</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;WriteAttr(<em class="replaceable">attrs</em>, <em class="replaceable">col</em>, <em class="replaceable">row</em>)</pre><p><a name="INDEX-3205" />Writes the attributescontained in the string <tt class="sgmltag-element">&lt;attrs&gt;</tt>, beginning at<em class="replaceable"><tt>col</em>, <em class="replaceable">row</tt></em>,without affecting the characters that are on screen. The string<em class="replaceable"><tt>attrs</tt></em> can be the result of a<tt class="literal">ReadAttr</tt> function, or you can build your ownattribute string; in this case, keep in mind that every attribute istreated as a character, not a number (see example). Returns thenumber of attributes written, or <tt class="literal">undef</tt> on error.</p><blockquote><pre class="code">$CONSOLE-&gt;WriteAttr($attrs, 0, 0);# note the use of chr( )...$attrs = chr($FG_BLACK | $BG_WHITE) x 80; $CONSOLE-&gt;WriteAttr($attrs, 0, 0);</pre></blockquote></div><a name="INDEX-3206" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>WriteChar</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;WriteChar(<em class="replaceable">chars</em>, <em class="replaceable">col</em>, <em class="replaceable">row</em>)</pre><p><a name="INDEX-3206" />Writes the characters in thestring <em class="replaceable"><tt>attr</tt></em>, beginning at<em class="replaceable"><tt>col</em>, <em class="replaceable">row</tt></em>,without affecting the attributes that are onscreen. The stringcharacters can be the result of a <tt class="literal">ReadChar</tt>function or a normal string. Returns the number of characterswritten, or <tt class="literal">undef</tt> on error.</p></div><a name="INDEX-3207" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>WriteInput</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;WriteInput(<em class="replaceable">event</em>)</pre><p><a name="INDEX-3207" />Pushes data in the consoleinput buffer. <em class="replaceable"><tt>event</tt></em> is a list of values(for more information, see <tt class="literal">Input</tt>). The stringcharacters can be the result of a <tt class="literal">ReadChar</tt>function or a normal string. Returns the number of characterswritten, or <tt class="literal">undef</tt> on error.</p></div><a name="INDEX-3208" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>WriteRect</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>$<em class="replaceable">cons</em>-&gt;WriteRect(<em class="replaceable">rect</em>, <em class="replaceable">left</em>, <em class="replaceable">top</em>, <em class="replaceable">right</em>, <em class="replaceable">bottom</em>)</pre><p><a name="INDEX-3208" />Writes a rectangle ofcharacters and attributes (contained in<em class="replaceable"><tt>rect</tt></em>) on the console at the coordinatesspecified by <em class="replaceable"><tt>left</tt></em>,<em class="replaceable"><tt>top</em>, <em class="replaceable">right</tt></em>, and<em class="replaceable"><tt>bottom</em>. <em class="replaceable">rect</tt></em>can be the result of a <tt class="literal">ReadRect</tt> function. Returns<tt class="literal">undef</tt> on error; otherwise, returns a four-elementlist containing the coordinates of the affected rectangle, in theformat (<em class="replaceable"><tt>left</tt></em>,<em class="replaceable"><tt>top</em>, <em class="replaceable">right</tt></em>,<em class="replaceable"><tt>bottom</tt></em>).</p></div><a name="perlnut2-CHP-22-SECT-2.1" /><div class="sect2"><h3 class="sect2">22.2.1. Constants</h3><p>The following constants are exported in the main namespace of yourscript using Win32::Console:</p><blockquote><pre class="code">BACKGROUND_BLUE                 BACKGROUND_GREENBACKGROUND_INTENSITY            BACKGROUND_REDCAPSLOCK_ON                     CONSOLE_TEXTMODE_BUFFER    ENABLE_ECHO_INPUT               ENABLE_LINE_INPUTENABLE_MOUSE_INPUT              ENABLE_PROCESSED_INPUTENABLE_PROCESSED_OUTPUT         ENABLE_WINDOW_INPUTENABLE_WRAP_AT_EOL_OUTPUT       ENHANCED_KEYFILE_SHARE_READ                 FILE_SHARE_WRITEFOREGROUND_BLUE                 FOREGROUND_GREENFOREGROUND_INTENSITY            FOREGROUND_REDLEFT_ALT_PRESSED                LEFT_CTRL_PRESSEDNUMLOCK_ON                      GENERIC_READGENERIC_WRITE                   RIGHT_ALT_PRESSEDRIGHT_CTRL_PRESSED              SCROLLLOCK_ONSHIFT_PRESSED                   STD_INPUT_HANDLESTD_OUTPUT_HANDLE               STD_ERROR_HANDLE</pre></blockquote><p>Additionally, the following variables can be used: </p><blockquote><pre class="code">$FG_BLACK                       $FG_BLUE$FG_LIGHTBLUE                   $FG_RED$FG_LIGHTRED                    $FG_GREEN$FG_LIGHTGREEN                  $FG_MAGENTA$FG_LIGHTMAGENTA                $FG_CYAN$FG_LIGHTCYAN                   $FG_BROWN$FG_YELLOW                      $FG_GRAY$FG_WHITE                       $BG_BLACK$BG_BLUE                        $BG_LIGHTBLUE$BG_RED                         $BG_LIGHTRED$BG_GREEN                       $BG_LIGHTGREEN$BG_MAGENTA                     $BG_LIGHTMAGENTA$BG_CYAN                        $BG_LIGHTCYAN$BG_BROWN                       $BG_YELLOW$BG_GRAY                        $BG_WHITE$ATTR_NORMAL                    $ATTR_INVERSE</pre></blockquote><p><tt class="literal">ATTR_NORMAL</tt> is set to gray foreground on blackbackground (DOS's standard colors). <a name="INDEX-3209" /><a name="INDEX-3210" /></p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch22_01.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch22_03.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">22. Win32 Modules and Extensions</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">22.3. Win32::ChangeNotify</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

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