Reputation: 10607
In my curses program, I sometimes need to use ungetch
to put back a lot of characters at once. However, there is a limit:
foreach my $character (reverse split('', "put back this string")) {
ungetch($character);
}
For a large string though, ungetch
fails (it returns -1, which I should check for above). How can I increase the buffer or limit that controls how many letters I must push back before I have to do a getch
?
Upvotes: 1
Views: 178
Reputation: 16096
The size of the buffer is provided by the underlying curses library that the Perl curses implementation. In ncurses the input queue size is defined at ncurses/curses.priv.h , where it is defined as FIFO_SIZE is MAXCOLUMNS+2, which is 137 for the newer versions of ncurses.
In order to increase the input queue size, you would need to increase that value and recompile your system's curses implementation.
The underlying method which clears the input queue fifo_clear
isn't exposed outside of the curses implementation source code, which means it is not provided to the Perl binding. The only provided method I am aware of is getch, which you already specify as a workaround.
Upvotes: 4