Re: Bugs when porting ncurses to a new platform
Antonio Niño Díaz <[email protected]> Wed, 01 Jul 2026 23:17:23 +0000
| Newsgroups | gmane.comp.lib.ncurses.bugs |
|---|---|
| Message-ID | <LQs_v2dxJ5SvXzESjIKmGM91LImAZJIEUn1Z7VZWIeyPsKEVQI6qOr9Qj-dG0rQ3zZCDSBvAICiCpKV11RtVaYuK3QCXXOidzZgkrX6thFg=@pm.me> |
On Wednesday, July 1st, 2026 at 2:47 AM, Thomas Dickey <dickey@invisible-is= land.net> wrote: > On Tue, Jun 30, 2026 at 12:27:45AM +0000, Antonio Ni=C3=B1o D=C3=ADaz wro= te: > > Hello! > >=20 > > 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 termin= fo > > configuration settings from other terminals to create my own configurat= ion > > based on what I actually support, and I'm trying to understand every se= tting > > I use. So far I've managed to get 16 and 256 color modes working, as w= ell 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 col= or > > working, though). > >=20 > > ---------------- > ... > > 2) getch() only works for blocking input. > >=20 > > If I use `timeout(-1)` I can see calls to `read()`. They block as expe= cted > > 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. >=20 > no - ncurses basically uses select() or poll() to detect new data. >=20 > In a quick check, timeout() sets a _delay member of the window, > which when negative will bypass a timed delay when looking for data. > =20 > > How does ncurses get new characters for non-blocking input? > >=20 > > ---------------- > >=20 > > This is my build configuration: > >=20 > > ./configure \ > > --with-normal \ > > --without-shared --without-progs --without-manpages --without-tests \ > > --target=3Darm --host=3Darm --build=3Damd64 \ > > --disable-database --disable-db-install \ > > --disable-gnat-projects --disable-home-terminfo \ > > --enable-termcap \ > > --disable-widec \ > > --prefix=3D$PWD/mybuild \ > > --with-trace \ > > --enable-getcap \ > > --disable-sigwinch \ > > --enable-ext-colors --enable-rgb-color \ > > --enable-ext-mouse \ > > CFLAGS=3D"-mthumb -mcpu=3Darm946e-s+nofp -O2 -ffunction-sections -fdata= -sections -I$BLOCKSDS/libs/libnds/include" \ > > BUILD_CC=3Dgcc \ > > CC=3Darm-none-eabi-gcc \ > > cf_cv_have_tcgetattr=3Dyes \ > > ac_cv_func_gettimeofday=3Dyes \ > > ac_cv_type_sigset_t=3Dno >=20 > 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 pa= tch to add an extra case to check_pending() to use ioctl(FIONREAD) if neither o= f 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