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

📄 ncurses-intro.html

📁 ncurses-5.4 需要的就来下把 一定会有用的哦
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN"><!--  $Id: ncurses-intro.html,v 1.39 2003/10/25 16:19:24 tom Exp $--><HTML><HEAD><TITLE>Writing Programs with NCURSES</TITLE><link rev="made" href="mailto:bugs-ncurses@gnu.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD><BODY><H1>Writing Programs with NCURSES</H1><BLOCKQUOTE>by Eric S. Raymond and Zeyd M. Ben-Halim<BR>updates since release 1.9.9e by Thomas Dickey</BLOCKQUOTE><H1>Contents</H1><UL><LI><A HREF="#introduction">Introduction</A><UL><LI><A HREF="#history">A Brief History of Curses</A><LI><A HREF="#scope">Scope of This Document</A><LI><A HREF="#terminology">Terminology</A></UL><LI><A HREF="#curses">The Curses Library</A><UL><LI><A HREF="#overview">An Overview of Curses</A><UL><LI><A HREF="#compiling">Compiling Programs using Curses</A><LI><A HREF="#updating">Updating the Screen</A><LI><A HREF="#stdscr">Standard Windows and Function Naming Conventions</A><LI><A HREF="#variables">Variables</A></UL><LI><A HREF="#using">Using the Library</A><UL><LI><A HREF="#starting">Starting up</A><LI><A HREF="#output">Output</A><LI><A HREF="#input">Input</A><LI><A HREF="#formschars">Using Forms Characters</A><LI><A HREF="#attributes">Character Attributes and Color</A><LI><A HREF="#mouse">Mouse Interfacing</A><LI><A HREF="#finishing">Finishing Up</A></UL><LI><A HREF="#functions">Function Descriptions</A><UL><LI><A HREF="#init">Initialization and Wrapup</A><LI><A HREF="#flush">Causing Output to the Terminal</A><LI><A HREF="#lowlevel">Low-Level Capability Access</A><LI><A HREF="#debugging">Debugging</A></UL><LI><A HREF="#hints">Hints, Tips, and Tricks</A><UL><LI><A HREF="#caution">Some Notes of Caution</A><LI><A HREF="#leaving">Temporarily Leaving ncurses Mode</A><LI><A HREF="#xterm">Using <CODE>ncurses</CODE> under <CODE>xterm</CODE></A><LI><A HREF="#screens">Handling Multiple Terminal Screens</A><LI><A HREF="#testing">Testing for Terminal Capabilities</A><LI><A HREF="#tuning">Tuning for Speed</A><LI><A HREF="#special">Special Features of <CODE>ncurses</CODE></A></UL><LI><A HREF="#compat">Compatibility with Older Versions</A><UL><LI><A HREF="#refbug">Refresh of Overlapping Windows</A><LI><A HREF="#backbug">Background Erase</A></UL><LI><A HREF="#xsifuncs">XSI Curses Conformance</A></UL><LI><A HREF="#panels">The Panels Library</A><UL><LI><A HREF="#pcompile">Compiling With the Panels Library</A><LI><A HREF="#poverview">Overview of Panels</A><LI><A HREF="#pstdscr">Panels, Input, and the Standard Screen</A><LI><A HREF="#hiding">Hiding Panels</A><LI><A HREF="#pmisc">Miscellaneous Other Facilities</A></UL><LI><A HREF="#menu">The Menu Library</A><UL><LI><A HREF="#mcompile">Compiling with the menu Library</A><LI><A HREF="#moverview">Overview of Menus</A><LI><A HREF="#mselect">Selecting items</A><LI><A HREF="#mdisplay">Menu Display</A><LI><A HREF="#mwindows">Menu Windows</A><LI><A HREF="#minput">Processing Menu Input</A><LI><A HREF="#mmisc">Miscellaneous Other Features</A></UL><LI><A HREF="#form">The Forms Library</A><UL><LI><A HREF="#fcompile">Compiling with the forms Library</A><LI><A HREF="#foverview">Overview of Forms</A><LI><A HREF="#fcreate">Creating and Freeing Fields and Forms</A><LI><A HREF="#fattributes">Fetching and Changing Field Attributes</A><UL><LI><A HREF="#fsizes">Fetching Size and Location Data</A><LI><A HREF="#flocation">Changing the Field Location</A><LI><A HREF="#fjust">The Justification Attribute</A><LI><A HREF="#fdispatts">Field Display Attributes</A><LI><A HREF="#foptions">Field Option Bits</A><LI><A HREF="#fstatus">Field Status</A><LI><A HREF="#fuser">Field User Pointer</A></UL><LI><A HREF="#fdynamic">Variable-Sized Fields</A><LI><A HREF="#fvalidation">Field Validation</A><UL><LI><A HREF="#ftype_alpha">TYPE_ALPHA</A><LI><A HREF="#ftype_alnum">TYPE_ALNUM</A><LI><A HREF="#ftype_enum">TYPE_ENUM</A><LI><A HREF="#ftype_integer">TYPE_INTEGER</A><LI><A HREF="#ftype_numeric">TYPE_NUMERIC</A><LI><A HREF="#ftype_regexp">TYPE_REGEXP</A></UL><LI><A HREF="#fbuffer">Direct Field Buffer Manipulation</A><LI><A HREF="#formattrs">Attributes of Forms</A><LI><A HREF="#fdisplay">Control of Form Display</A><LI><A HREF="#fdriver">Input Processing in the Forms Driver</A><UL><LI><A HREF="#fpage">Page Navigation Requests</A><LI><A HREF="#ffield">Inter-Field Navigation Requests</A><LI><A HREF="#fifield">Intra-Field Navigation Requests</A><LI><A HREF="#fscroll">Scrolling Requests</A><LI><A HREF="#fedit">Field Editing Requests</A><LI><A HREF="#forder">Order Requests</A><LI><A HREF="#fappcmds">Application Commands</A></UL><LI><A HREF="#fhooks">Field Change Hooks</A><LI><A HREF="#ffocus">Field Change Commands</A><LI><A HREF="#frmoptions">Form Options</A><LI><A HREF="#fcustom">Custom Validation Types</A><UL><LI><A HREF="#flinktypes">Union Types</A><LI><A HREF="#fnewtypes">New Field Types</A><LI><A HREF="#fcheckargs">Validation Function Arguments</A><LI><A HREF="#fcustorder">Order Functions For Custom Types</A><LI><A HREF="#fcustprobs">Avoiding Problems</A></UL></UL></UL><HR><H1><A NAME="introduction">Introduction</A></H1>This document is an introduction to programming with <CODE>curses</CODE>. It isnot an exhaustive reference for the curses Application Programming Interface(API); that role is filled by the <CODE>curses</CODE> manual pages.  Rather, itis intended to help C programmers ease into using the package. <P>This document is aimed at C applications programmers not yet specificallyfamiliar with ncurses.  If you are already an experienced <CODE>curses</CODE>programmer, you should nevertheless read the sections on<A HREF="#mouse">Mouse Interfacing</A>, <A HREF="#debugging">Debugging</A>,<A HREF="#compat">Compatibility with Older Versions</A>,and <A HREF="#hints">Hints, Tips, and Tricks</A>.  These will bring you upto speed on the special features and quirks of the <CODE>ncurses</CODE>implementation.  If you are not so experienced, keep reading. <P>The <CODE>curses</CODE> package is a subroutine library forterminal-independent screen-painting and input-event handling whichpresents a high level screen model to the programmer, hiding differencesbetween terminal types and doing automatic optimization of output to changeone screen full of text into another.  <CODE>Curses</CODE> uses terminfo, whichis a database format that can describe the capabilities of thousands ofdifferent terminals. <P>The <CODE>curses</CODE> API may seem something of an archaism on UNIX desktopsincreasingly dominated by X, Motif, and Tcl/Tk.  Nevertheless, UNIX stillsupports tty lines and X supports <EM>xterm(1)</EM>; the <CODE>curses</CODE>API has the advantage of (a) back-portability to character-cell terminals,and (b) simplicity.  For an application that does not require bit-mappedgraphics and multiple fonts, an interface implementation using <CODE>curses</CODE>will typically be a great deal simpler and less expensive than one using anX toolkit.<H2><A NAME="history">A Brief History of Curses</A></H2>Historically, the first ancestor of <CODE>curses</CODE> was the routines written toprovide screen-handling for the game <CODE>rogue</CODE>; these used thealready-existing <CODE>termcap</CODE> database facility for describing terminalcapabilities.  These routines were abstracted into a documented library andfirst released with the early BSD UNIX versions. <P>System III UNIX from Bell Labs featured a rewritten and much-improved<CODE>curses</CODE> library.  It introduced the terminfo format.  Terminfo is basedon Berkeley's termcap database, but contains a number of improvements andextensions. Parameterized capabilities strings were introduced, making itpossible to describe multiple video attributes, and colors and to handle farmore unusual terminals than possible with termcap.  In the later AT&amp;TSystem V releases, <CODE>curses</CODE> evolved to use more facilities and offermore capabilities, going far beyond BSD curses in power and flexibility.<H2><A NAME="scope">Scope of This Document</A></H2>This document describes <CODE>ncurses</CODE>, a free implementation ofthe System V <CODE>curses</CODE> API with some clearly marked extensions.It includes the following System V curses features:<UL><LI>Support for multiple screen highlights (BSD curses could onlyhandle one `standout' highlight, usually reverse-video).<LI>Support for line- and box-drawing using forms characters.<LI>Recognition of function keys on input.<LI>Color support.<LI>Support for pads (windows of larger than screen size on which thescreen or a subwindow defines a viewport).</UL>Also, this package makes use of the insert and delete line and characterfeatures of terminals so equipped, and determines how to optimally use thesefeatures with no help from the programmer.  It allows arbitrary combinations ofvideo attributes to be displayed, even on terminals that leave ``magiccookies'' on the screen to mark changes in attributes. <P>The <CODE>ncurses</CODE> package can also capture and use event reports from amouse in some environments (notably, xterm under the X window system).  Thisdocument includes tips for using the mouse. <P>The <CODE>ncurses</CODE> package was originated by Pavel Curtis.  The originalmaintainer of this package is<A HREF="mailto:zmbenhal@netcom.com">Zeyd Ben-Halim</A>&lt;zmbenhal@netcom.com&gt;.<A HREF="mailto:esr@snark.thyrsus.com">Eric S. Raymond</A>&lt;esr@snark.thyrsus.com&gt;wrote many of the new features in versions after 1.8.1and wrote most of this introduction.J&uuml;rgen Pfeiferwrote all of the menu and forms code as well as the<A HREF="http://www.adahome.com">Ada95</A> binding.Ongoing work is being done by<A HREF="mailto:dickey@invisible-island.net">Thomas Dickey</A> (maintainer).Contact the current maintainers at<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.<P>This document also describes the <A HREF="#panels">panels</A> extension library,similarly modeled on the SVr4 panels facility.  This library allows you toassociate backing store with each of a stack or deck of overlapping windows,and provides operations for moving windows around in the stack that changetheir visibility in the natural way (handling window overlaps). <P>Finally, this document describes in detail the <A HREF="#menu">menus</A> and <AHREF="#form">forms</A> extension libraries, also cloned from System V,which support easy construction and sequences of menus and fill-informs.<H2><A NAME="terminology">Terminology</A></H2>In this document, the following terminology is used with reasonableconsistency:<DL><DT> window<DD>A data structure describing a sub-rectangle of the screen (possibly theentire screen).  You can write to a window as though it were a miniaturescreen, scrolling independently of other windows on the physical screen.<DT> screens<DD>A subset of windows which are as large as the terminal screen, i.e., they startat the upper left hand corner and encompass the lower right hand corner.  Oneof these, <CODE>stdscr</CODE>, is automatically provided for the programmer.<DT> terminal screen<DD>The package's idea of what the terminal display currently looks like, i.e.,what the user sees now.  This is a special screen.</DL><H1><A NAME="curses">The Curses Library</A></H1><H2><A NAME="overview">An Overview of Curses</A></H2><H3><A NAME="compiling">Compiling Programs using Curses</A></H3>In order to use the library, it is necessary to have certain types andvariables defined.  Therefore, the programmer must have a line:<PRE>	  #include &lt;curses.h&gt;</PRE>

⌨️ 快捷键说明

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