On Wednesday, July 1st, 2026 at 2:47 AM, Thomas Dickey 
<[email protected]> wrote:

> On Tue, Jun 30, 2026 at 12:27:45AM +0000, Antonio Niño Díaz wrote:
> > Hello!
> > 
> > I'm trying to get ncurses working in a new platform (Nintendo DS using
> > [BlocksDS](https://blocksds.skylyrac.net/)).  I've created a terminal
> > emulator that supports 16-color, 256-color and direct color commands
> > (foreground and background), as well as a few other commands like "bold",
> > "move cursor" and "clear screen".  Basically, I'm cherry-picking terminfo
> > configuration settings from other terminals to create my own configuration
> > based on what I actually support, and I'm trying to understand every setting
> > I use.  So far I've managed to get 16 and 256 color modes working, as well 
> > as
> > moving the cursor around and clearing the screen.  However, I have two 
> > issues
> > that I've spent a few days debugging with no success.  I've even added 
> > printf
> > logs in ncurses in many places (the trace system doesn't work for some
> > reason) but ncurses has so many build options and code paths that it's hard
> > to know what actually gets used (printf-debugging has helped to get color
> > working, though).
> > 
> > ----------------
> ...
> > 2) getch() only works for blocking input.
> > 
> > If I use `timeout(-1)` I can see calls to `read()`.  They block as expected
> > and I can see that the value is received by ncurses.  However, if I use
> > `timeout(0)` I never see any syscall being used.  Maybe I'm looking at the
> > wrong place, but the same code works on PC, so I assume it's something to do
> > with my port.  I do support setting non-blocking mode for `stdin` with
> > `ioctl(FIONBIO)` and `fcntl(F_SETFL, O_NONBLOCK)`, and I also support
> > querying the amount of characters available to read from `stdin` with
> > `ioctl(FIONREAD)`, but I don't know if this is even used by ncurses.
> 
> no - ncurses basically uses select() or poll() to detect new data.
> 
> In a quick check, timeout() sets a _delay member of the window,
> which when negative will bypass a timed delay when looking for data.
>  
> > How does ncurses get new characters for non-blocking input?
> > 
> > ----------------
> > 
> > This is my build configuration:
> > 
> > ./configure \
> > --with-normal \
> > --without-shared --without-progs --without-manpages --without-tests \
> > --target=arm --host=arm --build=amd64 \
> > --disable-database --disable-db-install \
> > --disable-gnat-projects --disable-home-terminfo \
> > --enable-termcap \
> > --disable-widec \
> > --prefix=$PWD/mybuild \
> > --with-trace \
> > --enable-getcap \
> > --disable-sigwinch \
> > --enable-ext-colors --enable-rgb-color \
> > --enable-ext-mouse \
> > CFLAGS="-mthumb -mcpu=arm946e-s+nofp -O2 -ffunction-sections 
> > -fdata-sections -I$BLOCKSDS/libs/libnds/include" \
> > BUILD_CC=gcc \
> > CC=arm-none-eabi-gcc \
> > cf_cv_have_tcgetattr=yes \
> > ac_cv_func_gettimeofday=yes \
> > ac_cv_type_sigset_t=no
> 
> The output from the configure script (config.log, config.status) would
> tell us for example if it's using select or poll.

Ah, yes, that seems to be it, my select() and poll() don't work with stdin, so
it can't detect the available characters.

Unfortunately, implementing this isn't exactly trivial (I support select() and
poll() for network sockets with lwIP, so I need a way to redirect select() calls
to lwIP and to my own stdin handler somehow) so I might just add a small patch
to add an extra case to check_pending() to use ioctl(FIONREAD) if neither of the
functions are available. There's already a custom case for BeOS (which also
supports them also for networking), but it's not exactly the ioctl() I need.

Thanks a lot, I'll investigate how I can work around this limitation!

Antonio

Reply via email to