Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | .\" * |
| 5 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | .\" copy of this software and associated documentation files (the * |
| 7 | .\" "Software"), to deal in the Software without restriction, including * |
| 8 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 11 | .\" furnished to do so, subject to the following conditions: * |
| 12 | .\" * |
| 13 | .\" The above copyright notice and this permission notice shall be included * |
| 14 | .\" in all copies or substantial portions of the Software. * |
| 15 | .\" * |
| 16 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | .\" * |
| 24 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 25 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 26 | .\" sale, use or other dealings in this Software without prior written * |
| 27 | .\" authorization. * |
| 28 | .\"*************************************************************************** |
| 29 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_instr.3x,v 1.51 2024/04/20 21:24:19 tom Exp $ |
| 31 | .TH curs_instr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 32 | .ie \n(.g \{\ |
| 33 | .ds `` \(lq |
| 34 | .ds '' \(rq |
| 35 | .\} |
| 36 | .el \{\ |
| 37 | .ie t .ds `` `` |
| 38 | .el .ds `` "" |
| 39 | .ie t .ds '' '' |
| 40 | .el .ds '' "" |
| 41 | .\} |
| 42 | . |
| 43 | .de bP |
| 44 | .ie n .IP \(bu 4 |
| 45 | .el .IP \(bu 2 |
| 46 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | \fB\%instr\fP, |
| 49 | \fB\%innstr\fP, |
| 50 | \fB\%winstr\fP, |
| 51 | \fB\%winnstr\fP, |
| 52 | \fB\%mvinstr\fP, |
| 53 | \fB\%mvinnstr\fP, |
| 54 | \fB\%mvwinstr\fP, |
| 55 | \fB\%mvwinnstr\fP \- |
| 56 | get a string from a \fIcurses\fR window |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 57 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 58 | .nf |
| 59 | \fB#include <curses.h> |
| 60 | .PP |
| 61 | \fBint instr(char *\fIstr\fP); |
| 62 | \fBint innstr(char *\fIstr\fP, int \fIn\fP); |
| 63 | \fBint winstr(WINDOW *\fIwin\fP, char *\fIstr\fP); |
| 64 | \fBint winnstr(WINDOW *\fIwin\fP, char *\fIstr\fP, int \fIn\fP); |
| 65 | .PP |
| 66 | \fBint mvinstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP); |
| 67 | \fBint mvinnstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP); |
| 68 | \fBint mvwinstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP); |
| 69 | \fBint mvwinnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP); |
| 70 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 71 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 72 | These routines return a string of characters in \fIstr\fP, |
| 73 | starting at the current cursor position in the named window. |
| 74 | Attributes are stripped from the characters. |
| 75 | .PP |
| 76 | The four functions with \fIn\fP as the last argument return |
| 77 | a leading substring at most \fIn\fP characters long |
| 78 | (exclusive of the trailing NUL). |
| 79 | Transfer stops at the end of the current line, or when \fIn\fP characters have |
| 80 | been stored at the location referenced by \fIstr\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 81 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 82 | All of the functions return \fBERR\fP upon failure, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 83 | or the number of characters actually read into the string. |
| 84 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 85 | X/Open Curses defines no error conditions. |
| 86 | This implementation returns an error |
| 87 | .bP |
| 88 | if the \fIwin\fP parameter is null or |
| 89 | .bP |
| 90 | if the \fIchstr\fP parameter is null. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 91 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 92 | Functions prefixed with \*(``mv\*('' first perform cursor movement and |
| 93 | fail if the position |
| 94 | .RI ( y , |
| 95 | .IR x ) |
| 96 | is outside the window boundaries. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 97 | .SH NOTES |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 98 | All routines except \fBwinnstr\fP may be macros. |
| 99 | .PP |
| 100 | Reading a line that overflows the array pointed to by |
| 101 | \fIstr\fP |
| 102 | with |
| 103 | \fBinstr\fP, |
| 104 | \fBmvinstr\fP, |
| 105 | \fBmvwinstr\fP |
| 106 | or |
| 107 | \fBwinstr\fP |
| 108 | causes undefined results. |
| 109 | Therefore, the use of |
| 110 | \fBinnstr\fP, |
| 111 | \fBmvinnstr\fP, |
| 112 | \fBmvwinnstr\fP, or |
| 113 | \fBwinnstr\fP |
| 114 | is recommended. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 115 | .SH PORTABILITY |
| 116 | SVr4 does not |
| 117 | document whether a length limit includes or excludes the trailing NUL. |
| 118 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 119 | The \fI\%ncurses\fP library extends the X/Open Curses description by allowing a |
| 120 | negative value for \fIn\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 121 | In this case, the functions return the string ending at the right margin. |
| 122 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | \fB\%curs_ins_wstr\fP(3X) describes comparable functions of the |
| 124 | .I \%ncurses |
| 125 | library in its wide-character configuration |
| 126 | .RI ( \%ncursesw ). |
| 127 | .PP |
| 128 | \fB\%curses\fP(3X), |
| 129 | \fB\%curs_inch\fP(3X), |
| 130 | \fB\%curs_inchstr\fP(3X) |