<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-ncurses" role="wrap">
  <?dbhtml filename="ncurses.html"?>

  <sect1info condition="script">
    <productname>ncurses</productname>
    <productnumber>&ncurses-version;</productnumber>
    <address>&ncurses-url;</address>
  </sect1info>

  <title>Ncurses-&ncurses-version;</title>

  <indexterm zone="ch-system-ncurses">
    <primary sortas="a-Ncurses">Ncurses</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

    <para>Ncurses 软件包包含终端无关的字符屏幕处理库。</para>

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&ncurses-ch6-sbu;</seg>
        <seg>&ncurses-ch6-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

  <sect2 role="installation">
    <title>安装 Ncurses</title>

	<para>输入以下命令，使构建系统不安装一个 configure 脚本未处理的静态库：
	</para>

<screen><userinput remap="pre">sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in</userinput></screen>

    <para>准备安装 Ncurses：</para>

<screen><userinput remap="configure">./configure --prefix=/usr           \
            --mandir=/usr/share/man \
            --with-shared           \
            --without-debug         \
            --without-normal        \
            --enable-pc-files       \
            --enable-widec</userinput></screen>

    <variablelist>
      <title>新的配置选项的含义：</title>

      <varlistentry>
        <term><parameter>--enable-widec</parameter></term>
        <listitem>
          <!--para>This switch causes wide-character libraries (e.g., <filename
          class="libraryfile">libncursesw.so.&ncurses-version;</filename>)
          to be built instead of normal ones (e.g., <filename
          class="libraryfile">libncurses.so.&ncurses-version;</filename>).
          These wide-character libraries are usable in both multibyte and
          traditional 8-bit locales, while normal libraries work properly
          only in 8-bit locales. Wide-character and normal libraries are
          source-compatible, but not binary-compatible.</para-->
	      <para os="widec">该选项使得宽字符库（例如
<filename class="libraryfile">libncursesw.so.&ncurses-version;</filename> ）
被构建，而不构建常规字符库（例如
<filename class="libraryfile">libncurses.so.&ncurses-version;</filename>）。
宽字符库在多字节和传统 8 位 locale 中都能工作，
而常规字符库只能在 8 位 locale 中工作。
宽字符库和普通字符库在源码层面是兼容的，但二进制不兼容。</para>

        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--enable-pc-files</parameter></term>
        <listitem>
          <para>该参数使得构建系统生成并安装 pkg-config 使用的 .pc 文件。
          </para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--without-normal</parameter></term>
        <listitem>
          <para>该选项禁止构建系统编译并安装多数静态库。
          </para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>编译该软件包：</para>

<screen><userinput remap="make">make</userinput></screen>

    <!--para>This package has a test suite, but it can only be run after the
    package has been installed.  The tests reside in the
    <filename class="directory">test/</filename> directory.  See the
    <filename>README</filename> file in that directory for further details.
    </para-->
	<para>该软件包有测试套件，但只能在安装该软件包后才能运行。
		测试用例位于 <filename class="directory">test/</filename> 中，
		阅读其中的 <filename>README</filename> 文件了解更多细节。</para>

    <para>安装该软件包：</para>

<screen><userinput remap="install">make install</userinput></screen>

    <para>将共享库移动到期望的
    <filename class="directory">/lib</filename> 目录：</para>

<screen><userinput remap="install">mv -v /usr/lib/libncursesw.so.6* /lib</userinput></screen>

    <para>由于共享库被移走了，一个符号链接指向了不存在的文件。
    重新创建它：</para>

<screen><userinput remap="install">ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so</userinput></screen>

    <!--para>Many applications still expect the linker to be able to find
    non-wide-character Ncurses libraries. Trick such applications into linking with
    wide-character libraries by means of symlinks and linker scripts:</para-->
    <para>许多程序仍然希望链接器能够找到非宽字符版本的 Ncurses 库。
		通过使用符号链接和链接脚本，诱导它们链接到宽字符库：</para>

<screen><userinput remap="install">for lib in ncurses form panel menu ; do
    rm -vf                    /usr/lib/lib${lib}.so
    echo "INPUT(-l${lib}w)" &gt; /usr/lib/lib${lib}.so
    ln -sfv ${lib}w.pc        /usr/lib/pkgconfig/${lib}.pc
done</userinput></screen>

    <para>最后，确保那些在构建时寻找
	<filename class="libraryfile">-lcurses</filename>
    的老式程序仍然能够构建：</para>

<screen><userinput remap="install">rm -vf                     /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" &gt; /usr/lib/libcursesw.so
ln -sfv libncurses.so      /usr/lib/libcurses.so</userinput></screen>

    <para>如果需要的话，安装 Ncurses 文档：</para>

<screen><userinput remap="install">mkdir -v       /usr/share/doc/ncurses-&ncurses-version;
cp -v -R doc/* /usr/share/doc/ncurses-&ncurses-version;</userinput></screen>

    <note>

      <!--para>The instructions above don't create non-wide-character Ncurses
      libraries since no package installed by compiling from sources would link
      against them at runtime. However, the only known binary-only
      applications that link against non-wide-character Ncurses libraries 
      require version 5.  If you must have such libraries because of some binary-only
      application or to be compliant with LSB, build the package again with the
      following commands:</para-->
      <para>上述指令没有创建非宽字符的 Ncurses 库，
		  因为从源码编译的软件包不会在运行时链接到它。
		  然而，已知的需要链接到非宽字符 Ncurses 库的二进制程序都需要版本
		  5，如果您为了满足一些仅有二进制版本的程序，或者满足 LSB 兼容性，
		  必须安装这样的库，执行以下命令再次构建该软件包：</para>

<screen role="nodump"><userinput>make distclean
./configure --prefix=/usr    \
            --with-shared    \
            --without-normal \
            --without-debug  \
            --without-cxx-binding \
            --with-abi-version=5 
make sources libs
cp -av lib/lib*.so.5* /usr/lib</userinput></screen>
    </note>

  </sect2>

  <sect2 id="contents-ncurses" role="content">
    <title>Ncurses 的内容</title>

    <segmentedlist>
      <segtitle>安装的程序</segtitle>
      <segtitle>安装的库</segtitle>
      <segtitle>安装的目录</segtitle>

      <seglistitem>
        <seg>
           captoinfo (链接到 tic), 
           clear, 
           infocmp, 
           infotocap (链接到 tic),
           ncursesw6-config, 
           reset (链接到 tset), 
           tabs, 
           tic, 
           toe, 
           tput, 以及
           tset
        </seg>
        <seg>
           libcursesw.so (指向 libncursesw.so 的符号链接和链接脚本),
           libformw.so, 
           libmenuw.so, 
           libncursesw.so,
           libncurses++w.a,
		   libpanelw.so, 以及它们的库名称没有 <quote>w</quote>
		   的非宽字符替代品</seg>
        <seg>
           /usr/share/tabset, 
           /usr/share/terminfo, 以及
           /usr/share/doc/ncurses-&ncurses-version;
        </seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">简要描述</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="captoinfo">
        <term><command>captoinfo</command></term>
        <listitem>
          <para>将 termcap 描述转换成 terminfo 描述</para>
          <indexterm zone="ch-system-ncurses captoinfo">
            <primary sortas="b-captoinfo">captoinfo</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="clear">
        <term><command>clear</command></term>
        <listitem>
          <para>如果可能的话，清空屏幕</para>
          <indexterm zone="ch-system-ncurses clear">
            <primary sortas="b-clear">clear</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="infocmp">
        <term><command>infocmp</command></term>
        <listitem>
          <para>比较或输出 terminfo 描述</para>
          <indexterm zone="ch-system-ncurses infocmp">
            <primary sortas="b-infocmp">infocmp</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="infotocap">
        <term><command>infotocap</command></term>
        <listitem>
          <para>将 terminfo 描述转化为 termcap 描述</para>
          <indexterm zone="ch-system-ncurses infotocap">
            <primary sortas="b-infotocap">infotocap</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="ncursesw6-config">
        <term><command>ncursesw6-config</command></term>
        <listitem>
          <para>提供 ncurses 的配置信息</para>
          <indexterm zone="ch-system-ncurses ncursesw6-config">
            <primary sortas="b-ncursesw6-config">ncursesw6-config</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="reset">
        <term><command>reset</command></term>
        <listitem>
          <para>以终端默认值重新初始化终端</para>
          <indexterm zone="ch-system-ncurses reset">
            <primary sortas="b-reset">reset</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="tabs">
        <term><command>tabs</command></term>
        <listitem>
          <para>清除并设置终端的 tab 宽度</para>
          <indexterm zone="ch-system-ncurses tabs">
            <primary sortas="b-tabs">tabs</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="tic">
        <term><command>tic</command></term>
        <listitem>
          <!--para>The terminfo entry-description compiler that translates a
          terminfo file from source format into the binary format needed for the
          ncurses library routines [A terminfo file contains information on the
          capabilities of a certain terminal.]</para-->
	      <para>Terminfo 条目描述编译器，将 terminfo
			  文件从源代码格式翻译为 ncurses 库子程序需要的二进制格式
			  [terminfo 文件包含特定终端的功能信息。]</para>
          <indexterm zone="ch-system-ncurses tic">
            <primary sortas="b-tic">tic</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="toe">
        <term><command>toe</command></term>
        <listitem>
          <para>列出所有可用的终端类型，并给出每种类型的主要名称和描述
          </para>
          <indexterm zone="ch-system-ncurses toe">
            <primary sortas="b-toe">toe</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="tput">
        <term><command>tput</command></term>
        <listitem>
          <para>使 shell 可以使用终端相关的功能；也可以重置或初始化终端，
          或者报告它的长名称</para>
          <indexterm zone="ch-system-ncurses tput">
            <primary sortas="b-tput">tput</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="tset">
        <term><command>tset</command></term>
        <listitem>
          <para>可以被用于初始化终端</para>
          <indexterm zone="ch-system-ncurses tset">
            <primary sortas="b-tset">tset</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libcursesw">
        <term><filename class="libraryfile">libcursesw</filename></term>
        <listitem>
          <para>指向 <filename>libncursesw</filename> 的链接</para>
          <indexterm zone="ch-system-ncurses libcursesw">
            <primary sortas="c-libcursesw">libcursesw</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libncursesw">
        <term><filename class="libraryfile">libncursesw</filename></term>
        <listitem>
          <!--para>Contains functions to display text in many complex ways on a
          terminal screen; a good example of the use of these functions is the
          menu displayed during the kernel's <command>make
          menuconfig</command></para-->
          <para>包含在终端屏幕上以多种复杂方式显示文本的函数；
			  使用这些函数的典型例子是运行内核的
			  <command>make menuconfig</command> 时显示的目录。</para>
          <indexterm zone="ch-system-ncurses libncursesw">
            <primary sortas="c-libncursesw">libncursesw</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libformw">
        <term><filename class="libraryfile">libformw</filename></term>
        <listitem>
          <para>包含实现表单的函数</para>
          <indexterm zone="ch-system-ncurses libformw">
            <primary sortas="c-libformw">libformw</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libmenuw">
        <term><filename class="libraryfile">libmenuw</filename></term>
        <listitem>
          <para>包含实现目录的函数</para>
          <indexterm zone="ch-system-ncurses libmenuw">
            <primary sortas="c-libmenuw">libmenuw</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libpanelw">
        <term><filename class="libraryfile">libpanelw</filename></term>
        <listitem>
          <para>包含实现面板的函数</para>
          <indexterm zone="ch-system-ncurses libpanelw">
            <primary sortas="c-libpanelw">libpanelw</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>
