mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
134 lines
7.0 KiB
HTML
134 lines
7.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Define a color pair</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.ncurses-init-pair" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">ncurses_init_pair</h1>
|
|
<p class="verinfo">(PHP 4 >= 4.0.7, PHP 5 < 5.3.0, PECL ncurses >= 1.0.0)</p><p class="refpurpose"><span class="refname">ncurses_init_pair</span> — <span class="dc-title">Define a color pair</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.ncurses-init-pair-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>ncurses_init_pair</strong></span>
|
|
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$pair</code></span>
|
|
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$fg</code></span>
|
|
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$bg</code></span>
|
|
) : <span class="type">int</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Defines or redefines the given color pair to have the given foreground
|
|
and background colors. If the color pair was previously initialized,
|
|
the screen is refreshed and all occurrences of it are changed to reflect
|
|
the new definition.
|
|
</p>
|
|
<p class="para">
|
|
Color capabilities must be initialized using
|
|
<span class="function"><a href="ncurses_start_color.html" class="function">ncurses_start_color()</a></span> before calling this function.
|
|
The first color pair (color pair <em>0</em>) is assumed to
|
|
be white on black by default, but can be changed using
|
|
<span class="function"><a href="ncurses_assume_default_colors.html" class="function">ncurses_assume_default_colors()</a></span>.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.ncurses-init-pair-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">pair</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The number of the color pair to define.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">fg</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The foreground color for the color pair. May be one of the
|
|
<a href="ncurses.colorconsts.html" class="link">pre-defined colors</a>
|
|
or one defined by <span class="function"><a href="ncurses_init_color.html" class="function">ncurses_init_color()</a></span> if
|
|
the terminal has color changing capabilities.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">bg</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The background color for the color pair. May be one of the
|
|
<a href="ncurses.colorconsts.html" class="link">pre-defined colors</a>
|
|
or one defined by <span class="function"><a href="ncurses_init_color.html" class="function">ncurses_init_color()</a></span> if
|
|
the terminal has color changing capabilities.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.ncurses-init-pair-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns <em>-1</em> if the function was successful, and
|
|
<em>0</em> if ncurses or color support were not initialized.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 notes" id="refsect1-function.ncurses-init-pair-notes">
|
|
<h3 class="title">注释</h3>
|
|
<p class="para">
|
|
Note that color changing capabilities are not required for
|
|
defining color pairs of pre-existing colors, but only for changing
|
|
definitions (red, green, and blue components)
|
|
of colors themselves per <span class="function"><a href="ncurses_init_color.html" class="function">ncurses_init_color()</a></span>.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.ncurses-init-pair-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-682">
|
|
<p><strong>Example #1 Writing a string with a specified color to the screen</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />ncurses_init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// If the terminal supports colors, initialize and set active color<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">ncurses_has_colors</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">ncurses_start_color</span><span style="color: #007700">();<br /> </span><span style="color: #0000BB">ncurses_init_pair</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">NCURSES_COLOR_YELLOW</span><span style="color: #007700">, </span><span style="color: #0000BB">NCURSES_COLOR_BLUE</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">ncurses_color_set</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Write a string at specified location<br /></span><span style="color: #0000BB">ncurses_mvaddstr</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #DD0000">"Hello world! Yellow on blue text!"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Flush output to screen<br /></span><span style="color: #0000BB">ncurses_refresh</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">ncurses_end</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.ncurses-init-pair-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="ncurses_pair_content.html" class="function" rel="rdfs-seeAlso">ncurses_pair_content()</a> - Retrieves foreground and background colors of a color pair</span></li>
|
|
<li class="member"><span class="function"><a href="ncurses_start_color.html" class="function" rel="rdfs-seeAlso">ncurses_start_color()</a> - Initializes color functionality</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |