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

📄 ch22_02.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<p>Current row (Y position) of the cursor</p></li><li><p>Current attribute used for <tt class="literal">Write</tt></p></li><li><p>Left column (X of the starting point) of the current console window</p></li><li><p>Top row (Y of the starting point) of the current console window</p></li><li><p>Right column (X of the final point) of the current console window</p></li><li><p>Bottom row (Y of the final point) of the current console window</p></li><li><p>Maximum number of columns for the console window, given the currentbuffer size, font, and screen size</p></li><li><p>Maximum number of rows for the console window, given the currentbuffer size, font, and screen size</p></li></ul><p>This example prints the cursor's current position: </p><blockquote><pre class="code">@info = $CONSOLE-&gt;Info( );print "Cursor at $info[3], $info[4].0";</pre></blockquote></div><a name="INDEX-3188" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Input</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;Input</pre><p><a name="INDEX-3188" />Reads an event from the inputbuffer. Returns a list of values, determined by the type of event. Akeyboard event will contain the following values, in order:</p><ul><li><p>Event type (<tt class="literal">1</tt> for keyboard)</p></li><li><p>Key state&#x2014;true if the key is being pressed, false if the key isbeing released</p></li><li><p>Repeat count&#x2014;the number of times the key is held down</p></li><li><p>Virtual keycode of the key</p></li><li><p>Virtual scancode of the key</p></li><li><p>ASCII code of the character (if the key is a character key,<tt class="literal">0</tt> otherwise)</p></li><li><p>State of the control keys (Shifts, Ctrls, Alts, etc.)</p></li></ul><p>A mouse event will return the following values, in order:</p><ul><li><p>Event type (<tt class="literal">2</tt> for mouse)</p></li><li><p>X coordinate (column) of the mouse location</p></li><li><p>Y coordinate (row) of the mouse location</p></li><li><p>Button state&#x2014;the mouse button(s) that are pressed</p></li><li><p>State of the control keys (Shifts, Ctrls, Alts, etc.)</p></li><li><p>Event flags for the type of the mouse event</p></li></ul><p>This method will return <tt class="literal">undef</tt> on error.</p><p>Note that the events returned depend on the input mode of theconsole; for example, mouse events are not intercepted unless<tt class="literal">ENABLE_MOUSE_INPUT</tt> is specified.</p></div><a name="INDEX-3189" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>InputChar</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;InputChar(<em class="replaceable">number</em>)</pre><p><a name="INDEX-3189" />Reads and returns numbercharacters from the console input buffer, or returns<tt class="literal">undef</tt> on error.</p></div><a name="INDEX-3190" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>InputCP</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;InputCP([<em class="replaceable">codepage</em>])</pre><p><a name="INDEX-3190" />Gets or sets the input codepage used by the console. Note that this doesn'tapply to a console object, but to the standard input console. Thisattribute is used by the <tt class="literal">Write</tt> method.</p></div><a name="INDEX-3191" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>MaxWindow</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;MaxWindow</pre><p><a name="INDEX-3191" />Returns the size of thelargest possible console window, based on the current font and thesize of the display. The result is <tt class="literal">undef</tt> on error;otherwise, a two-element list containing the number of columns androws is returned.</p></div><a name="INDEX-3192" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Mode</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;Mode([<em class="replaceable">flags</em>])</pre><p><a name="INDEX-3192" />Gets or sets the input or output modeof a console. <em class="replaceable"><tt>flags</tt></em> can be a combinationof the following constants:</p><blockquote><pre class="code">ENABLE_LINE_INPUTENABLE_ECHO_INPUTENABLE_PROCESSED_INPUTENABLE_WINDOW_INPUTENABLE_MOUSE_INPUTENABLE_PROCESSED_OUTPUTENABLE_WRAP_AT_EOL_OUTPUT</pre></blockquote></div><a name="INDEX-3193" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>MouseButtons</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;MouseButtons</pre><p><a name="INDEX-3193" />Returns the number of thebuttons on your mouse, or <tt class="literal">undef</tt> on error.</p></div><a name="INDEX-3194" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>OutputCP</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;OutputCP([<em class="replaceable">codepage</em>])</pre><p><a name="INDEX-3194" />Gets or sets the output codepage used by the console. Note that this doesn'tapply to a console object, but to the standard output console. Youmay want to use the noninstantiated form to avoid confusion:</p><blockquote><pre class="code">$codepage = Win32::Console::OutputCP( );Win32::Console::OutputCP(437);</pre></blockquote></div><a name="INDEX-3195" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>PeekInput</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;PeekInput</pre><p><a name="INDEX-3195" />Does exactly the same as<tt class="literal">Input</tt>, except that the event read is not removedfrom the input buffer.</p></div><a name="INDEX-3196" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ReadAttr</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;ReadAttr([<em class="replaceable">number</em>, <em class="replaceable">col</em>, <em class="replaceable">row</em>])</pre><p><a name="INDEX-3196" />Reads the specified<em class="replaceable"><tt>number</tt></em> of consecutive attributes from theconsole, beginning at <em class="replaceable"><tt>col</tt></em>,<em class="replaceable"><tt>row</tt></em>. Returns the attributes read (avariable containing one character for each attribute), or<tt class="literal">undef</tt> on error. You can then pass the returnedvariable to <tt class="literal">WriteAttr</tt> to restore the savedattributes on screen.</p></div><a name="INDEX-3197" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ReadChar</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;ReadChar([<em class="replaceable">number</em>, <em class="replaceable">col</em>, <em class="replaceable">row</em>])</pre><p><a name="INDEX-3197" />Reads the specified<em class="replaceable"><tt>number</tt></em> of consecutive characters from theconsole, beginning at <em class="replaceable"><tt>col</tt></em>,<em class="replaceable"><tt>row</tt></em>. Returns a string containing thecharacters read, or <tt class="literal">undef</tt> on error. You can thenpass the returned variable to <tt class="literal">WriteChar</tt> to restorethe saved characters on screen.</p></div><a name="INDEX-3198" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ReadRect</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;ReadRect(<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-3198" />Reads the content (charactersand attributes) of the rectangle specified by<em class="replaceable"><tt>left</em>, <em class="replaceable">top</tt></em>,<em class="replaceable"><tt>right</tt></em>, and<em class="replaceable"><tt>bottom</tt></em> from the console. Returns a stringcontaining the rectangle read, or <tt class="literal">undef</tt> on error.You can then pass the returned variable to<tt class="literal">WriteRect</tt> to restore the saved rectangle on screen(or on another console).</p></div><a name="INDEX-3199" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Scroll</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;Scroll(<em class="replaceable">left</em>, <em class="replaceable">top</em>, <em class="replaceable">right</em>, <em class="replaceable">bottom</em>, <em class="replaceable">col</em>, <em class="replaceable">row</em>, <em class="replaceable">char</em>, <em class="replaceable">attr</em>, [<em class="replaceable">cleft</em>, <em class="replaceable">ctop</em>, <em class="replaceable">cright</em>, <em class="replaceable">cbottom</em>])</pre><p><a name="INDEX-3199" />Moves a block of data in aconsole buffer; the block is identified by the<em class="replaceable"><tt>left</em>, <em class="replaceable">top</tt></em>,<em class="replaceable"><tt>right</tt></em>, and<em class="replaceable"><tt>bottom</tt></em> positions.</p><p><em class="replaceable"><tt>row</em> and <em class="replaceable">col</tt></em>identify the new location of the block. The cells left empty as aresult of the move are filled with the character<em class="replaceable"><tt>char</tt></em> and attribute

⌨️ 快捷键说明

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