Next: , Previous: Handling unmapped keys, Up: The basic curses library   [Contents][Index]

5.2.18 Receiving strings from the keyboard

Procedure: getnstr win n #:key y x

The procedure getnstr is equivalent to a series of calls to getch, until a newline or carriage return is received (the terminating character is not included in the returned string). The resulting string is returned.

getnstr reads at most n characters, thus preventing a possible overflow of the input buffer. Any attempt to enter more characters (other than the terminating newline or carriage return) causes a beep. Function keys also cause a beep and are ignored.

The user’s erase and kill characters are interpreted. If keypad mode is on for the window, KEY_LEFT and KEY_BACKSPACE are both considered equivalent to the user’s kill character.

Characters input are echoed only if echo! is currently on. In that case, backspace is echoed as deletion of the previous character (typically a left motion).

If a SIGWINCH interrupts the function, it will return the integer value of KEY_RESIZE instead of a string.