This document is a hacker's tour of the ncurses library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or improving the
package.
The objective of the ncurses package is to provide a free software API for
character-cell terminals and terminal emulators with the following
characteristics:
Source-compatible with historical curses implementations (including
the original BSD curses and System V curses.
Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
Featureful -- should eliminate as much of the drudgery of C interface
programming as possible, freeing programmers to think at a higher
level of design.
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we cannot
add features if it means breaking the portion of the API corresponding
to historical curses versions.
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives.
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also
capture BSD's.
More importantly for the future, the XSI Curses standard issued by X/Open
is explicitly and closely modeled on System V. So conformance with
System V took us most of the way to base-level XSI conformance.
The third objective (standards conformance) requires that it be easy to
condition source code using ncurses so that the absence of nonstandard
extensions does not break the code.
Accordingly, we have a policy of associating with each nonstandard extension
a feature macro, so that ncurses client code can use this macro to condition
in or out the code that requires the ncurses extension.
For example, there is a macro NCURSES_MOUSE_VERSION which XSI Curses
does not define, but which is defined in the ncurses library header.
You can use this to condition the calls to the mouse API calls.
Code written for ncurses may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible select(2) call.
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible.
We encourage developers to support OS-specific optimizations and methods
not available under POSIX/ANSI, provided only that:
All such code is properly conditioned so the build process does not
attempt to compile it under a plain ANSI/POSIX environment.
Adding such implementation methods does not introduce incompatibilities
in the ncurses API between platforms.
We use GNU autoconf(1) as a tool to deal with portability issues.
The right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new feature
macro, which you then use to condition your code.
Maintain package-internal files in plain text.
The expected viewer for them more(1) or an editor window; there's
no point in elaborate mark-up.
Mark up manual pages in the man macros. These have to be viewable
through traditional man(1) programs.
Write everything else in HTML.
When in doubt, HTMLize a master and use lynx(1) to generate
plain ASCII (as we do for the announcement document).
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if youA>
*
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
-->
A Hacker's Guide to Ncurses Internals
This document is a hacker's tour of the ncurses library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or improving the
package.
The objective of the ncurses package is to provide a free software API for
character-cell terminals and terminal emulators with the following
characteristics:
Source-compatible with historical curses implementations (including
the original BSD curses and System V curses.
Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
Featureful -- should eliminate as much of the drudgery of C interface
programming as possible, freeing programmers to think at a higher
level of design.
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we cannot
add features if it means breaking the portion of the API corresponding
to historical curses versions.
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives.
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also
capture BSD's.
More importantly for the future, the XSI Curses standard issued by X/Open
is explicitly and closely modeled on System V. So conformance with
System V took us most of the way to base-level XSI conformance.
The third objective (standards conformance) requires that it be easy to
condition source code using ncurses so that the absence of nonstandard
extensions does not break the code.
Accordingly, we have a policy of associating with each nonstandard extension
a feature macro, so that ncurses client code can use this macro to condition
in or out the code that requires the ncurses extension.
For example, there is a macro NCURSES_MOUSE_VERSION which XSI Curses
does not define, but which is defined in the ncurses library header.
You can use this to condition the calls to the mouse API calls.
Code written for ncurses may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible select(2) call.
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible.
We encourage developers to support OS-specific optimizations and methods
not available under POSIX/ANSI, provided only that:
All such code is properly conditioned so the build process does not
attempt to compile it under a plain ANSI/POSIX environment.
Adding such implementation methods does not introduce incompatibilities
in the ncurses API between platforms.
We use GNU autoconf(1) as a tool to deal with portability issues.
The right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new feature
macro, which you then use to condition your code.
Maintain package-internal files in plain text.
The expected viewer for them more(1) or an editor window; there's
no point in elaborate mark-up.
Mark up manual pages in the man macros. These have to be viewable
through traditional man(1) programs.
Write everything else in HTML.
When in doubt, HTMLize a master and use lynx(1) to generate
plain ASCII (as we do for the announcement document).
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if youA>
*
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
-->
A Hacker's Guide to Ncurses Internals
This document is a hacker's tour of the ncurses library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or improving the
package.
The objective of the ncurses package is to provide a free software API for
character-cell terminals and terminal emulators with the following
characteristics:
Source-compatible with historical curses implementations (including
the original BSD curses and System V curses.
Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
Featureful -- should eliminate as much of the drudgery of C interface
programming as possible, freeing programmers to think at a higher
level of design.
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we cannot
add features if it means breaking the portion of the API corresponding
to historical curses versions.
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives.
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also
capture BSD's.
More importantly for the future, the XSI Curses standard issued by X/Open
is explicitly and closely modeled on System V. So conformance with
System V took us most of the way to base-level XSI conformance.
The third objective (standards conformance) requires that it be easy to
condition source code using ncurses so that the absence of nonstandard
extensions does not break the code.
Accordingly, we have a policy of associating with each nonstandard extension
a feature macro, so that ncurses client code can use this macro to condition
in or out the code that requires the ncurses extension.
For example, there is a macro NCURSES_MOUSE_VERSION which XSI Curses
does not define, but which is defined in the ncurses library header.
You can use this to condition the calls to the mouse API calls.
Code written for ncurses may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible select(2) call.
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible.
We encourage developers to support OS-specific optimizations and methods
not available under POSIX/ANSI, provided only that:
All such code is properly conditioned so the build process does not
attempt to compile it under a plain ANSI/POSIX environment.
Adding such implementation methods does not introduce incompatibilities
in the ncurses API between platforms.
We use GNU autoconf(1) as a tool to deal with portability issues.
The right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new feature
macro, which you then use to condition your code.
Maintain package-internal files in plain text.
The expected viewer for them more(1) or an editor window; there's
no point in elaborate mark-up.
Mark up manual pages in the man macros. These have to be viewable
through traditional man(1) programs.
Write everything else in HTML.
When in doubt, HTMLize a master and use lynx(1) to generate
plain ASCII (as we do for the announcement document).
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if youA>
*
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
-->
A Hacker's Guide to Ncurses Internals
This document is a hacker's tour of the ncurses library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or improving the
package.
The objective of the ncurses package is to provide a free software API for
character-cell terminals and terminal emulators with the following
characteristics:
Source-compatible with historical curses implementations (including
the original BSD curses and System V curses.
Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
Featureful -- should eliminate as much of the drudgery of C interface
programming as possible, freeing programmers to think at a higher
level of design.
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we cannot
add features if it means breaking the portion of the API corresponding
to historical curses versions.
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives.
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also
capture BSD's.
More importantly for the future, the XSI Curses standard issued by X/Open
is explicitly and closely modeled on System V. So conformance with
System V took us most of the way to base-level XSI conformance.
The third objective (standards conformance) requires that it be easy to
condition source code using ncurses so that the absence of nonstandard
extensions does not break the code.
Accordingly, we have a policy of associating with each nonstandard extension
a feature macro, so that ncurses client code can use this macro to condition
in or out the code that requires the ncurses extension.
For example, there is a macro NCURSES_MOUSE_VERSION which XSI Curses
does not define, but which is defined in the ncurses library header.
You can use this to condition the calls to the mouse API calls.
Code written for ncurses may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible select(2) call.
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible.
We encourage developers to support OS-specific optimizations and methods
not available under POSIX/ANSI, provided only that:
All such code is properly conditioned so the build process does not
attempt to compile it under a plain ANSI/POSIX environment.
Adding such implementation methods does not introduce incompatibilities
in the ncurses API between platforms.
We use GNU autoconf(1) as a tool to deal with portability issues.
The right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new feature
macro, which you then use to condition your code.
Maintain package-internal files in plain text.
The expected viewer for them more(1) or an editor window; there's
no point in elaborate mark-up.
Mark up manual pages in the man macros. These have to be viewable
through traditional man(1) programs.
Write everything else in HTML.
When in doubt, HTMLize a master and use lynx(1) to generate
plain ASCII (as we do for the announcement document).
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if youA>
*
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
-->
A Hacker's Guide to Ncurses Internals