./test/dots_curses.c
./test/dots_mvcur.c
./test/dots_termcap.c
+./test/dots_xcurses.c
./test/echochar.c
./test/edit_field.c
./test/edit_field.h
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2966 2017/10/07 23:37:31 tom Exp $
+-- $Id: NEWS,v 1.2975 2017/10/14 23:49:52 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
+20171014
+ + minor cleanup to test/view.c:
+ + eliminate "-n" option by simply reading the whole file.
+ + implement page up/down commands.
+ + add check in tput for init/reset operands to ensure those use a
+ terminal.
+ + improve manual pages which discuss chtype, cchar_t types and the
+ attribute values which can be stored in those types.
+ + correct array-index when parsing "-T" command-line option in tabs
+ program.
+ + modify demo_new_pair.c to pass extended pairs to setcchar().
+ + add test/dots_xcurses.c to illustrate a different approach used for
+ extended colors which can be contrasted with dots_curses.c.
+ + add a check in tic to note when a description uses non-mandatory
+ delays without xon_xoff. This is not an error, but some descriptions
+ for a terminal emulator may use the combination incorrectly.
+
20171007
+ modify "-T" option of clear and tput to call use_tioctl() to obtain
the operating system's notion of the screensize if possible.
-5:0:9 6.0 20171007
+5:0:9 6.0 20171014
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: dist.mk,v 1.1186 2017/10/02 01:01:40 tom Exp $
+# $Id: dist.mk,v 1.1187 2017/10/08 23:38:02 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 6
NCURSES_MINOR = 0
-NCURSES_PATCH = 20171007
+NCURSES_PATCH = 20171014
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
- * @Id: curs_attr.3x,v 1.53 2017/03/28 23:31:39 tom Exp @
+ * @Id: curs_attr.3x,v 1.60 2017/10/14 20:01:13 tom Exp @
+ * ---------------------------------------------------------------------------
* attr_get
* .br
* .br
* ---------------------------------------------------------------------------
* ---------------------------------------------------------------------------
* ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
+ * ---------------------------------------------------------------------------
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
support more than 256 color pairs.
+</PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
+ X/Open Curses is largely based on SVr4 curses, adding support for
+ "wide-characters" (not specific to Unicode). Some of the X/Open dif-
+ ferences from SVr4 curses address the way video attributes can be ap-
+ plied to wide-characters. But aside from that, <STRONG>attrset</STRONG> and <STRONG>attr_set</STRONG>
+ are similar. SVr4 curses provided the basic features for manipulating
+ video attributes. However, earlier versions of curses provided a part
+ of these features.
+
+ As seen in 2.8BSD, curses assumed 7-bit characters, using the eighth
+ bit of a byte to represent the <EM>standout</EM> feature (often implemented as
+ bold and/or reverse video). The BSD curses library provided functions
+ <STRONG>standout</STRONG> and <STRONG>standend</STRONG> which were carried along into X/Open Curses due
+ to their pervasive use in legacy applications.
+
+ Some terminals in the 1980s could support a variety of video at-
+ tributes, although the BSD curses library could do nothing with those.
+ System V (1983) provided an improved curses library. It defined the <STRONG>A_</STRONG>
+ symbols for use by applications to manipulate the other attributes.
+ There are few useful references for the chronology.
+
+ Goodheart's book <EM>UNIX</EM> <EM>Curses</EM> <EM>Explained</EM> (1991) describes SVr3 (1987),
+ commenting on several functions:
+
+ <STRONG>o</STRONG> the <STRONG>attron</STRONG>, <STRONG>attroff</STRONG>, <STRONG>attrset</STRONG> functions (and most of the functions
+ found in SVr4 but not in BSD curses) were introduced by System V,
+
+ <STRONG>o</STRONG> the alternate character set feature with <STRONG>A_ALTCHARSET</STRONG> was added in
+ SVr2 and improved in SVr3 (by adding <STRONG>acs_map[]</STRONG>),
+
+ <STRONG>o</STRONG> <STRONG>start_color</STRONG> and related color-functions were introduced by System
+ V.3.2,
+
+ <STRONG>o</STRONG> pads, soft-keys were added in SVr3, and
+
+ Goodheart did not mention the background character or the <STRONG>cchar_t</STRONG> type.
+ Those are respectively SVr4 and X/Open features. He did mention the <STRONG>A_</STRONG>
+ constants, but did not indicate their values. Those were not the same
+ in different systems, even for those marked as System V.
+
+ Different Unix systems used different sizes for the bit-fields in
+ <STRONG>chtype</STRONG> for <EM>characters</EM> and <EM>colors</EM>, and took into account the different
+ integer sizes (32-bit versus 64-bit).
+
+ This table showing the number of bits for <STRONG>A_COLOR</STRONG> and <STRONG>A_CHARTEXT</STRONG> was
+ gleaned from the curses header files for various operating systems and
+ architectures. The inferred architecture and notes reflect the format
+ and size of the defined constants as well as clues such as the alter-
+ nate character set implementation. A 32-bit library can be used on a
+ 64-bit system, but not necessarily the reverse.
+
+ <EM>Year</EM> <EM>System</EM> <EM>Arch</EM> <EM>Color</EM> <EM>Char</EM> <EM>Notes</EM>
+ ----------------------------------------------------------------
+ 1992 Solaris 5.2 32 6 17 SVr4 curses
+ 1992 HPUX 9 32 no 8 SVr2 curses
+ 1992 AIX 3.2 32 no 23 SVr2 curses
+ 1994 OSF/1 r3 32 no 23 SVr2 curses
+ 1995 HP-UX 10.00 32 6 16 SVr3 "curses_colr"
+ 1995 HP-UX 10.00 32 6 8 SVr4, X/Open curses
+ 1995 Solaris 5.4 32/64 7 16 X/Open curses
+ 1996 AIX 4.2 32 7 16 X/Open curses
+ 1996 OSF/1 r4 32 6 16 X/Open curses
+ 1997 HP-UX 11.00 32 6 8 X/Open curses
+ 2000 U/Win 32/64 7/31 16 uses <STRONG>chtype</STRONG>
+
+ Notes:
+
+ Regarding HP-UX,
+
+ <STRONG>o</STRONG> HP-UX 10.20 (1996) added support for 64-bit PA-RISC processors
+ in 1996.
+
+ <STRONG>o</STRONG> HP-UX 10.30 (1997) marked "curses_colr" obsolete. That version
+ of curses was dropped with HP-UX 11.30 in 2006.
+
+ Regarding OSF/1 (and Tru64),
+
+ <STRONG>o</STRONG> These used 64-bit hardware. Like ncurses, the OSF/1 curses in-
+ terface is not customized for 32-bit and 64-bit versions.
+
+ <STRONG>o</STRONG> Unlike other systems which evolved from AT&T code, OSF/1 provid-
+ ed a new implementation for X/Open curses.
+
+ Regarding Solaris,
+
+ <STRONG>o</STRONG> The initial release of Solaris was in 1992.
+
+ <STRONG>o</STRONG> The <EM>xpg4</EM> (X/Open) curses was developed by MKS from 1990 to 1995.
+ Sun's copyright began in 1996.
+
+ <STRONG>o</STRONG> Sun updated the X/Open curses interface after 64-bit support was
+ introduced in 1997, but did not modify the SVr4 curses inter-
+ face.
+
+ Regarding U/Win,
+
+ <STRONG>o</STRONG> Development of the curses library began in 1991, stopped in
+ 2000.
+
+ <STRONG>o</STRONG> Color support was added in 1998.
+
+ <STRONG>o</STRONG> The library uses only <STRONG>chtype</STRONG> (no <STRONG>cchar_t</STRONG>).
+
+ Once X/Open curses was adopted in the mid-1990s, the constraint of a
+ 32-bit interface with many colors and wide-characters for <STRONG>chtype</STRONG> became
+ a moot point. The <STRONG>cchar_t</STRONG> structure (whose size and members are not
+ specified in X/Open Curses) could be extended as needed.
+
+ Other interfaces are rarely used now:
+
+ <STRONG>o</STRONG> BSD curses was improved slightly in 1993/1994 using Keith Bostic's
+ modification to make the library 8-bit clean for <STRONG>nvi</STRONG>. He moved
+ <EM>standout</EM> attribute to a structure member.
+
+ The resulting 4.4BSD curses was replaced by ncurses over the next
+ ten years.
+
+ <STRONG>o</STRONG> U/Win is rarely used now.
+
+
</PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
This implementation provides the <STRONG>A_ITALIC</STRONG> attribute for terminals which
have the <STRONG>enter_italics_mode</STRONG> (<STRONG>sitm</STRONG>) and <STRONG>exit_italics_mode</STRONG> (<STRONG>ritm</STRONG>) capa-
<STRONG>WA_BOLD</STRONG> Extra bright or bold
<STRONG>WA_ALTCHARSET</STRONG> Alternate character set
- The XSI curses standard specifies that each pair of corresponding <STRONG>A_</STRONG>
- and <STRONG>WA_</STRONG>-using functions operates on the same current-highlight informa-
- tion.
+ XSI curses does not assign values to these symbols, nor does it state
+ whether or not they are related to the similarly-named A_NORMAL, etc.:
+
+ <STRONG>o</STRONG> The XSI curses standard specifies that each pair of corresponding
+ <STRONG>A_</STRONG> and <STRONG>WA_</STRONG>-using functions operates on the same current-highlight
+ information.
+
+ <STRONG>o</STRONG> However, in some implementations, those symbols have unrelated val-
+ ues.
+
+ For example, the Solaris <EM>xpg4</EM> (X/Open) curses declares <STRONG>attr_t</STRONG> to be
+ an unsigned short integer (16-bits), while <STRONG>chtype</STRONG> is a unsigned in-
+ teger (32-bits). The <STRONG>WA_</STRONG> symbols in this case are different from
+ the <STRONG>A_</STRONG> symbols because they are used for a smaller datatype which
+ does not represent <STRONG>A_CHARTEXT</STRONG> or <STRONG>A_COLOR</STRONG>.
+
+ In this implementation (as in many others), the values happen to be
+ the same because it simplifies copying information between <STRONG>chtype</STRONG>
+ and <STRONG>cchar_t</STRONG> variables.
The XSI standard extended conformance level adds new highlights <STRONG>A_HORI-</STRONG>
<STRONG>ZONTAL</STRONG>, <STRONG>A_LEFT</STRONG>, <STRONG>A_LOW</STRONG>, <STRONG>A_RIGHT</STRONG>, <STRONG>A_TOP</STRONG>, <STRONG>A_VERTICAL</STRONG> (and corresponding
</li>
<li><a href="#h2-VIDEO-ATTRIBUTES">VIDEO ATTRIBUTES</a></li>
<li><a href="#h2-NOTES">NOTES</a></li>
+<li><a href="#h2-HISTORY">HISTORY</a></li>
<li><a href="#h2-EXTENSIONS">EXTENSIONS</a></li>
<li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
<li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
<!--
* t
****************************************************************************
- * Copyright (c) 1998-2006,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
- * @Id: curs_inch.3x,v 1.17 2010/12/04 18:36:44 tom Exp @
+ * @Id: curs_inch.3x,v 1.18 2017/10/14 19:14:47 tom Exp @
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<STRONG>wmove</STRONG>, and return an error if the position is outside the window, or if
the window pointer is null.
+ The <STRONG>winch</STRONG> function does not return an error if the window contains
+ characters larger than 8-bits (255). Only the low-order 8 bits of the
+ character are used by <STRONG>winch</STRONG>.
+
</PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
Note that all of these routines may be macros.
</PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
These functions are described in the XSI Curses standard, Issue 4.
+ Very old systems (before standardization) provide a different function
+ with the same name:
+
+ <STRONG>o</STRONG> The <STRONG>winch</STRONG> function was part of the original BSD curses library,
+ which stored a 7-bit character combined with the <EM>standout</EM>
+ attribute.
+
+ In BSD curses, <STRONG>winch</STRONG> returned only the character (as an integer)
+ with the <EM>standout</EM> attribute removed.
+
+ <STRONG>o</STRONG> System V curses added support for several video attributes which
+ could be combined with characters in the window.
+
+ Reflecting this improvment, the function was altered to return the
+ character combined with all video attributes in a <STRONG>chtype</STRONG> value.
+
+ X/Open Curses does not specify the size and layout of attributes, color
+ and character values in <STRONG>chtype</STRONG>; it is implementation-dependent. This
+ implementation uses 8 bits for character values. An application using
+ more bits, e.g., a Unicode value, should use the wide-character equiva-
+ lents to these functions.
+
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
- <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>.
+ <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>
+ gives an overview of the WINDOW and <STRONG>chtype</STRONG> data types.
+
+ <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
+ goes into more detail, pointing out portability problems and con-
+ straints on the use of <STRONG>chtype</STRONG> for returning window information.
- Comparable functions in the wide-character (ncursesw) library are
- described in <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>.
+ <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>
+ describes comparable functions for the wide-character (ncursesw)
+ library.
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> and related pages whose names begin "form_" for detailed
descriptions of the entry points.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
http://invisible-island.net/ncurses/tctest.html
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> and related pages whose names begin "menu_" for detailed
descriptions of the entry points.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
method of updating character screens with reasonable optimization.
This implementation is "new curses" (ncurses) and is the approved
replacement for 4.4BSD classic curses, which has been discontinued.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
The <STRONG>ncurses</STRONG> library emulates the curses library of System V Release 4
UNIX, and XPG4 (X/Open Portability Guide) curses (also known as XSI
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>,
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
<EM>Terminfo</EM> describes terminals by giving a set of capabilities which they
have, by specifying how to perform screen operations, and by specifying
padding requirements and initialization sequences. This describes
- <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H3><a name="h3-Terminfo-Entry-Syntax">Terminfo Entry Syntax</a></H3><PRE>
<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>, <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>, <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,
<STRONG><A HREF="term.5.html">term(5)</A></STRONG>. <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
<STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>, <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG>ter-</STRONG>
<STRONG><A HREF="terminfo.5.html">minfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>, <STRONG>stty(1)</STRONG>, <STRONG><A HREF="tabs.1.html">tabs(1)</A></STRONG>, <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>, <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
<STRONG>csh(1)</STRONG>, <STRONG>sh(1)</STRONG>, <STRONG>stty(1)</STRONG>, <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>, <STRONG>tty(4)</STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>,
<STRONG>ttys(5)</STRONG>, <STRONG>environ(7)</STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171007).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20171014).
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $Id: curs_attr.3x,v 1.53 2017/03/28 23:31:39 tom Exp $
+.\" $Id: curs_attr.3x,v 1.60 2017/10/14 20:01:13 tom Exp $
.TH curs_attr 3X ""
+.ie \n(.g .ds `` \(lq
+.el .ds `` ``
+.ie \n(.g .ds '' \(rq
+.el .ds '' ''
.de bP
.IP \(bu 4
..
.na
.hy 0
+.\" ---------------------------------------------------------------------------
.SH NAME
.\" attr_get
\fBattr_get\fR,
\fBwstandout\fR \- \fBcurses\fR character and window attribute control routines
.ad
.hy
+.\" ---------------------------------------------------------------------------
.SH SYNOPSIS
\fB#include <curses.h>\fR
.sp
\fBint standout(void);\fR
.br
\fBint wstandout(WINDOW *\fP\fIwin\fP\fB);\fR
+.\" ---------------------------------------------------------------------------
.SH DESCRIPTION
.PP
These routines manipulate the current attributes of the named window,
The return values of many of these routines are not meaningful (they are
implemented as macro-expanded assignments and simply return their argument).
The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
+.\" ---------------------------------------------------------------------------
.SH NOTES
These functions may be macros:
.sp
value directly.
However, ncurses ABI 4 and 5 simply OR this value within the alternate functions.
You must use ncurses ABI 6 to support more than 256 color pairs.
+.\" ---------------------------------------------------------------------------
+.SH HISTORY
+X/Open Curses is largely based on SVr4 curses,
+adding support for \*(``wide-characters\*('' (not specific to Unicode).
+Some of the X/Open differences from SVr4 curses address the way
+video attributes can be applied to wide-characters.
+But aside from that, \fBattrset\fP and \fBattr_set\fP are similar.
+SVr4 curses provided the basic features for manipulating video attributes.
+However, earlier versions of curses provided a part of these features.
+.PP
+As seen in 2.8BSD, curses assumed 7-bit characters,
+using the eighth bit of a byte to represent the \fIstandout\fP
+feature (often implemented as bold and/or reverse video).
+The BSD curses library provided functions \fBstandout\fP and \fBstandend\fP
+which were carried along into X/Open Curses due to their pervasive use
+in legacy applications.
+.PP
+Some terminals in the 1980s could support a variety of video attributes,
+although the BSD curses library could do nothing with those.
+System V (1983) provided an improved curses library.
+It defined the \fBA_\fP symbols for use by applications to manipulate the
+other attributes.
+There are few useful references for the chronology.
+.PP
+Goodheart's book
+\fIUNIX Curses Explained\fP (1991) describes SVr3 (1987),
+commenting on several functions:
+.bP
+the \fBattron\fP, \fBattroff\fP, \fBattrset\fP functions
+(and most of the functions found in SVr4 but not in BSD curses) were
+introduced by System V,
+.bP
+the alternate character set feature with \fBA_ALTCHARSET\fP was
+added in SVr2 and improved in SVr3 (by adding \fBacs_map[]\fP),
+.bP
+\fBstart_color\fP and related color-functions were introduced by System V.3.2,
+.bP
+pads, soft-keys were added in SVr3, and
+.PP
+Goodheart did not mention the background character or the \fBcchar_t\fP type.
+Those are respectively SVr4 and X/Open features.
+He did mention the \fBA_\fP constants, but did not indicate their values.
+Those were not the same in different systems,
+even for those marked as System V.
+.PP
+Different Unix systems used different sizes for the bit-fields in \fBchtype\fP
+for \fIcharacters\fP and \fIcolors\fP, and took into account the different
+integer sizes (32-bit versus 64-bit).
+.PP
+This table showing the number of bits for \fBA_COLOR\fP
+and \fBA_CHARTEXT\fP
+was gleaned from the curses header files for
+various operating systems and architectures.
+The inferred architecture and notes reflect
+the format and size of the defined constants
+as well as clues such as the alternate character set implementation.
+A 32-bit library can be used on a 64-bit system,
+but not necessarily the reverse.
+.RS
+.TS
+l l l l l l
+_ _ _ _ _ _
+l l l l l l .
+\fIYear\fR \fISystem\fR \fIArch\fP \fIColor\fR \fIChar\fR \fINotes\fR
+1992 Solaris 5.2 32 6 17 SVr4 curses
+1992 HPUX 9 32 no 8 SVr2 curses
+1992 AIX 3.2 32 no 23 SVr2 curses
+1994 OSF/1 r3 32 no 23 SVr2 curses
+1995 HP-UX 10.00 32 6 16 SVr3 \*(``curses_colr\*(''
+1995 HP-UX 10.00 32 6 8 SVr4, X/Open curses
+1995 Solaris 5.4 32/64 7 16 X/Open curses
+1996 AIX 4.2 32 7 16 X/Open curses
+1996 OSF/1 r4 32 6 16 X/Open curses
+1997 HP-UX 11.00 32 6 8 X/Open curses
+2000 U/Win 32/64 7/31 16 uses \fBchtype\fP
+.TE
+.RE
+.PP
+Notes:
+.RS 3
+.PP
+Regarding HP-UX,
+.bP
+HP-UX 10.20 (1996) added support for 64-bit PA-RISC processors in 1996.
+.bP
+HP-UX 10.30 (1997) marked \*(``curses_colr\*('' obsolete.
+That version of curses was dropped with HP-UX 11.30 in 2006.
+.PP
+Regarding OSF/1 (and Tru64),
+.bP
+These used 64-bit hardware.
+Like ncurses, the OSF/1 curses interface is not customized for 32-bit
+and 64-bit versions.
+.bP
+Unlike other systems which evolved from AT&T code,
+OSF/1 provided a new implementation for X/Open curses.
+.PP
+Regarding Solaris,
+.bP
+The initial release of Solaris was in 1992.
+.bP
+The \fIxpg4\fP (X/Open) curses was developed by MKS from 1990 to 1995.
+Sun's copyright began in 1996.
+.bP
+Sun updated the X/Open curses interface after 64-bit support was introduced in 1997,
+but did not modify the SVr4 curses interface.
+.PP
+Regarding U/Win,
+.bP
+Development of the curses library began in 1991, stopped in 2000.
+.bP
+Color support was added in 1998.
+.bP
+The library uses only \fBchtype\fP (no \fBcchar_t\fP).
+.RE
+.PP
+Once X/Open curses was adopted in the mid-1990s, the constraint of
+a 32-bit interface with many colors and wide-characters for \fBchtype\fP
+became a moot point. The \fBcchar_t\fP structure (whose size and
+members are not specified in X/Open Curses) could be extended as needed.
+.PP
+Other interfaces are rarely used now:
+.bP
+BSD curses was improved slightly in 1993/1994 using Keith Bostic's
+modification to make the library 8-bit clean for \fBnvi\fP.
+He moved \fIstandout\fP attribute to a structure member.
+.IP
+The resulting 4.4BSD curses was replaced by ncurses over the next ten years.
+.bP
+U/Win is rarely used now.
+.\" ---------------------------------------------------------------------------
.SH EXTENSIONS
.PP
This implementation provides the \fBA_ITALIC\fP attribute for terminals
but do not manipulate color,
e.g., \fBwattr_on\fP and \fBwattr_off\fP
are not used by this implementation except to check that they are \fBNULL\fP.
+.\" ---------------------------------------------------------------------------
.SH PORTABILITY
These functions are supported in the XSI Curses standard, Issue 4.
The standard defined the dedicated type for highlights,
.TE
.RE
.PP
+XSI curses does not assign values to these symbols,
+nor does it state whether or not they are related to the
+similarly-named A_NORMAL, etc.:
+.bP
The XSI curses standard specifies that each pair of corresponding \fBA_\fR
and \fBWA_\fR-using functions operates on the same current-highlight
information.
+.bP
+However, in some implementations, those symbols have unrelated values.
+.IP
+For example, the Solaris \fIxpg4\fP (X/Open) curses declares
+\fBattr_t\fP to be an unsigned short integer (16-bits),
+while \fBchtype\fP is a unsigned integer (32-bits).
+The \fBWA_\fP symbols in this case are different from the \fBA_\fP symbols
+because they are used for a smaller datatype which does not
+represent \fBA_CHARTEXT\fP or \fBA_COLOR\fP.
+.IP
+In this implementation (as in many others), the values happen to be
+the same because it simplifies copying information between
+\fBchtype\fP and \fBcchar_t\fP variables.
.PP
The XSI standard extended conformance level adds new highlights
\fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
As of August 2013,
no known terminal provides these highlights
(i.e., via the \fBsgr1\fP capability).
+.\" ---------------------------------------------------------------------------
.SH RETURN VALUE
All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
.PP
Functions with a "mv" prefix first perform a cursor movement using
\fBwmove\fP, and return an error if the position is outside the window,
or if the window pointer is null.
+.\" ---------------------------------------------------------------------------
.SH SEE ALSO
.na
\fBcurses\fR(3X),
'\" t
.\"***************************************************************************
-.\" Copyright (c) 1998-2006,2010 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2010,2017 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $Id: curs_inch.3x,v 1.17 2010/12/04 18:36:44 tom Exp $
+.\" $Id: curs_inch.3x,v 1.18 2017/10/14 19:14:47 tom Exp $
.TH curs_inch 3X ""
+.de bP
+.IP \(bu 4
+..
.SH NAME
\fBinch\fR,
\fBwinch\fR,
Functions with a "mv" prefix first perform a cursor movement using
\fBwmove\fP, and return an error if the position is outside the window,
or if the window pointer is null.
+.PP
+The \fBwinch\fP function does not return an error if the window contains
+characters larger than 8-bits (255).
+Only the low-order 8 bits of the character are used by \fBwinch\fP.
.SH NOTES
Note that all of these routines may be macros.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4.
-.SH SEE ALSO
-\fBcurses\fR(3X).
.PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_in_wch\fR(3X).
+Very old systems (before standardization) provide a different function
+with the same name:
+.bP
+The \fBwinch\fP function was part of the original BSD curses library,
+which stored a 7-bit character combined with the \fIstandout\fP attribute.
+.IP
+In BSD curses, \fBwinch\fP returned only the character (as an integer)
+with the \fIstandout\fP attribute removed.
+.bP
+System V curses added support for several video attributes which
+could be combined with characters in the window.
+.IP
+Reflecting this improvment, the function was altered to return the
+character combined with all video attributes in a \fBchtype\fP value.
+.PP
+X/Open Curses does not specify
+the size and layout of attributes, color and character values in
+\fBchtype\fP; it is implementation-dependent.
+This implementation uses 8 bits for character values.
+An application using more bits, e.g., a Unicode value,
+should use the wide-character equivalents to these functions.
+.SH SEE ALSO
+.TP 5
+\fBcurses\fR(3X)
+gives an overview of the WINDOW and \fBchtype\fP data types.
+.TP 5
+\fBcurs_attr\fR(3X)
+goes into more detail, pointing out portability problems and
+constraints on the use of \fBchtype\fP for returning window information.
+.TP 5
+\fBcurs_in_wch\fR(3X)
+describes comparable functions for the wide-character (ncursesw) library.
-ncurses6 (6.0+20171007) unstable; urgency=low
+ncurses6 (6.0+20171014) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 01 Oct 2017 21:01:40 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 08 Oct 2017 19:38:02 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.0+20171007) unstable; urgency=low
+ncurses6 (6.0+20171014) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 01 Oct 2017 21:01:40 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 08 Oct 2017 19:38:02 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.0+20171007) unstable; urgency=low
+ncurses6 (6.0+20171014) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 01 Oct 2017 21:01:40 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 08 Oct 2017 19:38:02 -0400
ncurses6 (5.9-20120608) unstable; urgency=low
-; $Id: mingw-ncurses.nsi,v 1.234 2017/10/02 01:01:40 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.235 2017/10/08 23:38:02 tom Exp $\r
\r
; TODO add examples\r
; TODO bump ABI to 6\r
!define VERSION_MAJOR "6"\r
!define VERSION_MINOR "0"\r
!define VERSION_YYYY "2017"\r
-!define VERSION_MMDD "1007"\r
+!define VERSION_MMDD "1014"\r
!define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
\r
!define MY_ABI "5"\r
Summary: shared libraries for terminal handling
Name: mingw32-ncurses6
Version: 6.0
-Release: 20171007
+Release: 20171014
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
Summary: shared libraries for terminal handling
Name: ncurses6
Version: 6.0
-Release: 20171007
+Release: 20171014
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
* Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
- * $Id: progs.priv.h,v 1.45 2017/10/07 20:42:10 tom Exp $
+ * $Id: progs.priv.h,v 1.46 2017/10/09 00:30:38 tom Exp $
*
* progs.priv.h
*
#endif
#endif
+#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
+
/* error-returns for tput */
#define ErrUsage 2
#define ErrTermType 3
#include <progs.priv.h>
#include <tty_settings.h>
-MODULE_ID("$Id: tabs.c,v 1.40 2017/10/07 19:34:58 tom Exp $")
+MODULE_ID("$Id: tabs.c,v 1.41 2017/10/12 22:42:08 tom Exp $")
static void usage(void) GCC_NORETURN;
if (*++option != '\0') {
term_name = option;
} else {
- term_name = argv[n++];
+ term_name = argv[n];
option--;
}
option += ((int) strlen(option)) - 1;
#include <parametrized.h>
#include <transform.h>
-MODULE_ID("$Id: tic.c,v 1.244 2017/09/20 00:39:37 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.247 2017/10/09 15:16:15 tom Exp $")
#define STDIN_NAME "<stdin>"
*target = (*target * 10) + (source - '0');
}
-#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
-
int
main(int argc, char *argv[])
{
}
static void
-check_delays(const char *name, const char *value)
+check_delays(TERMTYPE2 *tp, const char *name, const char *value)
{
const char *p, *q;
const char *first = 0;
_nc_warning("function-key %s has delay", name);
} else if (proportional && !line_capability(name)) {
_nc_warning("non-line capability using proportional delay: %s", name);
+ } else if (!xon_xoff &&
+ !mandatory &&
+ strchr(_nc_first_name(tp->term_names), '+') == 0) {
+ _nc_warning("%s in %s is used since no xon/xoff",
+ (proportional
+ ? "proportional delay"
+ : "delay"),
+ name);
}
} else {
p = q - 1; /* restart scan */
parametrized[j] > 0) {
check_params(tp, name, a, (j >= STRCOUNT));
}
- check_delays(ExtStrname(tp, (int) j, strnames), a);
+ check_delays(tp, ExtStrname(tp, (int) j, strnames), a);
if (capdump) {
check_infotocap(tp, (int) j, a);
}
#include <transform.h>
#include <tty_settings.h>
-MODULE_ID("$Id: tput.c,v 1.77 2017/10/07 23:51:01 tom Exp $")
+MODULE_ID("$Id: tput.c,v 1.78 2017/10/14 20:46:43 tom Exp $")
#define PUTS(s) fputs(s, stdout)
}
is_alias = (is_clear || is_reset || is_init);
- need_tty = (is_reset || is_init);
+ need_tty = ((is_reset || is_init) ||
+ (optind < argc &&
+ (!strcmp(argv[optind], "reset") ||
+ !strcmp(argv[optind], "init"))));
/*
* Modify the argument list to omit the options we processed.
* authorization. *
****************************************************************************/
/*
- * $Id: demo_new_pair.c,v 1.17 2017/09/28 23:17:56 tom Exp $
+ * $Id: demo_new_pair.c,v 1.18 2017/10/11 22:16:14 tom Exp $
*
* Demonstrate the alloc_pair() function.
*/
break;
wch[0] = use_wide ? 0xff03 : '#';
wch[1] = 0;
- setcchar(&temp, wch, my_attrs, (short) my_pair, NULL);
+ setcchar(&temp, wch, my_attrs,
+ (short) my_pair,
+ (use_init ? NULL : (void *) &my_pair));
/*
* At the end of a page, move the cursor to the home position.
*/
/*
* Author: Thomas E. Dickey <dickey@clark.net> 1999
*
- * $Id: dots.c,v 1.26 2017/09/30 17:55:22 tom Exp $
+ * $Id: dots.c,v 1.28 2017/10/11 08:15:27 tom Exp $
*
* A simple demo of the terminfo interface.
*/
#include <time.h>
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static bool interrupted = FALSE;
static long total_chars = 0;
static time_t started;
static bool
outs(const char *s)
{
- if (valid(s)) {
+ if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
outs(clear_screen);
outs(cursor_normal);
- printf("\n\n%ld total chars, rate %.2f/sec\n",
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
outs(cursor_invisible);
my_colors = max_colors;
if (my_colors > 1) {
- if (!valid(set_a_foreground)
- || !valid(set_a_background)
- || (!valid(orig_colors) && !valid(orig_pair)))
+ if (!VALID_STRING(set_a_foreground)
+ || !VALID_STRING(set_a_background)
+ || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
my_colors = -1;
}
tputs(tparm2(set_a_background, z), 1, outc);
napms(1);
}
- } else if (valid(exit_attribute_mode)
- && valid(enter_reverse_mode)) {
+ } else if (VALID_STRING(exit_attribute_mode)
+ && VALID_STRING(enter_reverse_mode)) {
if (ranf() <= 0.01) {
outs((ranf() > 0.6)
? enter_reverse_mode
/*
* Author: Thomas E. Dickey
*
- * $Id: dots_curses.c,v 1.5 2017/09/30 15:41:17 tom Exp $
+ * $Id: dots_curses.c,v 1.7 2017/10/11 08:16:33 tom Exp $
*
* A simple demo of the curses interface used for comparison with termcap.
*/
#include <time.h>
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static bool interrupted = FALSE;
static long total_chars = 0;
static time_t started;
{
endwin();
- printf("\n\n%ld total chars, rate %.2f/sec\n",
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
/*
* Author: Thomas E. Dickey - 2007
*
- * $Id: dots_mvcur.c,v 1.13 2017/09/30 21:34:15 tom Exp $
+ * $Id: dots_mvcur.c,v 1.15 2017/10/11 08:15:46 tom Exp $
*
* A simple demo of the terminfo interface, and mvcur.
*/
#include <time.h>
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static bool interrupted = FALSE;
static long total_chars = 0;
static time_t started;
static bool
outs(const char *s)
{
- if (valid(s)) {
+ if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
outs(clear_screen);
outs(cursor_normal);
- printf("\n\n%ld total chars, rate %.2f/sec\n",
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
outs(cursor_invisible);
my_colors = max_colors;
if (my_colors > 1) {
- if (!valid(set_a_foreground)
- || !valid(set_a_background)
- || (!valid(orig_colors) && !valid(orig_pair)))
+ if (!VALID_STRING(set_a_foreground)
+ || !VALID_STRING(set_a_background)
+ || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
my_colors = -1;
}
tputs(tparm2(set_a_background, z), 1, outc);
napms(1);
}
- } else if (valid(exit_attribute_mode)
- && valid(enter_reverse_mode)) {
+ } else if (VALID_STRING(exit_attribute_mode)
+ && VALID_STRING(enter_reverse_mode)) {
if (ranf() <= 0.01) {
outs((ranf() > 0.6)
? enter_reverse_mode
/*
* Author: Thomas E. Dickey
*
- * $Id: dots_termcap.c,v 1.10 2017/09/30 17:55:22 tom Exp $
+ * $Id: dots_termcap.c,v 1.12 2017/10/11 08:15:07 tom Exp $
*
* A simple demo of the termcap interface.
*/
#include <time.h>
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static bool interrupted = FALSE;
static long total_chars = 0;
static time_t started;
static bool
outs(char *s)
{
- if (valid(s)) {
+ if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
outs(t_cl);
outs(t_ve);
- printf("\n\n%ld total chars, rate %.2f/sec\n",
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
outs(t_cl);
outs(t_vi);
if (num_colors > 1) {
- if (!valid(t_AF)
- || !valid(t_AB)
- || (!valid(t_oc) && !valid(t_op)))
+ if (!VALID_STRING(t_AF)
+ || !VALID_STRING(t_AB)
+ || (!VALID_STRING(t_oc) && !VALID_STRING(t_op)))
num_colors = -1;
}
tputs(tgoto(t_AB, 0, z), 1, outc);
my_napms(1);
}
- } else if (valid(t_me)
- && valid(t_mr)) {
+ } else if (VALID_STRING(t_me)
+ && VALID_STRING(t_mr)) {
if (ranf() <= 0.01) {
outs((ranf() > 0.6)
? t_mr
--- /dev/null
+/****************************************************************************
+ * Copyright (c) 2017 Free Software Foundation, Inc. *
+ * *
+ * 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. *
+ ****************************************************************************/
+
+/*
+ * Author: Thomas E. Dickey
+ *
+ * $Id: dots_xcurses.c,v 1.8 2017/10/12 00:20:41 tom Exp $
+ *
+ * A simple demo of the wide-curses interface used for comparison with termcap.
+ */
+#include <test.priv.h>
+
+#if !defined(__MINGW32__)
+#include <sys/time.h>
+#endif
+
+#include <time.h>
+
+#if USE_WIDEC_SUPPORT
+
+#if HAVE_ALLOC_PAIR
+#define NewPair(n) x_option ? ((void *)&(n)) : NULL
+#else
+#define NewPair(n) NULL
+#endif
+
+#define InitPair(p,fg,bg) init_pair((short) (p), (short) (fg), (short) (bg))
+
+static bool interrupted = FALSE;
+static long total_chars = 0;
+static time_t started;
+
+#ifdef NCURSES_VERSION
+static bool d_option = FALSE;
+static bool x_option = FALSE;
+#endif
+
+static void
+cleanup(void)
+{
+ endwin();
+
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
+ total_chars,
+ ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+}
+
+static void
+onsig(int n GCC_UNUSED)
+{
+ interrupted = TRUE;
+}
+
+static double
+ranf(void)
+{
+ long r = (rand() & 077777);
+ return ((double) r / 32768.);
+}
+
+static int
+mypair(int fg, int bg)
+{
+ int result;
+#if HAVE_ALLOC_PAIR
+ if (x_option) {
+ result = alloc_pair(fg, bg);
+ } else
+#endif
+ {
+ int pair = (fg * COLORS) + bg;
+ result = (pair >= COLOR_PAIRS) ? -1 : pair;
+ }
+ return result;
+}
+
+static void
+set_colors(int fg, int bg)
+{
+ int pair = mypair(fg, bg);
+ if (pair > 0) {
+ color_set((short) pair, NewPair(pair));
+ }
+}
+
+#if defined(NCURSES_VERSION)
+static void
+usage(void)
+{
+ static const char *msg[] =
+ {
+ "Usage: firework [options]"
+ ,""
+ ,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+ ," -d invoke use_default_colors()"
+#endif
+#if HAVE_ALLOC_PAIR
+ ," -x use alloc_pair() rather than init_pair()"
+#endif
+ };
+ size_t n;
+
+ for (n = 0; n < SIZEOF(msg); n++)
+ fprintf(stderr, "%s\n", msg[n]);
+
+ ExitProgram(EXIT_FAILURE);
+}
+#endif
+
+int
+main(int argc GCC_UNUSED,
+ char *argv[]GCC_UNUSED)
+{
+ int margin = 2;
+ int x, y, z, p;
+ int fg, bg, ch;
+ wchar_t wch[2];
+ int pair;
+ double r;
+ double c;
+
+#if defined(NCURSES_VERSION)
+ while ((ch = getopt(argc, argv, "dx")) != -1) {
+ switch (ch) {
+ case 'd':
+ d_option = TRUE;
+ break;
+#if HAVE_ALLOC_PAIR
+ case 'x':
+ x_option = TRUE;
+ break;
+#endif
+ default:
+ usage();
+ break;
+ }
+ }
+#endif
+
+ srand((unsigned) time(0));
+
+ InitAndCatch(initscr(), onsig);
+ if (has_colors()) {
+ start_color();
+#if HAVE_USE_DEFAULT_COLORS
+ if (d_option)
+ use_default_colors();
+#endif
+ if (x_option) {
+ ; /* nothing */
+ } else {
+ for (fg = 0; fg < COLORS; fg++) {
+ for (bg = 0; bg < COLORS; bg++) {
+ pair = mypair(fg, bg);
+ if (pair > 0) {
+ InitPair(pair, fg, bg);
+ }
+ }
+ }
+ }
+ }
+
+ r = (double) (LINES - (2 * margin));
+ c = (double) (COLS - (2 * margin));
+ started = time((time_t *) 0);
+
+ fg = COLOR_WHITE;
+ bg = COLOR_BLACK;
+ pair = 0;
+ wch[1] = 0;
+ while (!interrupted) {
+ x = (int) (c * ranf()) + margin;
+ y = (int) (r * ranf()) + margin;
+ p = (ranf() > 0.9) ? '*' : ' ';
+
+ move(y, x);
+ if (has_colors()) {
+ z = (int) (ranf() * COLORS);
+ if (ranf() > 0.01) {
+ set_colors(fg = z, bg);
+ } else {
+ set_colors(fg, bg = z);
+ napms(1);
+ }
+ } else {
+ if (ranf() <= 0.01) {
+ if (ranf() > 0.6) {
+ attr_on(WA_REVERSE, NULL);
+ } else {
+ attr_off(WA_REVERSE, NULL);
+ }
+ napms(1);
+ }
+ }
+ wch[0] = p;
+ addnwstr(wch, 1);
+ refresh();
+ ++total_chars;
+ }
+ cleanup();
+ ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+ printf("This program requires the wide-ncurses library\n");
+ ExitProgram(EXIT_FAILURE);
+}
+#endif
* authorization. *
****************************************************************************/
/*
- * $Id: echochar.c,v 1.15 2017/09/30 15:42:10 tom Exp $
+ * $Id: echochar.c,v 1.17 2017/10/11 08:16:12 tom Exp $
*
* Demonstrate the echochar function (compare to dots.c).
* Thomas Dickey - 2006/11/4
#include <time.h>
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static bool interrupted = FALSE;
static long total_chars = 0;
static time_t started;
{
exit_curses();
- printf("\n\n%ld total chars, rate %.2f/sec\n",
+ printf("\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
-# $Id: modules,v 1.64 2017/06/24 18:26:44 tom Exp $
+# $Id: modules,v 1.65 2017/10/11 08:08:41 tom Exp $
##############################################################################
# Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. #
# #
dots_curses progs $(srcdir) $(HEADER_DEPS)
dots_mvcur progs $(srcdir) $(HEADER_DEPS)
dots_termcap progs $(srcdir) $(HEADER_DEPS)
+dots_xcurses progs $(srcdir) $(HEADER_DEPS)
echochar progs $(srcdir) $(HEADER_DEPS)
edit_field progs $(srcdir) $(HEADER_DEPS) $(srcdir)/edit_field.h $(srcdir)/popup_msg.h
extended_color progs $(srcdir) $(HEADER_DEPS)
-# $Id: programs,v 1.39 2017/07/01 20:14:35 tom Exp $
+# $Id: programs,v 1.40 2017/10/11 08:08:41 tom Exp $
##############################################################################
# Copyright (c) 2006-2016,2017 Free Software Foundation, Inc. #
# #
dots_curses $(LDFLAGS_CURSES) $(LOCAL_LIBS) dots_curses
dots_mvcur $(LDFLAGS_CURSES) $(LOCAL_LIBS) dots_mvcur
dots_termcap $(LDFLAGS_TINFO) $(LOCAL_LIBS) dots_termcap
+dots_xcurses $(LDFLAGS_CURSES) $(LOCAL_LIBS) dots_xcurses
echochar $(LDFLAGS_CURSES) $(LOCAL_LIBS) echochar
extended_color $(LDFLAGS_CURSES) $(LOCAL_LIBS) extended_color
filter $(LDFLAGS_CURSES) $(LOCAL_LIBS) filter
/****************************************************************************
* Author: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $Id: test.priv.h,v 1.158 2017/09/30 17:58:37 tom Exp $ */
+/* $Id: test.priv.h,v 1.160 2017/10/12 01:00:59 tom Exp $ */
#ifndef __TEST_PRIV_H
#define __TEST_PRIV_H 1
#undef WACS_NEQUAL
#undef WACS_STERLING
-#define WACS_RARROW &(CURSES_WACS_ARRAY['+'])
-#define WACS_LARROW &(CURSES_WACS_ARRAY[','])
-#define WACS_UARROW &(CURSES_WACS_ARRAY['-'])
-#define WACS_DARROW &(CURSES_WACS_ARRAY['.'])
-#define WACS_BLOCK &(CURSES_WACS_ARRAY['0'])
-#define WACS_DIAMOND &(CURSES_WACS_ARRAY['`'])
-#define WACS_CKBOARD &(CURSES_WACS_ARRAY['a'])
-#define WACS_DEGREE &(CURSES_WACS_ARRAY['f'])
-#define WACS_PLMINUS &(CURSES_WACS_ARRAY['g'])
-#define WACS_BOARD &(CURSES_WACS_ARRAY['h'])
-#define WACS_LANTERN &(CURSES_WACS_ARRAY['i'])
-#define WACS_LRCORNER &(CURSES_WACS_ARRAY['j'])
-#define WACS_URCORNER &(CURSES_WACS_ARRAY['k'])
-#define WACS_ULCORNER &(CURSES_WACS_ARRAY['l'])
-#define WACS_LLCORNER &(CURSES_WACS_ARRAY['m'])
-#define WACS_PLUS &(CURSES_WACS_ARRAY['n'])
-#define WACS_HLINE &(CURSES_WACS_ARRAY['q'])
-#define WACS_S1 &(CURSES_WACS_ARRAY['o'])
-#define WACS_S9 &(CURSES_WACS_ARRAY['s'])
-#define WACS_LTEE &(CURSES_WACS_ARRAY['t'])
-#define WACS_RTEE &(CURSES_WACS_ARRAY['u'])
-#define WACS_BTEE &(CURSES_WACS_ARRAY['v'])
-#define WACS_TTEE &(CURSES_WACS_ARRAY['w'])
-#define WACS_VLINE &(CURSES_WACS_ARRAY['x'])
-#define WACS_BULLET &(CURSES_WACS_ARRAY['~'])
-#define WACS_S3 &(CURSES_WACS_ARRAY['p'])
-#define WACS_S7 &(CURSES_WACS_ARRAY['r'])
-#define WACS_LEQUAL &(CURSES_WACS_ARRAY['y'])
-#define WACS_GEQUAL &(CURSES_WACS_ARRAY['z'])
-#define WACS_PI &(CURSES_WACS_ARRAY['{'])
-#define WACS_NEQUAL &(CURSES_WACS_ARRAY['|'])
-#define WACS_STERLING &(CURSES_WACS_ARRAY['}'])
+#define WACS_RARROW &(CURSES_WACS_ARRAY['+'])
+#define WACS_LARROW &(CURSES_WACS_ARRAY[','])
+#define WACS_UARROW &(CURSES_WACS_ARRAY['-'])
+#define WACS_DARROW &(CURSES_WACS_ARRAY['.'])
+#define WACS_BLOCK &(CURSES_WACS_ARRAY['0'])
+#define WACS_DIAMOND &(CURSES_WACS_ARRAY['`'])
+#define WACS_CKBOARD &(CURSES_WACS_ARRAY['a'])
+#define WACS_DEGREE &(CURSES_WACS_ARRAY['f'])
+#define WACS_PLMINUS &(CURSES_WACS_ARRAY['g'])
+#define WACS_BOARD &(CURSES_WACS_ARRAY['h'])
+#define WACS_LANTERN &(CURSES_WACS_ARRAY['i'])
+#define WACS_LRCORNER &(CURSES_WACS_ARRAY['j'])
+#define WACS_URCORNER &(CURSES_WACS_ARRAY['k'])
+#define WACS_ULCORNER &(CURSES_WACS_ARRAY['l'])
+#define WACS_LLCORNER &(CURSES_WACS_ARRAY['m'])
+#define WACS_PLUS &(CURSES_WACS_ARRAY['n'])
+#define WACS_HLINE &(CURSES_WACS_ARRAY['q'])
+#define WACS_S1 &(CURSES_WACS_ARRAY['o'])
+#define WACS_S9 &(CURSES_WACS_ARRAY['s'])
+#define WACS_LTEE &(CURSES_WACS_ARRAY['t'])
+#define WACS_RTEE &(CURSES_WACS_ARRAY['u'])
+#define WACS_BTEE &(CURSES_WACS_ARRAY['v'])
+#define WACS_TTEE &(CURSES_WACS_ARRAY['w'])
+#define WACS_VLINE &(CURSES_WACS_ARRAY['x'])
+#define WACS_BULLET &(CURSES_WACS_ARRAY['~'])
+#define WACS_S3 &(CURSES_WACS_ARRAY['p'])
+#define WACS_S7 &(CURSES_WACS_ARRAY['r'])
+#define WACS_LEQUAL &(CURSES_WACS_ARRAY['y'])
+#define WACS_GEQUAL &(CURSES_WACS_ARRAY['z'])
+#define WACS_PI &(CURSES_WACS_ARRAY['{'])
+#define WACS_NEQUAL &(CURSES_WACS_ARRAY['|'])
+#define WACS_STERLING &(CURSES_WACS_ARRAY['}'])
+#endif
+
+#ifndef WA_NORMAL
+#define WA_NORMAL A_NORMAL
+#define WA_BOLD A_BOLD
+#define WA_REVERSE A_REVERSE
+#define WA_UNDERLINE A_UNDERLINE
+#define WA_BLINK A_BLINK
#endif
#ifndef OK
#define DECL_CURSES_DATA_TTYTYPE 0
#endif
-#if !HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE
+#if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
#define ttytype termname()
#endif
* authorization. *
****************************************************************************/
/*
- * $Id: test_termattrs.c,v 1.1 2017/06/24 18:26:15 tom Exp $
+ * $Id: test_termattrs.c,v 1.2 2017/10/11 08:16:02 tom Exp $
*
* Demonstrate the termattrs and term_attrs functions.
*/
#if HAVE_SETUPTERM
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static FILE *my_fp;
static void
* authorization. *
****************************************************************************/
/*
- * $Id: test_vid_puts.c,v 1.9 2017/06/24 17:48:04 tom Exp $
+ * $Id: test_vid_puts.c,v 1.10 2017/10/11 08:16:24 tom Exp $
*
* Demonstrate the vid_puts and vid_attr functions.
* Thomas Dickey - 2013/01/12
#if USE_WIDEC_SUPPORT && HAVE_SETUPTERM && HAVE_VID_PUTS
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static FILE *my_fp;
static bool p_opt = FALSE;
static bool
outs(const char *s)
{
- if (valid(s)) {
+ if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
* authorization. *
****************************************************************************/
/*
- * $Id: test_vidputs.c,v 1.8 2017/06/24 17:48:17 tom Exp $
+ * $Id: test_vidputs.c,v 1.9 2017/10/11 08:17:07 tom Exp $
*
* Demonstrate the vidputs and vidattr functions.
* Thomas Dickey - 2013/01/12
#if HAVE_SETUPTERM && HAVE_VIDPUTS
-#define valid(s) ((s != 0) && s != (char *)-1)
-
static FILE *my_fp;
static bool p_opt = FALSE;
static bool
outs(const char *s)
{
- if (valid(s)) {
+ if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
* scroll operation worked, and the refresh() code only had to do a
* partial repaint.
*
- * $Id: view.c,v 1.104 2017/09/30 17:50:38 tom Exp $
+ * $Id: view.c,v 1.111 2017/10/15 00:56:58 tom Exp $
*/
#include <test.priv.h>
#include <widechars.h>
#include <popup_msg.h>
+#include <sys/stat.h>
#include <time.h>
#undef CTRL /* conflict on AIX 5.2 with <sys/ioctl.h> */
+static void finish(int sig) GCC_NORETURN;
+
#if HAVE_TERMIOS_H
# include <termios.h>
#else
#undef CTRL
#define CTRL(x) ((x) & 0x1f)
-static void finish(int sig) GCC_NORETURN;
-static void show_all(const char *tag);
-
#if defined(SIGWINCH) && defined(TIOCGWINSZ) && HAVE_RESIZE_TERM
#define CAN_RESIZE 1
#else
#endif
#if CAN_RESIZE
-static void adjust(int sig);
static int interrupted;
static bool waiting = FALSE;
#endif
static void usage(void) GCC_NORETURN;
+static void
+failed(const char *msg)
+{
+ fprintf(stderr, "%s\n", msg);
+ ExitProgram(EXIT_FAILURE);
+}
+
static void
usage(void)
{
,"Options:"
," -c use color if terminal supports it"
," -i ignore INT, QUIT, TERM signals"
- ," -n NUM specify maximum number of lines (default 1000)"
#if defined(KEY_RESIZE)
," -r use old-style sigwinch handler rather than KEY_RESIZE"
#endif
return dst;
}
+static void
+finish(int sig)
+{
+ endwin();
+#if NO_LEAKS
+ if (vec_lines != 0) {
+ int n;
+ for (n = 0; n < num_lines; ++n) {
+ free(vec_lines[n]);
+ }
+ free(vec_lines);
+ }
+#endif
+ ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
+static void
+show_all(const char *tag)
+{
+ int i;
+ char temp[BUFSIZ];
+ NCURSES_CH_T *s;
+ time_t this_time;
+
+#if CAN_RESIZE
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
+ i = (int) strlen(temp);
+ if ((i + 7) < (int) sizeof(temp)) {
+ _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
+ "view %.*s",
+ (int) (sizeof(temp) - 7 - (size_t) i),
+ fname);
+ }
+#else
+ (void) tag;
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "view %.*s", (int) sizeof(temp) - 7, fname);
+#endif
+ move(0, 0);
+ printw("%.*s", COLS, temp);
+ clrtoeol();
+ this_time = time((time_t *) 0);
+ _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
+ if ((i = (int) strlen(temp)) != 0) {
+ temp[--i] = 0;
+ if (move(0, COLS - i - 2) != ERR)
+ printw(" %s", temp);
+ }
+
+ scrollok(stdscr, FALSE); /* prevent screen from moving */
+ for (i = 1; i < LINES; i++) {
+ int len;
+ int actual = (int) (lptr + i - vec_lines);
+ if (actual >= num_lines) {
+ clrtobot();
+ break;
+ }
+ move(i, 0);
+ printw("%3d:", actual);
+ clrtoeol();
+ if ((s = lptr[i - 1]) == 0) {
+ continue;
+ }
+ len = ch_len(s);
+ if (len > shift) {
+#if USE_WIDEC_SUPPORT
+ add_wchstr(s + shift);
+#else
+ addchstr(s + shift);
+#endif
+ }
+#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
+ if (try_color)
+ wchgat(stdscr, -1, WA_NORMAL, my_pair, NULL);
+#endif
+ }
+ setscrreg(1, LINES - 1);
+ scrollok(stdscr, TRUE);
+ refresh();
+}
+
+#if CAN_RESIZE
+/*
+ * This uses functions that are "unsafe", but it seems to work on SunOS.
+ * Usually: the "unsafe" refers to the functions that POSIX lists which may be
+ * called from a signal handler. Those do not include buffered I/O, which is
+ * used for instance in wrefresh(). To be really portable, you should use the
+ * KEY_RESIZE return (which relies on ncurses' sigwinch handler).
+ *
+ * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
+ * of the screen -- some xterms mangle the bitmap while resizing.
+ */
+static void
+adjust(int sig)
+{
+ if (waiting || sig == 0) {
+ struct winsize size;
+
+ if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
+ resize_term(size.ws_row, size.ws_col);
+ wrefresh(curscr);
+ show_all(sig ? "SIGWINCH" : "interrupt");
+ }
+ interrupted = FALSE;
+ } else {
+ interrupted = TRUE;
+ }
+ (void) signal(SIGWINCH, adjust); /* some systems need this */
+}
+#endif /* CAN_RESIZE */
+
+static void
+read_file(const char *filename)
+{
+ FILE *fp;
+ int pass;
+ int k;
+ size_t j;
+ size_t len;
+ struct stat sb;
+ char *my_blob;
+ char **my_vec = 0;
+
+ if (stat(filename, &sb) != 0
+ || (sb.st_mode & S_IFMT) != S_IFREG) {
+ failed("input is not a file");
+ }
+
+ if (sb.st_size == 0) {
+ failed("input is empty");
+ }
+
+ if ((fp = fopen(filename, "r")) == 0) {
+ failed("cannot open input-file");
+ }
+
+ if ((my_blob = malloc((size_t) sb.st_size + 1)) == 0) {
+ failed("cannot allocate memory for input-file");
+ }
+
+ len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+ my_blob[sb.st_size] = '\0';
+ fclose(fp);
+
+ for (pass = 0; pass < 2; ++pass) {
+ char *base = my_blob;
+ k = 0;
+ for (j = 0; j < len; ++j) {
+ if (my_blob[j] == '\n') {
+ if (pass) {
+ my_vec[k] = base;
+ my_blob[j] = '\0';
+ }
+ base = my_blob + j + 1;
+ ++k;
+ }
+ }
+ num_lines = k;
+ if (base != (my_blob + j))
+ ++num_lines;
+ if (!pass &&
+ ((my_vec = typeCalloc(char *, (size_t) k + 2)) == 0)) {
+ failed("cannot allocate line-vector #1");
+ }
+ }
+ if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) num_lines + 2)) == 0)
+ failed("cannot allocate line-vector #2");
+
+ Trace(("slurp the file"));
+ for (k = 0; k < num_lines; ++k) {
+ char *buf = my_vec[k];
+ char temp[BUFSIZ], *s, *d;
+ int col;
+
+ lptr = &vec_lines[k];
+
+#if USE_WIDEC_SUPPORT
+ if (lptr == vec_lines) {
+ if (!memcmp("", buf, 3)) {
+ Trace(("trim BOM"));
+ s = buf + 3;
+ d = buf;
+ do {
+ } while ((*d++ = *s++) != '\0');
+ }
+ }
+#endif
+
+ /* convert tabs and nonprinting chars so that shift will work properly */
+ for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
+ if (*d == '\r') {
+ if (s[1] == '\n') {
+ continue;
+ } else {
+ break;
+ }
+ }
+ if (*d == '\n') {
+ *d = '\0';
+ break;
+ } else if (*d == '\t') {
+ col = (col | 7) + 1;
+ while ((d - temp) != col)
+ *d++ = ' ';
+ } else
+#if USE_WIDEC_SUPPORT
+ col++, d++;
+#else
+ if (isprint(UChar(*d))) {
+ col++;
+ d++;
+ } else {
+ _nc_SPRINTF(d, _nc_SLIMIT(sizeof(temp) - (d - buf))
+ "\\%03o", UChar(*s));
+ d += strlen(d);
+ col = (int) (d - temp);
+ }
+#endif
+ }
+ *lptr = ch_dup(temp);
+ }
+
+ free(my_vec);
+ free(my_blob);
+}
+
int
main(int argc, char *argv[])
{
" r,<Right> - scroll the viewport right by one column",
"",
" h,<Home> - scroll the viewport to top of file",
+ " ^F,<PageDn> - scroll to the next page",
+ " ^B,<PageUp> - scroll to the previous page",
" e,<End> - scroll the viewport to end of file",
"",
" ^L - repaint using redrawwin()",
0
};
- int MAXLINES = 1000;
- FILE *fp;
- char buf[BUFSIZ];
int i;
int my_delay = 0;
NCURSES_CH_T **olptr;
setlocale(LC_ALL, "");
-#ifndef NCURSES_VERSION
- /*
- * We know ncurses will catch SIGINT if we don't establish our own handler.
- * Other versions of curses may/may not catch it.
- */
- (void) signal(SIGINT, finish); /* arrange interrupts to terminate */
-#endif
-
- while ((i = getopt(argc, argv, "cin:rstT:")) != -1) {
+ while ((i = getopt(argc, argv, "cirstT:")) != -1) {
switch (i) {
case 'c':
try_color = TRUE;
case 'i':
ignore_sigs = TRUE;
break;
- case 'n':
- if ((MAXLINES = atoi(optarg)) < 1 ||
- (MAXLINES + 2) <= 1)
- usage();
- break;
#if CAN_RESIZE
case 'r':
nonposix_resize = TRUE;
if (optind + 1 != argc)
usage();
- if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) MAXLINES + 2)) == 0)
- usage();
-
- assert(vec_lines != 0);
+ read_file(fname = argv[optind]);
- fname = argv[optind];
- if ((fp = fopen(fname, "r")) == 0) {
- perror(fname);
- ExitProgram(EXIT_FAILURE);
- }
#if CAN_RESIZE
if (nonposix_resize)
(void) signal(SIGWINCH, adjust); /* arrange interrupts to resize */
#endif
- Trace(("slurp the file"));
- for (lptr = &vec_lines[0]; (lptr - vec_lines) < MAXLINES; lptr++) {
- char temp[BUFSIZ], *s, *d;
- int col;
-
- if (fgets(buf, sizeof(buf), fp) == 0)
- break;
-
-#if USE_WIDEC_SUPPORT
- if (lptr == vec_lines) {
- if (!memcmp("", buf, 3)) {
- Trace(("trim BOM"));
- s = buf + 3;
- d = buf;
- do {
- } while ((*d++ = *s++) != '\0');
- }
- }
-#endif
-
- /* convert tabs and nonprinting chars so that shift will work properly */
- for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
- if (*d == '\r') {
- if (s[1] == '\n') {
- continue;
- } else {
- break;
- }
- }
- if (*d == '\n') {
- *d = '\0';
- break;
- } else if (*d == '\t') {
- col = (col | 7) + 1;
- while ((d - temp) != col)
- *d++ = ' ';
- } else
-#if USE_WIDEC_SUPPORT
- col++, d++;
-#else
- if (isprint(UChar(*d))) {
- col++;
- d++;
- } else {
- _nc_SPRINTF(d, _nc_SLIMIT(sizeof(temp) - (d - buf))
- "\\%03o", UChar(*s));
- d += strlen(d);
- col = (int) (d - temp);
- }
-#endif
- }
- *lptr = ch_dup(temp);
- }
- (void) fclose(fp);
- num_lines = (int) (lptr - vec_lines);
-
- if (ignore_sigs) {
- InitAndCatch(initscr(), SIG_IGN);
- } else {
- initscr();
- }
+ InitAndCatch(initscr(), ignore_sigs ? SIG_IGN : finish);
keypad(stdscr, TRUE); /* enable keyboard mapping */
(void) nonl(); /* tell curses not to do NL->CR/NL on output */
(void) cbreak(); /* take input chars one at a time, no wait for \n */
scrl((int) (lptr - olptr));
break;
+ case '<':
+ shift = 0;
+ /* FALLTHRU */
case 'h':
+ /* FALLTHRU */
case KEY_HOME:
lptr = vec_lines;
break;
+ case '>':
+ shift = 0;
+ /* FALLTHRU */
case 'e':
+ /* FALLTHRU */
case KEY_END:
if (num_lines > LINES)
- lptr = vec_lines + num_lines - LINES + 1;
+ lptr = (vec_lines + num_lines - LINES + 1);
+ else
+ lptr = (vec_lines + (num_lines - 2));
+ break;
+
+ case CTRL('F'):
+ /* FALLTHRU */
+ case KEY_NPAGE:
+ if ((lptr - vec_lines) < (num_lines - 5))
+ lptr += (LINES - 1);
+ else
+ lptr = (vec_lines + num_lines - 2);
+ break;
+
+ case CTRL('B'):
+ /* FALLTHRU */
+ case KEY_PPAGE:
+ if ((lptr - vec_lines) >= LINES)
+ lptr -= (LINES - 1);
else
lptr = vec_lines;
break;
finish(0); /* we're done */
}
-
-static void
-finish(int sig)
-{
- endwin();
-#if NO_LEAKS
- if (vec_lines != 0) {
- int n;
- for (n = 0; n < num_lines; ++n) {
- free(vec_lines[n]);
- }
- free(vec_lines);
- }
-#endif
- ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#if CAN_RESIZE
-/*
- * This uses functions that are "unsafe", but it seems to work on SunOS.
- * Usually: the "unsafe" refers to the functions that POSIX lists which may be
- * called from a signal handler. Those do not include buffered I/O, which is
- * used for instance in wrefresh(). To be really portable, you should use the
- * KEY_RESIZE return (which relies on ncurses' sigwinch handler).
- *
- * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
- * of the screen -- some xterms mangle the bitmap while resizing.
- */
-static void
-adjust(int sig)
-{
- if (waiting || sig == 0) {
- struct winsize size;
-
- if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
- resize_term(size.ws_row, size.ws_col);
- wrefresh(curscr);
- show_all(sig ? "SIGWINCH" : "interrupt");
- }
- interrupted = FALSE;
- } else {
- interrupted = TRUE;
- }
- (void) signal(SIGWINCH, adjust); /* some systems need this */
-}
-#endif /* CAN_RESIZE */
-
-static void
-show_all(const char *tag)
-{
- int i;
- char temp[BUFSIZ];
- NCURSES_CH_T *s;
- time_t this_time;
-
-#if CAN_RESIZE
- _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
- "%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
- i = (int) strlen(temp);
- if ((i + 7) < (int) sizeof(temp)) {
- _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
- "view %.*s",
- (int) (sizeof(temp) - 7 - (size_t) i),
- fname);
- }
-#else
- (void) tag;
- _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
- "view %.*s", (int) sizeof(temp) - 7, fname);
-#endif
- move(0, 0);
- printw("%.*s", COLS, temp);
- clrtoeol();
- this_time = time((time_t *) 0);
- _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
- if ((i = (int) strlen(temp)) != 0) {
- temp[--i] = 0;
- if (move(0, COLS - i - 2) != ERR)
- printw(" %s", temp);
- }
-
- scrollok(stdscr, FALSE); /* prevent screen from moving */
- for (i = 1; i < LINES; i++) {
- move(i, 0);
- printw("%3ld:", (long) (lptr + i - vec_lines));
- clrtoeol();
- if ((s = lptr[i - 1]) != 0) {
- int len = ch_len(s);
- if (len > shift) {
-#if USE_WIDEC_SUPPORT
- add_wchstr(s + shift);
-#else
- addchstr(s + shift);
-#endif
- }
-#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
- if (try_color)
- wchgat(stdscr, -1, WA_NORMAL, my_pair, NULL);
-#endif
- }
- }
- setscrreg(1, LINES - 1);
- scrollok(stdscr, TRUE);
- refresh();
-}