xref: /freebsd/contrib/ncurses/doc/hackguide.doc (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
17a69bbfbSPeter Wemm                          A Hacker's Guide to NCURSES
27a69bbfbSPeter Wemm
3*21817992SBaptiste DaroussinA Hacker's Guide to NCURSES
4*21817992SBaptiste Daroussin
57a69bbfbSPeter WemmContents
67a69bbfbSPeter Wemm
77a69bbfbSPeter Wemm     * Abstract
87a69bbfbSPeter Wemm     * Objective of the Package
97a69bbfbSPeter Wemm          + Why System V Curses?
107a69bbfbSPeter Wemm          + How to Design Extensions
117a69bbfbSPeter Wemm     * Portability and Configuration
127a69bbfbSPeter Wemm     * Documentation Conventions
137a69bbfbSPeter Wemm     * How to Report Bugs
147a69bbfbSPeter Wemm     * A Tour of the Ncurses Library
157a69bbfbSPeter Wemm          + Library Overview
167a69bbfbSPeter Wemm          + The Engine Room
177a69bbfbSPeter Wemm          + Keyboard Input
187a69bbfbSPeter Wemm          + Mouse Events
197a69bbfbSPeter Wemm          + Output and Screen Updating
207a69bbfbSPeter Wemm     * The Forms and Menu Libraries
217a69bbfbSPeter Wemm     * A Tour of the Terminfo Compiler
227a69bbfbSPeter Wemm          + Translation of Non-use Capabilities
237a69bbfbSPeter Wemm          + Use Capability Resolution
247a69bbfbSPeter Wemm          + Source-Form Translation
257a69bbfbSPeter Wemm     * Other Utilities
267a69bbfbSPeter Wemm     * Style Tips for Developers
277a69bbfbSPeter Wemm     * Porting Hints
287a69bbfbSPeter Wemm
297a69bbfbSPeter WemmAbstract
307a69bbfbSPeter Wemm
317a69bbfbSPeter Wemm   This document is a hacker's tour of the ncurses library and utilities.
327a69bbfbSPeter Wemm   It  discusses  design  philosophy,  implementation  methods,  and  the
337a69bbfbSPeter Wemm   conventions  used  for  coding  and  documentation.  It is recommended
347a69bbfbSPeter Wemm   reading  for  anyone  who  is  interested  in  porting,  extending  or
357a69bbfbSPeter Wemm   improving the package.
367a69bbfbSPeter Wemm
377a69bbfbSPeter WemmObjective of the Package
387a69bbfbSPeter Wemm
397a69bbfbSPeter Wemm   The objective of the ncurses package is to provide a free software API
407a69bbfbSPeter Wemm   for character-cell terminals and terminal emulators with the following
417a69bbfbSPeter Wemm   characteristics:
427a69bbfbSPeter Wemm     * Source-compatible    with    historical   curses   implementations
437a69bbfbSPeter Wemm       (including the original BSD curses and System V curses.
447a69bbfbSPeter Wemm     * Conformant  with the XSI Curses standard issued as part of XPG4 by
457a69bbfbSPeter Wemm       X/Open.
467a69bbfbSPeter Wemm     * High-quality  --  stable and reliable code, wide portability, good
477a69bbfbSPeter Wemm       packaging, superior documentation.
487a69bbfbSPeter Wemm     * Featureful  --  should  eliminate  as  much  of  the drudgery of C
497a69bbfbSPeter Wemm       interface programming as possible, freeing programmers to think at
507a69bbfbSPeter Wemm       a higher level of design.
517a69bbfbSPeter Wemm
527a69bbfbSPeter Wemm   These  objectives  are  in  priority  order.  So,  for example, source
537a69bbfbSPeter Wemm   compatibility  with  older  version  must  trump  featurefulness -- we
547a69bbfbSPeter Wemm   cannot  add  features  if  it  means  breaking  the portion of the API
557a69bbfbSPeter Wemm   corresponding to historical curses versions.
567a69bbfbSPeter Wemm
577a69bbfbSPeter Wemm  Why System V Curses?
587a69bbfbSPeter Wemm
597a69bbfbSPeter Wemm   We  used System V curses as a model, reverse-engineering their API, in
607a69bbfbSPeter Wemm   order to fulfill the first two objectives.
617a69bbfbSPeter Wemm
627a69bbfbSPeter Wemm   System  V  curses implementations can support BSD curses programs with
637a69bbfbSPeter Wemm   just a recompilation, so by capturing the System V API we also capture
647a69bbfbSPeter Wemm   BSD's.
657a69bbfbSPeter Wemm
667a69bbfbSPeter Wemm   More  importantly  for  the  future, the XSI Curses standard issued by
677a69bbfbSPeter Wemm   X/Open  is  explicitly and closely modeled on System V. So conformance
687a69bbfbSPeter Wemm   with System V took us most of the way to base-level XSI conformance.
697a69bbfbSPeter Wemm
707a69bbfbSPeter Wemm  How to Design Extensions
717a69bbfbSPeter Wemm
727a69bbfbSPeter Wemm   The  third  objective (standards conformance) requires that it be easy
737a69bbfbSPeter Wemm   to  condition  source  code  using  ncurses  so  that  the  absence of
747a69bbfbSPeter Wemm   nonstandard extensions does not break the code.
757a69bbfbSPeter Wemm
767a69bbfbSPeter Wemm   Accordingly,  we  have  a  policy of associating with each nonstandard
777a69bbfbSPeter Wemm   extension  a  feature  macro, so that ncurses client code can use this
787a69bbfbSPeter Wemm   macro  to  condition  in  or  out  the  code that requires the ncurses
797a69bbfbSPeter Wemm   extension.
807a69bbfbSPeter Wemm
817a69bbfbSPeter Wemm   For  example,  there is a macro NCURSES_MOUSE_VERSION which XSI Curses
827a69bbfbSPeter Wemm   does  not  define, but which is defined in the ncurses library header.
837a69bbfbSPeter Wemm   You can use this to condition the calls to the mouse API calls.
847a69bbfbSPeter Wemm
857a69bbfbSPeter WemmPortability and Configuration
867a69bbfbSPeter Wemm
877a69bbfbSPeter Wemm   Code  written  for  ncurses may assume an ANSI-standard C compiler and
887a69bbfbSPeter Wemm   POSIX-compatible  OS  interface.  It may also assume the presence of a
897a69bbfbSPeter Wemm   System-V-compatible select(2) call.
907a69bbfbSPeter Wemm
917a69bbfbSPeter Wemm   We encourage (but do not require) developers to make the code friendly
927a69bbfbSPeter Wemm   to less-capable UNIX environments wherever possible.
937a69bbfbSPeter Wemm
947a69bbfbSPeter Wemm   We  encourage  developers  to  support  OS-specific  optimizations and
957a69bbfbSPeter Wemm   methods not available under POSIX/ANSI, provided only that:
967a69bbfbSPeter Wemm     * All  such  code  is properly conditioned so the build process does
977a69bbfbSPeter Wemm       not attempt to compile it under a plain ANSI/POSIX environment.
987a69bbfbSPeter Wemm     * Adding    such   implementation   methods   does   not   introduce
997a69bbfbSPeter Wemm       incompatibilities in the ncurses API between platforms.
1007a69bbfbSPeter Wemm
1017a69bbfbSPeter Wemm   We  use GNU autoconf(1) as a tool to deal with portability issues. The
1027a69bbfbSPeter Wemm   right way to leverage an OS-specific feature is to modify the autoconf
1037a69bbfbSPeter Wemm   specification  files  (configure.in  and  aclocal.m4)  to set up a new
1047a69bbfbSPeter Wemm   feature macro, which you then use to condition your code.
1057a69bbfbSPeter Wemm
1067a69bbfbSPeter WemmDocumentation Conventions
1077a69bbfbSPeter Wemm
1087a69bbfbSPeter Wemm   There  are  three kinds of documentation associated with this package.
1097a69bbfbSPeter Wemm   Each has a different preferred format:
1107a69bbfbSPeter Wemm     * Package-internal files (README, INSTALL, TO-DO etc.)
1117a69bbfbSPeter Wemm     * Manual pages.
1127a69bbfbSPeter Wemm     * Everything else (i.e., narrative documentation).
1137a69bbfbSPeter Wemm
1147a69bbfbSPeter Wemm   Our conventions are simple:
1157a69bbfbSPeter Wemm    1. Maintain package-internal files in plain text. The expected viewer
116*21817992SBaptiste Daroussin       for  them  is  more(1)  or  an editor window; there is no point in
1177a69bbfbSPeter Wemm       elaborate mark-up.
1187a69bbfbSPeter Wemm    2. Mark  up manual pages in the man macros. These have to be viewable
1197a69bbfbSPeter Wemm       through traditional man(1) programs.
1207a69bbfbSPeter Wemm    3. Write everything else in HTML.
1217a69bbfbSPeter Wemm
1227a69bbfbSPeter Wemm   When  in  doubt,  HTMLize  a  master and use lynx(1) to generate plain
1237a69bbfbSPeter Wemm   ASCII (as we do for the announcement document).
1247a69bbfbSPeter Wemm
125aae38d10SBaptiste Daroussin   The  reason  for  choosing  HTML  is  that  it is (a) well-adapted for
126aae38d10SBaptiste Daroussin   on-line  browsing through viewers that are everywhere; (b) more easily
127aae38d10SBaptiste Daroussin   readable  as plain text than most other mark-ups, if you do not have a
128aae38d10SBaptiste Daroussin   viewer;  and  (c)  carries  enough information that you can generate a
1297a69bbfbSPeter Wemm   nice-looking  printed  version  from  it.  Also,  of  course,  it make
1307a69bbfbSPeter Wemm   exporting things like the announcement document to WWW pretty trivial.
1317a69bbfbSPeter Wemm
1327a69bbfbSPeter WemmHow to Report Bugs
1337a69bbfbSPeter Wemm
1347a69bbfbSPeter Wemm   The  reporting  address  for  bugs  is  bug-ncurses@gnu.org. This is a
1357a69bbfbSPeter Wemm   majordomo  list;  to join, write to bug-ncurses-request@gnu.org with a
1367a69bbfbSPeter Wemm   message containing the line:
1377a69bbfbSPeter Wemm             subscribe <name>@<host.domain>
1387a69bbfbSPeter Wemm
1397a69bbfbSPeter Wemm   The  ncurses  code is maintained by a small group of volunteers. While
140aae38d10SBaptiste Daroussin   we  try  our best to fix bugs promptly, we simply do not have a lot of
1417a69bbfbSPeter Wemm   hours  to  spend  on  elementary  hand-holding. We rely on intelligent
1427a69bbfbSPeter Wemm   cooperation  from  our  users.  If  you  think you have found a bug in
1437a69bbfbSPeter Wemm   ncurses,  there  are some steps you can take before contacting us that
1447a69bbfbSPeter Wemm   will help get the bug fixed quickly.
1457a69bbfbSPeter Wemm
1467a69bbfbSPeter Wemm   In  order  to  use  our bug-fixing time efficiently, we put people who
147aae38d10SBaptiste Daroussin   show  us  they  have  taken these steps at the head of our queue. This
148aae38d10SBaptiste Daroussin   means that if you do not, you will probably end up at the tail end and
149aae38d10SBaptiste Daroussin   have to wait a while.
1507a69bbfbSPeter Wemm    1. Develop a recipe to reproduce the bug.
1517a69bbfbSPeter Wemm       Bugs  we  can reproduce are likely to be fixed very quickly, often
1527a69bbfbSPeter Wemm       within  days.  The most effective single thing you can do to get a
1537a69bbfbSPeter Wemm       quick  fix  is  develop a way we can duplicate the bad behavior --
1547a69bbfbSPeter Wemm       ideally,  by  giving  us source for a small, portable test program
1557a69bbfbSPeter Wemm       that  breaks the library. (Even better is a keystroke recipe using
1567a69bbfbSPeter Wemm       one of the test programs provided with the distribution.)
1577a69bbfbSPeter Wemm    2. Try to reproduce the bug on a different terminal type.
1587a69bbfbSPeter Wemm       In  our experience, most of the behaviors people report as library
1597a69bbfbSPeter Wemm       bugs are actually due to subtle problems in terminal descriptions.
160aae38d10SBaptiste Daroussin       This  is  especially  likely  to  be  true  if  you  are  using  a
161aae38d10SBaptiste Daroussin       traditional  asynchronous  terminal or PC-based terminal emulator,
162aae38d10SBaptiste Daroussin       rather than xterm or a UNIX console entry.
163aae38d10SBaptiste Daroussin       It  is  therefore  extremely helpful if you can tell us whether or
164aae38d10SBaptiste Daroussin       not  your  problem reproduces on other terminal types. Usually you
165aae38d10SBaptiste Daroussin       will  have both a console type and xterm available; please tell us
1667a69bbfbSPeter Wemm       whether or not your bug reproduces on both.
1677a69bbfbSPeter Wemm       If  you  have  xterm  available,  it is also good to collect xterm
1687a69bbfbSPeter Wemm       reports for different window sizes. This is especially true if you
1697a69bbfbSPeter Wemm       normally  use  an unusual xterm window size -- a surprising number
170aae38d10SBaptiste Daroussin       of the bugs we have seen are either triggered or masked by these.
1717a69bbfbSPeter Wemm    3. Generate and examine a trace file for the broken behavior.
1727a69bbfbSPeter Wemm       Recompile   your  program  with  the  debugging  versions  of  the
1737a69bbfbSPeter Wemm       libraries.  Insert  a  trace()  call  with  the  argument  set  to
1747a69bbfbSPeter Wemm       TRACE_UPDATE.  (See "Writing Programs with NCURSES" for details on
1757a69bbfbSPeter Wemm       trace  levels.) Reproduce your bug, then look at the trace file to
1767a69bbfbSPeter Wemm       see what the library was actually doing.
1777a69bbfbSPeter Wemm       Another  frequent  cause  of  apparent  bugs is application coding
1787a69bbfbSPeter Wemm       errors  that  cause  the  wrong  things  to  be put on the virtual
1797a69bbfbSPeter Wemm       screen. Looking at the virtual-screen dumps in the trace file will
1807a69bbfbSPeter Wemm       tell  you  immediately if this is happening, and save you from the
1817a69bbfbSPeter Wemm       possible  embarrassment of being told that the bug is in your code
1827a69bbfbSPeter Wemm       and is your problem rather than ours.
183aae38d10SBaptiste Daroussin       If  the virtual-screen dumps look correct but the bug persists, it
184aae38d10SBaptiste Daroussin       is  possible  to  crank  up  the trace level to give more and more
1857a69bbfbSPeter Wemm       information  about  the  library's  update actions and the control
1867a69bbfbSPeter Wemm       sequences  it  issues  to  perform them. The test directory of the
1877a69bbfbSPeter Wemm       distribution contains a tool for digesting these logs to make them
1887a69bbfbSPeter Wemm       less tedious to wade through.
189aae38d10SBaptiste Daroussin       Often  you  will  find terminfo problems at this stage by noticing
190aae38d10SBaptiste Daroussin       that  the  escape  sequences  put out for various capabilities are
191aae38d10SBaptiste Daroussin       wrong.  If  not,  you  are  likely  to  learn enough to be able to
192aae38d10SBaptiste Daroussin       characterize any bug in the screen-update logic quite exactly.
1937a69bbfbSPeter Wemm    4. Report details and symptoms, not just interpretations.
194aae38d10SBaptiste Daroussin       If you do the preceding two steps, it is very likely that you will
1957a69bbfbSPeter Wemm       discover the nature of the problem yourself and be able to send us
1967a69bbfbSPeter Wemm       a  fix.  This  will  create happy feelings all around and earn you
197aae38d10SBaptiste Daroussin       good karma for the first time you run into a bug you really cannot
1987a69bbfbSPeter Wemm       characterize and fix yourself.
199aae38d10SBaptiste Daroussin       If  you  are  still stuck, at least you will know what to tell us.
2007a69bbfbSPeter Wemm       Remember,  we  need  details.  If  you guess about what is safe to
2017a69bbfbSPeter Wemm       leave out, you are too likely to be wrong.
2027a69bbfbSPeter Wemm       If  your  bug  produces a bad update, include a trace file. Try to
2037a69bbfbSPeter Wemm       make  the  trace  at the least voluminous level that pins down the
204aae38d10SBaptiste Daroussin       bug.  Logs  that  have been through tracemunch are OK, it does not
205aae38d10SBaptiste Daroussin       throw   away  any  information  (actually  they  are  better  than
206aae38d10SBaptiste Daroussin       un-munched ones because they are easier to read).
2077a69bbfbSPeter Wemm       If  your bug produces a core-dump, please include a symbolic stack
2087a69bbfbSPeter Wemm       trace generated by gdb(1) or your local equivalent.
209aae38d10SBaptiste Daroussin       Tell  us about every terminal on which you have reproduced the bug
210aae38d10SBaptiste Daroussin       --  and  every  terminal  on  which  you  cannot. Ideally, send us
211aae38d10SBaptiste Daroussin       terminfo sources for all of these (yours might differ from ours).
2127a69bbfbSPeter Wemm       Include  your ncurses version and your OS/machine type, of course!
2137a69bbfbSPeter Wemm       You can find your ncurses version in the curses.h file.
2147a69bbfbSPeter Wemm
2157a69bbfbSPeter Wemm   If  your  problem  smells  like a logic error or in cursor movement or
2167a69bbfbSPeter Wemm   scrolling  or a bad capability, there are a couple of tiny test frames
2177a69bbfbSPeter Wemm   for  the  library  algorithms in the progs directory that may help you
2187a69bbfbSPeter Wemm   isolate  it. These are not part of the normal build, but do have their
2197a69bbfbSPeter Wemm   own make productions.
2207a69bbfbSPeter Wemm
2217a69bbfbSPeter Wemm   The   most  important  of  these  is  mvcur,  a  test  frame  for  the
2227a69bbfbSPeter Wemm   cursor-movement  optimization  code.  With  this  program, you can see
2237a69bbfbSPeter Wemm   directly  what  control sequences will be emitted for any given cursor
224aae38d10SBaptiste Daroussin   movement or scroll/insert/delete operations. If you think you have got
225aae38d10SBaptiste Daroussin   a  bad  capability  identified, you can disable it and test again. The
2267a69bbfbSPeter Wemm   program is command-driven and has on-line help.
2277a69bbfbSPeter Wemm
2287a69bbfbSPeter Wemm   If  you think the vertical-scroll optimization is broken, or just want
2297a69bbfbSPeter Wemm   to  understand  how it works better, build hashmap and read the header
2307a69bbfbSPeter Wemm   comments  of hardscroll.c and hashmap.c; then try it out. You can also
2317a69bbfbSPeter Wemm   test the hardware-scrolling optimization separately with hardscroll.
2327a69bbfbSPeter Wemm
2337a69bbfbSPeter WemmA Tour of the Ncurses Library
2347a69bbfbSPeter Wemm
2357a69bbfbSPeter Wemm  Library Overview
2367a69bbfbSPeter Wemm
2377a69bbfbSPeter Wemm   Most  of  the  library is superstructure -- fairly trivial convenience
2387a69bbfbSPeter Wemm   interfaces  to a small set of basic functions and data structures used
2397a69bbfbSPeter Wemm   to  manipulate  the  virtual  screen (in particular, none of this code
2407a69bbfbSPeter Wemm   does  any  I/O  except  through  calls  to  more  fundamental  modules
2417a69bbfbSPeter Wemm   described below). The files
2427a69bbfbSPeter Wemm
2437a69bbfbSPeter Wemm     lib_addch.c    lib_bkgd.c    lib_box.c    lib_chgat.c   lib_clear.c
2447a69bbfbSPeter Wemm     lib_clearok.c  lib_clrbot.c  lib_clreol.c lib_colorset.c lib_data.c
2457a69bbfbSPeter Wemm     lib_delch.c    lib_delwin.c    lib_echo.c   lib_erase.c   lib_gen.c
2467a69bbfbSPeter Wemm     lib_getstr.c  lib_hline.c  lib_immedok.c  lib_inchstr.c lib_insch.c
2477a69bbfbSPeter Wemm     lib_insdel.c  lib_insstr.c lib_instr.c lib_isendwin.c lib_keyname.c
2487a69bbfbSPeter Wemm     lib_leaveok.c   lib_move.c   lib_mvwin.c   lib_overlay.c  lib_pad.c
2497a69bbfbSPeter Wemm     lib_printw.c  lib_redrawln.c  lib_scanw.c lib_screen.c lib_scroll.c
2507a69bbfbSPeter Wemm     lib_scrollok.c      lib_scrreg.c      lib_set_term.c      lib_slk.c
2517a69bbfbSPeter Wemm     lib_slkatr_set.c   lib_slkatrof.c   lib_slkatron.c  lib_slkatrset.c
2527a69bbfbSPeter Wemm     lib_slkattr.c     lib_slkclear.c    lib_slkcolor.c    lib_slkinit.c
2537a69bbfbSPeter Wemm     lib_slklab.c  lib_slkrefr.c lib_slkset.c lib_slktouch.c lib_touch.c
2547a69bbfbSPeter Wemm     lib_unctrl.c lib_vline.c lib_wattroff.c lib_wattron.c lib_window.c
2557a69bbfbSPeter Wemm
2567a69bbfbSPeter Wemm   are  all  in  this  category.  They  are very unlikely to need change,
2577a69bbfbSPeter Wemm   barring bugs or some fundamental reorganization in the underlying data
2587a69bbfbSPeter Wemm   structures.
2597a69bbfbSPeter Wemm
2607a69bbfbSPeter Wemm   These files are used only for debugging support:
2617a69bbfbSPeter Wemm
2627a69bbfbSPeter Wemm     lib_trace.c     lib_traceatr.c    lib_tracebits.c    lib_tracechr.c
2637a69bbfbSPeter Wemm     lib_tracedmp.c lib_tracemse.c trace_buf.c
2647a69bbfbSPeter Wemm
2657a69bbfbSPeter Wemm   It  is  rather unlikely you will ever need to change these, unless you
2665ca44d1cSRong-En Fan   want to introduce a new debug trace level for some reason.
2677a69bbfbSPeter Wemm
2687a69bbfbSPeter Wemm   There  is  another  group  of  files  that  do direct I/O via tputs(),
2697a69bbfbSPeter Wemm   computations  on  the  terminal  capabilities,  or  queries  to the OS
2707a69bbfbSPeter Wemm   environment,  but  nevertheless have only fairly low complexity. These
2717a69bbfbSPeter Wemm   include:
2727a69bbfbSPeter Wemm
2737a69bbfbSPeter Wemm     lib_acs.c   lib_beep.c   lib_color.c   lib_endwin.c   lib_initscr.c
2747a69bbfbSPeter Wemm     lib_longname.c  lib_newterm.c  lib_options.c lib_termcap.c lib_ti.c
2757a69bbfbSPeter Wemm     lib_tparm.c lib_tputs.c lib_vidattr.c read_entry.c.
2767a69bbfbSPeter Wemm
2777a69bbfbSPeter Wemm   They are likely to need revision only if ncurses is being ported to an
2787a69bbfbSPeter Wemm   environment without an underlying terminfo capability representation.
2797a69bbfbSPeter Wemm
2807a69bbfbSPeter Wemm   These  files  have  serious  hooks  into  the  tty  driver  and signal
2817a69bbfbSPeter Wemm   facilities:
2827a69bbfbSPeter Wemm
2837a69bbfbSPeter Wemm     lib_kernel.c lib_baudrate.c lib_raw.c lib_tstp.c lib_twait.c
2847a69bbfbSPeter Wemm
2857a69bbfbSPeter Wemm   If you run into porting snafus moving the package to another UNIX, the
2867a69bbfbSPeter Wemm   problem  is  likely  to be in one of these files. The file lib_print.c
2877a69bbfbSPeter Wemm   uses sleep(2) and also falls in this category.
2887a69bbfbSPeter Wemm
2897a69bbfbSPeter Wemm   Almost all of the real work is done in the files
2907a69bbfbSPeter Wemm
2917a69bbfbSPeter Wemm     hardscroll.c   hashmap.c   lib_addch.c  lib_doupdate.c  lib_getch.c
2927a69bbfbSPeter Wemm     lib_mouse.c lib_mvcur.c lib_refresh.c lib_setup.c lib_vidattr.c
2937a69bbfbSPeter Wemm
2947a69bbfbSPeter Wemm   Most  of  the  algorithmic  complexity  in  the library lives in these
295aae38d10SBaptiste Daroussin   files.  If there is a real bug in ncurses itself, it is probably here.
296aae38d10SBaptiste Daroussin   We  will  tour  some  of  these  files in detail below (see The Engine
297aae38d10SBaptiste Daroussin   Room).
2987a69bbfbSPeter Wemm
2997a69bbfbSPeter Wemm   Finally,  there  is  a  group  of  files  that is actually most of the
3007a69bbfbSPeter Wemm   terminfo  compiler.  The reason this code lives in the ncurses library
3017a69bbfbSPeter Wemm   is to support fallback to /etc/termcap. These files include
3027a69bbfbSPeter Wemm
3037a69bbfbSPeter Wemm     alloc_entry.c  captoinfo.c  comp_captab.c  comp_error.c comp_hash.c
3047a69bbfbSPeter Wemm     comp_parse.c comp_scan.c parse_entry.c read_termcap.c write_entry.c
3057a69bbfbSPeter Wemm
306aae38d10SBaptiste Daroussin   We will discuss these in the compiler tour.
3077a69bbfbSPeter Wemm
3087a69bbfbSPeter Wemm  The Engine Room
3097a69bbfbSPeter Wemm
3107a69bbfbSPeter Wemm    Keyboard Input
3117a69bbfbSPeter Wemm
3127a69bbfbSPeter Wemm   All  ncurses  input  funnels through the function wgetch(), defined in
3137a69bbfbSPeter Wemm   lib_getch.c.  This function is tricky; it has to poll for keyboard and
3147a69bbfbSPeter Wemm   mouse  events and do a running match of incoming input against the set
3157a69bbfbSPeter Wemm   of defined special keys.
3167a69bbfbSPeter Wemm
3177a69bbfbSPeter Wemm   The  central  data  structure  in this module is a FIFO queue, used to
3187a69bbfbSPeter Wemm   match   multiple-character   input   sequences   against   special-key
3197a69bbfbSPeter Wemm   capabilities; also to implement pushback via ungetch().
3207a69bbfbSPeter Wemm
3217a69bbfbSPeter Wemm   The wgetch() code distinguishes between function key sequences and the
3227a69bbfbSPeter Wemm   same  sequences  typed manually by doing a timed wait after each input
3237a69bbfbSPeter Wemm   character  that  could  lead  a  function  key sequence. If the entire
3247a69bbfbSPeter Wemm   sequence  takes  less  than  1  second,  it  is  assumed  to have been
3257a69bbfbSPeter Wemm   generated by a function key press.
3267a69bbfbSPeter Wemm
3277a69bbfbSPeter Wemm   Hackers  bruised  by  previous encounters with variant select(2) calls
3287a69bbfbSPeter Wemm   may  find  the  code  in  lib_twait.c  interesting.  It deals with the
329aae38d10SBaptiste Daroussin   problem  that  some  BSD  selects  do  not return a reliable time-left
330aae38d10SBaptiste Daroussin   value.  The  function  timed_wait()  effectively  simulates a System V
331aae38d10SBaptiste Daroussin   select.
3327a69bbfbSPeter Wemm
3337a69bbfbSPeter Wemm    Mouse Events
3347a69bbfbSPeter Wemm
3357a69bbfbSPeter Wemm   If the mouse interface is active, wgetch() polls for mouse events each
3367a69bbfbSPeter Wemm   call,  before  it  goes  to  the  keyboard  for  input.  It  is  up to
3377a69bbfbSPeter Wemm   lib_mouse.c how the polling is accomplished; it may vary for different
3387a69bbfbSPeter Wemm   devices.
3397a69bbfbSPeter Wemm
3407a69bbfbSPeter Wemm   Under  xterm,  however,  mouse  event  notifications  come  in via the
3417a69bbfbSPeter Wemm   keyboard  input  stream.  They  are  recognized  by  having  the kmous
3427a69bbfbSPeter Wemm   capability  as a prefix. This is kind of klugey, but trying to wire in
3437a69bbfbSPeter Wemm   recognition   of   a  mouse  key  prefix  without  going  through  the
3447a69bbfbSPeter Wemm   function-key  machinery  would be just too painful, and this turns out
3457a69bbfbSPeter Wemm   to  imply having the prefix somewhere in the function-key capabilities
3467a69bbfbSPeter Wemm   at terminal-type initialization.
3477a69bbfbSPeter Wemm
348aae38d10SBaptiste Daroussin   This  kluge  only  works  because  kmous  is  not actually used by any
3497a69bbfbSPeter Wemm   historic terminal type or curses implementation we know of. Best guess
350aae38d10SBaptiste Daroussin   is  it  is  a relic of some forgotten experiment in-house at Bell Labs
351aae38d10SBaptiste Daroussin   that  did  not  leave  any traces in the publicly-distributed System V
3527a69bbfbSPeter Wemm   terminfo  files.  If System V or XPG4 ever gets serious about using it
3537a69bbfbSPeter Wemm   again, this kluge may have to change.
3547a69bbfbSPeter Wemm
3557a69bbfbSPeter Wemm   Here are some more details about mouse event handling:
3567a69bbfbSPeter Wemm
357aae38d10SBaptiste Daroussin   The  lib_mouse()  code  is  logically  split  into  a lower level that
358aae38d10SBaptiste Daroussin   accepts  event reports in a device-dependent format and an upper level
359aae38d10SBaptiste Daroussin   that  parses  mouse  gestures  and  filters events. The mediating data
360aae38d10SBaptiste Daroussin   structure is a circular queue of event structures.
3617a69bbfbSPeter Wemm
3627a69bbfbSPeter Wemm   Functionally, the lower level's job is to pick up primitive events and
3637a69bbfbSPeter Wemm   put  them  on  the circular queue. This can happen in one of two ways:
3647a69bbfbSPeter Wemm   either  (a)  _nc_mouse_event()  detects  a  series  of  incoming mouse
3657a69bbfbSPeter Wemm   reports  and queues them, or (b) code in lib_getch.c detects the kmous
3667a69bbfbSPeter Wemm   prefix  in  the  keyboard  input  stream and calls _nc_mouse_inline to
3677a69bbfbSPeter Wemm   queue up a series of adjacent mouse reports.
3687a69bbfbSPeter Wemm
3697a69bbfbSPeter Wemm   In either case, _nc_mouse_parse() should be called after the series is
3707a69bbfbSPeter Wemm   accepted to parse the digested mouse reports (low-level events) into a
3717a69bbfbSPeter Wemm   gesture (a high-level or composite event).
3727a69bbfbSPeter Wemm
3737a69bbfbSPeter Wemm    Output and Screen Updating
3747a69bbfbSPeter Wemm
3757a69bbfbSPeter Wemm   With the single exception of character echoes during a wgetnstr() call
3767a69bbfbSPeter Wemm   (which  simulates  cooked-mode line editing in an ncurses window), the
3777a69bbfbSPeter Wemm   library normally does all its output at refresh time.
3787a69bbfbSPeter Wemm
3797a69bbfbSPeter Wemm   The  main  job  is  to  go  from  the  current state of the screen (as
3807a69bbfbSPeter Wemm   represented  in  the curscr window structure) to the desired new state
3817a69bbfbSPeter Wemm   (as represented in the newscr window structure), while doing as little
3827a69bbfbSPeter Wemm   I/O as possible.
3837a69bbfbSPeter Wemm
3847a69bbfbSPeter Wemm   The  brains  of this operation are the modules hashmap.c, hardscroll.c
3857a69bbfbSPeter Wemm   and  lib_doupdate.c; the latter two use lib_mvcur.c. Essentially, what
3867a69bbfbSPeter Wemm   happens looks like this:
387aae38d10SBaptiste Daroussin     * The  hashmap.c  module  tries  to  detect  vertical motion changes
388aae38d10SBaptiste Daroussin       between   the  real  and  virtual  screens.  This  information  is
389aae38d10SBaptiste Daroussin       represented by the oldindex members in the newscr structure. These
390aae38d10SBaptiste Daroussin       are modified by vertical-motion and clear operations, and both are
391aae38d10SBaptiste Daroussin       re-initialized  after  each  update.  To  this  change-journalling
392aae38d10SBaptiste Daroussin       information,  the  hashmap  code  adds  deductions  made  using  a
393aae38d10SBaptiste Daroussin       modified  Heckel  algorithm on hash values generated from the line
394aae38d10SBaptiste Daroussin       contents.
395aae38d10SBaptiste Daroussin     * The  hardscroll.c  module  computes  an  optimum  set  of  scroll,
396aae38d10SBaptiste Daroussin       insertion,  and  deletion operations to make the indices match. It
397aae38d10SBaptiste Daroussin       calls _nc_mvcur_scrolln() in lib_mvcur.c to do those motions.
398aae38d10SBaptiste Daroussin     * Then  lib_doupdate.c  goes  to work. Its job is to do line-by-line
399aae38d10SBaptiste Daroussin       transformations  of curscr lines to newscr lines. Its main tool is
400aae38d10SBaptiste Daroussin       the   routine   mvcur()   in   lib_mvcur.c.   This   routine  does
401aae38d10SBaptiste Daroussin       cursor-movement  optimization, attempting to get from given screen
402aae38d10SBaptiste Daroussin       location  A  to  given  location B in the fewest output characters
403aae38d10SBaptiste Daroussin       possible.
4047a69bbfbSPeter Wemm
4057a69bbfbSPeter Wemm   If  you  want to work on screen optimizations, you should use the fact
4067a69bbfbSPeter Wemm   that  (in  the  trace-enabled  version  of  the  library) enabling the
4077a69bbfbSPeter Wemm   TRACE_TIMES  trace  level  causes  a  report  to be emitted after each
4087a69bbfbSPeter Wemm   screen  update  giving  the  elapsed  time  and  a count of characters
4097a69bbfbSPeter Wemm   emitted  during  the  update.  You can use this to tell when an update
4107a69bbfbSPeter Wemm   optimization improves efficiency.
4117a69bbfbSPeter Wemm
4127a69bbfbSPeter Wemm   In  the  trace-enabled  version of the library, it is also possible to
4137a69bbfbSPeter Wemm   disable and re-enable various optimizations at runtime by tweaking the
4147a69bbfbSPeter Wemm   variable  _nc_optimize_enable.  See  the  file include/curses.h.in for
4157a69bbfbSPeter Wemm   mask values, near the end.
4167a69bbfbSPeter Wemm
4177a69bbfbSPeter WemmThe Forms and Menu Libraries
4187a69bbfbSPeter Wemm
4197a69bbfbSPeter Wemm   The  forms  and menu libraries should work reliably in any environment
4207a69bbfbSPeter Wemm   you  can  port ncurses to. The only portability issue anywhere in them
4217a69bbfbSPeter Wemm   is  what  flavor  of  regular expressions the built-in form field type
4227a69bbfbSPeter Wemm   TYPE_REGEXP will recognize.
4237a69bbfbSPeter Wemm
4247a69bbfbSPeter Wemm   The  configuration  code  prefers the POSIX regex facility, modeled on
425aae38d10SBaptiste Daroussin   System  V's,  but  will  settle  for  BSD regexps if the former is not
4267a69bbfbSPeter Wemm   available.
4277a69bbfbSPeter Wemm
4287a69bbfbSPeter Wemm   Historical  note:  the  panels code was written primarily to assist in
4297a69bbfbSPeter Wemm   porting  u386mon  2.0 (comp.sources.misc v14i001-4) to systems lacking
4307a69bbfbSPeter Wemm   panels  support; u386mon 2.10 and beyond use it. This version has been
4317a69bbfbSPeter Wemm   slightly cleaned up for ncurses.
4327a69bbfbSPeter Wemm
4337a69bbfbSPeter WemmA Tour of the Terminfo Compiler
4347a69bbfbSPeter Wemm
4357a69bbfbSPeter Wemm   The ncurses implementation of tic is rather complex internally; it has
4367a69bbfbSPeter Wemm   to  do  a  trying  combination  of missions. This starts with the fact
4377a69bbfbSPeter Wemm   that,  in  addition  to  its normal duty of compiling terminfo sources
4387a69bbfbSPeter Wemm   into  loadable  terminfo binaries, it has to be able to handle termcap
4397a69bbfbSPeter Wemm   syntax and compile that too into terminfo entries.
4407a69bbfbSPeter Wemm
4417a69bbfbSPeter Wemm   The  implementation  therefore  starts  with a table-driven, dual-mode
4427a69bbfbSPeter Wemm   lexical analyzer (in comp_scan.c). The lexer chooses its mode (termcap
443aae38d10SBaptiste Daroussin   or terminfo) based on the first "," or ":" it finds in each entry. The
4447a69bbfbSPeter Wemm   lexer  does  all  the work of recognizing capability names and values;
4457a69bbfbSPeter Wemm   the  grammar above it is trivial, just "parse entries till you run out
4467a69bbfbSPeter Wemm   of file".
4477a69bbfbSPeter Wemm
4487a69bbfbSPeter Wemm  Translation of Non-use Capabilities
4497a69bbfbSPeter Wemm
4507a69bbfbSPeter Wemm   Translation   of  most  things  besides  use  capabilities  is  pretty
4517a69bbfbSPeter Wemm   straightforward.   The   lexical   analyzer's   tokenizer  hands  each
4527a69bbfbSPeter Wemm   capability  name  to a hash function, which drives a table lookup. The
4537a69bbfbSPeter Wemm   table entry yields an index which is used to look up the token type in
4547a69bbfbSPeter Wemm   another table, and controls interpretation of the value.
4557a69bbfbSPeter Wemm
4567a69bbfbSPeter Wemm   One  possibly  interesting aspect of the implementation is the way the
4577a69bbfbSPeter Wemm   compiler  tables  are  initialized.  All  the  tables are generated by
4587a69bbfbSPeter Wemm   various  awk/sed/sh  scripts  from  a master table include/Caps; these
4597a69bbfbSPeter Wemm   scripts  actually  write  C  initializers  which  are  linked  to  the
4607a69bbfbSPeter Wemm   compiler. Furthermore, the hash table is generated in the same way, so
4617a69bbfbSPeter Wemm   it  doesn't  have  to  be  generated at compiler startup time (another
4627a69bbfbSPeter Wemm   benefit  of  this  organization  is  that  the  hash  table  can be in
4637a69bbfbSPeter Wemm   shareable text space).
4647a69bbfbSPeter Wemm
4657a69bbfbSPeter Wemm   Thus, adding a new capability is usually pretty trivial, just a matter
466aae38d10SBaptiste Daroussin   of  adding one line to the include/Caps file. We will have more to say
4677a69bbfbSPeter Wemm   about this in the section on Source-Form Translation.
4687a69bbfbSPeter Wemm
4697a69bbfbSPeter Wemm  Use Capability Resolution
4707a69bbfbSPeter Wemm
471aae38d10SBaptiste Daroussin   The  background  problem  that  makes tic tricky is not the capability
472aae38d10SBaptiste Daroussin   translation  itself,  it  is the resolution of use capabilities. Older
4737a69bbfbSPeter Wemm   versions would not handle forward use references for this reason (that
4747a69bbfbSPeter Wemm   is, a using terminal always had to follow its use target in the source
4757a69bbfbSPeter Wemm   file).  By  doing  this,  they  got  away with a simple implementation
4767a69bbfbSPeter Wemm   tactic;  compile  everything  as  it  blows by, then resolve uses from
4777a69bbfbSPeter Wemm   compiled entries.
4787a69bbfbSPeter Wemm
479aae38d10SBaptiste Daroussin   This  will  not  do  for  ncurses.  The problem is that that the whole
4807a69bbfbSPeter Wemm   compilation  process  has  to  be embeddable in the ncurses library so
4817a69bbfbSPeter Wemm   that it can be called by the startup code to translate termcap entries
482aae38d10SBaptiste Daroussin   on  the  fly.  The  embedded  version  cannot go promiscuously writing
4837a69bbfbSPeter Wemm   everything  it  translates  out  to  disk  --  for  one thing, it will
4847a69bbfbSPeter Wemm   typically be running with non-root permissions.
4857a69bbfbSPeter Wemm
4867a69bbfbSPeter Wemm   So  our  tic  is  designed  to  parse  an  entire terminfo file into a
4877a69bbfbSPeter Wemm   doubly-linked  circular  list of entry structures in-core, and then do
4887a69bbfbSPeter Wemm   use  resolution  in-memory  before writing everything out. This design
4897a69bbfbSPeter Wemm   has other advantages: it makes forward and back use-references equally
4907a69bbfbSPeter Wemm   easy  (so  we get the latter for free), and it makes checking for name
491aae38d10SBaptiste Daroussin   collisions before they are written out easy to do.
4927a69bbfbSPeter Wemm
4937a69bbfbSPeter Wemm   And   this  is  exactly  how  the  embedded  version  works.  But  the
4947a69bbfbSPeter Wemm   stand-alone  user-accessible  version  of  tic  partly  reverts to the
4957a69bbfbSPeter Wemm   historical strategy; it writes to disk (not keeping in core) any entry
4967a69bbfbSPeter Wemm   with no use references.
4977a69bbfbSPeter Wemm
4987a69bbfbSPeter Wemm   This  is  strictly  a  core-economy  kluge,  implemented  because  the
4997a69bbfbSPeter Wemm   terminfo  master file is large enough that some core-poor systems swap
5007a69bbfbSPeter Wemm   like crazy when you compile it all in memory...there have been reports
5017a69bbfbSPeter Wemm   of  this process taking three hours, rather than the twenty seconds or
5027a69bbfbSPeter Wemm   less typical on the author's development box.
5037a69bbfbSPeter Wemm
5047a69bbfbSPeter Wemm   So. The executable tic passes the entry-parser a hook that immediately
5057a69bbfbSPeter Wemm   writes  out  the  referenced  entry if it has no use capabilities. The
5067a69bbfbSPeter Wemm   compiler  main loop refrains from adding the entry to the in-core list
5077a69bbfbSPeter Wemm   when  this hook fires. If some other entry later needs to reference an
508aae38d10SBaptiste Daroussin   entry  that  got  written immediately, that is OK; the resolution code
509aae38d10SBaptiste Daroussin   will fetch it off disk when it cannot find it in core.
5107a69bbfbSPeter Wemm
5117a69bbfbSPeter Wemm   Name  collisions  will  still  be  detected,  just not as cleanly. The
5127a69bbfbSPeter Wemm   write_entry()   code   complains  before  overwriting  an  entry  that
5137a69bbfbSPeter Wemm   postdates  the time of tic's first call to write_entry(), Thus it will
5147a69bbfbSPeter Wemm   complain  about overwriting entries newly made during the tic run, but
5157a69bbfbSPeter Wemm   not about overwriting ones that predate it.
5167a69bbfbSPeter Wemm
5177a69bbfbSPeter Wemm  Source-Form Translation
5187a69bbfbSPeter Wemm
5197a69bbfbSPeter Wemm   Another use of tic is to do source translation between various termcap
5207a69bbfbSPeter Wemm   and terminfo formats. There are more variants out there than you might
5217a69bbfbSPeter Wemm   think; the ones we know about are described in the captoinfo(1) manual
5227a69bbfbSPeter Wemm   page.
5237a69bbfbSPeter Wemm
5247a69bbfbSPeter Wemm   The  translation output code (dump_entry() in ncurses/dump_entry.c) is
5257a69bbfbSPeter Wemm   shared  with  the  infocmp(1)  utility.  It  takes  the  same internal
5267a69bbfbSPeter Wemm   representation  used  to  generate  the  binary  form  and dumps it to
5277a69bbfbSPeter Wemm   standard output in a specified format.
5287a69bbfbSPeter Wemm
5297a69bbfbSPeter Wemm   The  include/Caps  file  has  a header comment describing ways you can
5307a69bbfbSPeter Wemm   specify  source  translations  for  nonstandard  capabilities  just by
531aae38d10SBaptiste Daroussin   altering  the  master  table.  It  is  possible  to  set up capability
532aae38d10SBaptiste Daroussin   aliasing  or  tell  the  compiler  to  plain ignore a given capability
533aae38d10SBaptiste Daroussin   without writing any C code at all.
5347a69bbfbSPeter Wemm
5357a69bbfbSPeter Wemm   For  circumstances where you need to do algorithmic translation, there
5367a69bbfbSPeter Wemm   are  functions  in  parse_entry.c called after the parse of each entry
5377a69bbfbSPeter Wemm   that are specifically intended to encapsulate such translations. This,
5387a69bbfbSPeter Wemm   for  example,  is  where  the AIX box1 capability get translated to an
5397a69bbfbSPeter Wemm   acsc string.
5407a69bbfbSPeter Wemm
5417a69bbfbSPeter WemmOther Utilities
5427a69bbfbSPeter Wemm
5437a69bbfbSPeter Wemm   The  infocmp  utility  is just a wrapper around the same entry-dumping
5447a69bbfbSPeter Wemm   code  used  by tic for source translation. Perhaps the one interesting
5457a69bbfbSPeter Wemm   aspect  of  the  code  is the use of a predicate function passed in to
5467a69bbfbSPeter Wemm   dump_entry()  to  control  which  capabilities  are  dumped.  This  is
5477a69bbfbSPeter Wemm   necessary in order to handle both the ordinary De-compilation case and
5487a69bbfbSPeter Wemm   entry difference reporting.
5497a69bbfbSPeter Wemm
5507a69bbfbSPeter Wemm   The  tput  and  clear  utilities  just  do an entry load followed by a
5517a69bbfbSPeter Wemm   tputs() of a selected capability.
5527a69bbfbSPeter Wemm
5537a69bbfbSPeter WemmStyle Tips for Developers
5547a69bbfbSPeter Wemm
5557a69bbfbSPeter Wemm   See   the  TO-DO  file  in  the  top-level  directory  of  the  source
5567a69bbfbSPeter Wemm   distribution for additions that would be particularly useful.
5577a69bbfbSPeter Wemm
5587a69bbfbSPeter Wemm   The  prefix  _nc_  should be used on library public functions that are
5597a69bbfbSPeter Wemm   not  part  of  the  curses  API  in  order to prevent pollution of the
5607a69bbfbSPeter Wemm   application  namespace.  If  you have to add to or modify the function
5617a69bbfbSPeter Wemm   prototypes  in curses.h.in, read ncurses/MKlib_gen.sh first so you can
5627a69bbfbSPeter Wemm   avoid  breaking XSI conformance. Please join the ncurses mailing list.
5637a69bbfbSPeter Wemm   See  the INSTALL file in the top level of the distribution for details
5647a69bbfbSPeter Wemm   on the list.
5657a69bbfbSPeter Wemm
5667a69bbfbSPeter Wemm   Look  for  the  string  FIXME  in  source  files to tag minor bugs and
5677a69bbfbSPeter Wemm   potential problems that could use fixing.
5687a69bbfbSPeter Wemm
569aae38d10SBaptiste Daroussin   Do  not try to auto-detect OS features in the main body of the C code.
570aae38d10SBaptiste Daroussin   That is the job of the configuration system.
5717a69bbfbSPeter Wemm
5727a69bbfbSPeter Wemm   To hold down complexity, do make your code data-driven. Especially, if
5737a69bbfbSPeter Wemm   you  can drive logic from a table filtered out of include/Caps, do it.
5747a69bbfbSPeter Wemm   If  you  find  you  need  to augment the data in that file in order to
575aae38d10SBaptiste Daroussin   generate  the proper table, that is still preferable to ad-hoc code --
576aae38d10SBaptiste Daroussin   that is why the fifth field (flags) is there.
5777a69bbfbSPeter Wemm
5787a69bbfbSPeter Wemm   Have fun!
5797a69bbfbSPeter Wemm
5807a69bbfbSPeter WemmPorting Hints
5817a69bbfbSPeter Wemm
5827a69bbfbSPeter Wemm   The  following  notes  are intended to be a first step towards DOS and
5837a69bbfbSPeter Wemm   Macintosh ports of the ncurses libraries.
5847a69bbfbSPeter Wemm
585aae38d10SBaptiste Daroussin   The  following library modules are "pure curses"; they operate only on
5867a69bbfbSPeter Wemm   the  curses  internal  structures,  do all output through other curses
5877a69bbfbSPeter Wemm   calls  (not  including  tputs()  and putp()) and do not call any other
5887a69bbfbSPeter Wemm   UNIX  routines  such  as  signal(2)  or  the stdio library. Thus, they
5897a69bbfbSPeter Wemm   should not need to be modified for single-terminal ports.
5907a69bbfbSPeter Wemm
5917a69bbfbSPeter Wemm     lib_addch.c    lib_addstr.c    lib_bkgd.c   lib_box.c   lib_clear.c
5927a69bbfbSPeter Wemm     lib_clrbot.c   lib_clreol.c  lib_delch.c  lib_delwin.c  lib_erase.c
5937a69bbfbSPeter Wemm     lib_inchstr.c  lib_insch.c  lib_insdel.c lib_insstr.c lib_keyname.c
5947a69bbfbSPeter Wemm     lib_move.c   lib_mvwin.c   lib_newwin.c   lib_overlay.c   lib_pad.c
5957a69bbfbSPeter Wemm     lib_printw.c  lib_refresh.c  lib_scanw.c  lib_scroll.c lib_scrreg.c
5967a69bbfbSPeter Wemm     lib_set_term.c  lib_touch.c  lib_tparm.c  lib_tputs.c  lib_unctrl.c
5977a69bbfbSPeter Wemm     lib_window.c panel.c
5987a69bbfbSPeter Wemm
5997a69bbfbSPeter Wemm   This module is pure curses, but calls outstr():
6007a69bbfbSPeter Wemm
6017a69bbfbSPeter Wemm     lib_getstr.c
6027a69bbfbSPeter Wemm
6037a69bbfbSPeter Wemm   These  modules  are  pure  curses,  except  that  they use tputs() and
6047a69bbfbSPeter Wemm   putp():
6057a69bbfbSPeter Wemm
6067a69bbfbSPeter Wemm     lib_beep.c   lib_color.c   lib_endwin.c   lib_options.c   lib_slk.c
6077a69bbfbSPeter Wemm     lib_vidattr.c
6087a69bbfbSPeter Wemm
6097a69bbfbSPeter Wemm   This modules assist in POSIX emulation on non-POSIX systems:
6107a69bbfbSPeter Wemm
6117a69bbfbSPeter Wemm   sigaction.c
6127a69bbfbSPeter Wemm          signal calls
6137a69bbfbSPeter Wemm
6147a69bbfbSPeter Wemm   The    following   source   files   will   not   be   needed   for   a
6157a69bbfbSPeter Wemm   single-terminal-type port.
6167a69bbfbSPeter Wemm
6177a69bbfbSPeter Wemm     alloc_entry.c   captoinfo.c   clear.c   comp_captab.c  comp_error.c
6187a69bbfbSPeter Wemm     comp_hash.c   comp_main.c   comp_parse.c  comp_scan.c  dump_entry.c
6197a69bbfbSPeter Wemm     infocmp.c parse_entry.c read_entry.c tput.c write_entry.c
6207a69bbfbSPeter Wemm
6217a69bbfbSPeter Wemm   The  following  modules will use open()/read()/write()/close()/lseek()
6227a69bbfbSPeter Wemm   on files, but no other OS calls.
6237a69bbfbSPeter Wemm
6247a69bbfbSPeter Wemm   lib_screen.c
6257a69bbfbSPeter Wemm          used to read/write screen dumps
6267a69bbfbSPeter Wemm
6277a69bbfbSPeter Wemm   lib_trace.c
6287a69bbfbSPeter Wemm          used to write trace data to the logfile
6297a69bbfbSPeter Wemm
6307a69bbfbSPeter Wemm   Modules that would have to be modified for a port start here:
6317a69bbfbSPeter Wemm
632aae38d10SBaptiste Daroussin   The  following  modules  are  "pure  curses"  but  contain assumptions
6337a69bbfbSPeter Wemm   inappropriate for a memory-mapped port.
6347a69bbfbSPeter Wemm
6357a69bbfbSPeter Wemm   lib_longname.c
6367a69bbfbSPeter Wemm          assumes there may be multiple terminals
6377a69bbfbSPeter Wemm
6387a69bbfbSPeter Wemm   lib_acs.c
6397a69bbfbSPeter Wemm          assumes acs_map as a double indirection
6407a69bbfbSPeter Wemm
6417a69bbfbSPeter Wemm   lib_mvcur.c
6427a69bbfbSPeter Wemm          assumes cursor moves have variable cost
6437a69bbfbSPeter Wemm
6447a69bbfbSPeter Wemm   lib_termcap.c
6457a69bbfbSPeter Wemm          assumes there may be multiple terminals
6467a69bbfbSPeter Wemm
6477a69bbfbSPeter Wemm   lib_ti.c
6487a69bbfbSPeter Wemm          assumes there may be multiple terminals
6497a69bbfbSPeter Wemm
6507a69bbfbSPeter Wemm   The following modules use UNIX-specific calls:
6517a69bbfbSPeter Wemm
6527a69bbfbSPeter Wemm   lib_doupdate.c
6537a69bbfbSPeter Wemm          input checking
6547a69bbfbSPeter Wemm
6557a69bbfbSPeter Wemm   lib_getch.c
6567a69bbfbSPeter Wemm          read()
6577a69bbfbSPeter Wemm
6587a69bbfbSPeter Wemm   lib_initscr.c
6597a69bbfbSPeter Wemm          getenv()
6607a69bbfbSPeter Wemm
6617a69bbfbSPeter Wemm   lib_newterm.c
6627a69bbfbSPeter Wemm   lib_baudrate.c
6637a69bbfbSPeter Wemm   lib_kernel.c
6647a69bbfbSPeter Wemm          various tty-manipulation and system calls
6657a69bbfbSPeter Wemm
6667a69bbfbSPeter Wemm   lib_raw.c
6677a69bbfbSPeter Wemm          various tty-manipulation calls
6687a69bbfbSPeter Wemm
6697a69bbfbSPeter Wemm   lib_setup.c
6707a69bbfbSPeter Wemm          various tty-manipulation calls
6717a69bbfbSPeter Wemm
6727a69bbfbSPeter Wemm   lib_restart.c
6737a69bbfbSPeter Wemm          various tty-manipulation calls
6747a69bbfbSPeter Wemm
6757a69bbfbSPeter Wemm   lib_tstp.c
6767a69bbfbSPeter Wemm          signal-manipulation calls
6777a69bbfbSPeter Wemm
6787a69bbfbSPeter Wemm   lib_twait.c
6797a69bbfbSPeter Wemm          gettimeofday(), select().
6807a69bbfbSPeter Wemm     _________________________________________________________________
6817a69bbfbSPeter Wemm
6827a69bbfbSPeter Wemm
6837a69bbfbSPeter Wemm    Eric S. Raymond <esr@snark.thyrsus.com>
6847a69bbfbSPeter Wemm
6857a69bbfbSPeter Wemm   (Note: This is not the bug address!)
686