]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - man/curs_inwstr.3x
ncurses 6.5 - patch 20240615
[ncurses.git] / man / curs_inwstr.3x
index 63ebed0bec832a195b8fd0d74f088daa76361cdb..a557cbe3c8cbbaf059ddd578810050afa2112860 100644 (file)
@@ -1,5 +1,6 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002-2012,2017 Free Software Foundation, Inc.              *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
+.\" Copyright 2002-2012,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_inwstr.3x,v 1.9 2017/10/28 23:42:58 tom Exp $
-.TH curs_inwstr 3X ""
+.\" $Id: curs_inwstr.3x,v 1.45 2024/06/08 21:19:18 tom Exp $
+.TH curs_inwstr 3X 2024-06-08 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBinwstr\fR,
-\fBinnwstr\fR,
-\fBwinwstr\fR,
-\fBwinnwstr\fR,
-\fBmvinwstr\fR,
-\fBmvinnwstr\fR,
-\fBmvwinwstr\fR,
-\fBmvwinnwstr\fR \- get a string of \fBwchar_t\fR characters from a curses window
+\fB\%inwstr\fP,
+\fB\%innwstr\fP,
+\fB\%winwstr\fP,
+\fB\%winnwstr\fP,
+\fB\%mvinwstr\fP,
+\fB\%mvinnwstr\fP,
+\fB\%mvwinwstr\fP,
+\fB\%mvwinnwstr\fP \-
+get a wide-character string from a \fIcurses\fR window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h> \fR
-.sp
-\fBint inwstr(\fR\fBwchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint innwstr(\fR\fBwchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint winwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint winnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvinwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvinnwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwinwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvwinnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fB#include <curses.h>
+.PP
+\fBint inwstr(wchar_t *\ \fIwstr\fP);
+\fBint winwstr(WINDOW *\ \fIwin\fP, wchar_t *\ \fIwstr\fP);
+\fBint mvinwstr(int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP);
+\fBint mvwinwstr(WINDOW *\ \fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP);
+.PP
+\fBint innwstr(wchar_t *\ \fIwstr\fP, int \fIn\fP);
+\fBint winnwstr(WINDOW *\ \fIwin\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
+\fBint mvinnwstr(int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
+\fBint mvwinnwstr(WINDOW *\ \fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
+.B \%winwstr
+extracts a wide-character string from a
+.I curses
+window
+.IR win ","
+starting at the cursor and stopping at the end of the line,
+and stores it in
+.IR wstr ","
+terminating it with a wide null character
+and
+omitting any attributes and color pair identifier
+that
+.I curses
+associates with each character.
+.B \%winnwstr
+does the same,
+but copies at most
+.I n
+characters from
+.IR win "."
+An
+.I n
+of
+.B \-1
+implies no limit;
+.B \%winnwstr
+then works like
+.BR \%winwstr "."
+\fB\%ncurses\fP(3X) describes the variants of these functions.
+.SH RETURN VALUE
+On successful operation,
+these functions return the count of wide characters copied from
+.I win
+to
+.IR wstr "."
+They return
+.B ERR
+upon failure.
+.BR \%innwstr ","
+.BR \%winnwstr ","
+.BR \%mvinnwstr ","
+and
+.B \%mvwinnwstr
+return
+.B ERR
+if
+.I n
+is insufficiently large to store a complete wide character string.
+(Recall that a
+.I curses
+complex character can contain multiple wide characters,
+some of which may be non-spacing.)
 .PP
-These routines return a string of \fBwchar_t\fR wide characters in \fIwstr\fR,
-extracted starting at the current cursor position in the named window.
-.PP
-The four functions with \fIn\fR as the last argument return a leading substring at most
-\fIn\fR characters long (exclusive of the trailing NUL).
-Transfer stops at the end of the current line, or when \fIn\fR characters have
-been stored at the location referenced by \fIwstr\fR.
+In
+.IR \%ncurses ","
+these functions return
+.B ERR
+if
+.bP
+.I win
+is
+.B NULL
+or
+.bP
+.I wstr
+is
+.BR NULL "."
 .PP
-If the size \fIn\fR is not large enough to store a complete complex character,
-an error is generated.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
+All of these functions except
+.B \%winnwstr
+may be implemented as macros.
 .PP
-All routines except
-\fBwinnwstr\fR
-may be macros.
+Reading a line that overflows the array pointed to by
+.I str
+with
+.BR \%inwstr ","
+.BR \%winwstr ","
+.BR \%mvinwstr ","
+or
+.B \%mvwinwstr
+causes undefined results.
+Use of
+.BR \%innwstr ","
+.BR \%winnwstr ","
+.BR \%mvinnwstr ","
+and
+.B \%mvwinnwstr
+is recommended instead.
+.SH EXTENSIONS
+.BR \%innwstr ","
+.BR \%winnwstr ","
+.BR \%mvinnwstr ","
+and
+.BR \%mvwinnwstr "'s"
+treatment of
+.B \-1
+as a valid value of
+.I n
+is an
+.I \%ncurses
+extension.
+.SH PORTABILITY
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
 .PP
-Each cell in the window holds a complex character (i.e., base-
-and combining-characters) together with attributes and color.
-These functions store only the wide characters,
-ignoring attributes and color.
-Use \fBin_wchstr\fP to return the complex characters from a window.
-.SH RETURN VALUE
-All routines return
-\fBERR\fR
-upon failure. Upon
-successful completion, the *\fBinwstr\fR
-routines return
-\fBOK\fR, and the *\fBinnwstr\fR
-routines return the
-number of characters read into the string.
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
+.PP
+Notwithstanding the foregoing,
+X/Open Curses Issues 4 and 7 both state that
+.BR \%innwstr ","
+.BR \%winnwstr ","
+.BR \%mvinnwstr ","
+and
+.B \%mvwinnwstr
+\*(``fail .\|.\|. [i]f the array is not large enough to contain any
+complete characters\*(''.
+Strictly interpreted,
+this means that a caller of these functions cannot use their return
+values to detect truncation of a wide-character string copied from more
+than one character cell in
+.IR win "."
+.I \%ncurses
+reports any truncation with
+.BR ERR "."
 .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.
+X/Open Curses specifies
+.BR \%inwstr ","
+.BR \%winwstr ","
+.BR \%mvinwstr ","
+and
+.B \%mvwinwstr
+as returning
+.B OK
+rather than a (wide) character count,
+unlike their non-wide counterparts
+.BR \%instr ","
+.BR \%winstr ","
+.BR \%mvinstr ","
+and
+.BR \%mvwinstr "."
+.I \%ncurses
+regards this inconsistency as an error in the standard.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_instr\fR(3X),
-\fBcurs_in_wchstr\fR(3X)
+\fB\%curs_instr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_in_wch\fP(3X),
+\fB\%curs_in_wchstr\fP(3X)