Testing confirms that <asm/termbits.h> is not needed for Linux for the detection of TIOCGWINSZ. <sys/ioctl/h> sufficient on both platforms.
Having #include <asm/termbits.h> is redundant on Linux, but causes incorrect detection of the existence of TIOCGWINSZ on macOS. Not sure if <asm/termbits.h> is needed on other platforms, though. - paul > On Dec 28, 2024, at 1:56 PM, Paul Rockwell <paulrockw...@mac.com> wrote: > > Jürgen, > > The configure code to determine HAVE_IOCTL_TIOCGWINSZ in config.h doesn't > work on macOS: > > conftest.cpp:130:11: fatal error: 'asm/termbits.h' file not found > 130 | #include <asm/termbits.h> /* for TIOCGWINSZ */ > | ^~~~~~~~~~~~~~~~ > 1 error generated. > configure:22435: $? = 1 > configure: failed program was: > | /* confdefs.h */ > | #define PACKAGE_NAME "GNU APL" > | #define PACKAGE_TARNAME "apl" > | #define PACKAGE_VERSION "1.9" > | #define PACKAGE_STRING "GNU APL 1.9" > | #define PACKAGE_BUGREPORT "bug-apl@gnu.org" > | #define PACKAGE_URL "https://www.gnu.org/software/apl/" > | #define HAVE_STDIO_H 1 > | #define HAVE_STDLIB_H 1 > | #define HAVE_STRING_H 1 > | #define HAVE_INTTYPES_H 1 > | #define HAVE_STDINT_H 1 > | #define HAVE_STRINGS_H 1 > | #define HAVE_SYS_STAT_H 1 > | #define HAVE_SYS_TYPES_H 1 > | #define HAVE_UNISTD_H 1 > | #define HAVE_WCHAR_H 1 > | #define STDC_HEADERS 1 > | #define _ALL_SOURCE 1 > | #define _DARWIN_C_SOURCE 1 > | #define _GNU_SOURCE 1 > | #define _HPUX_ALT_XOPEN_SOCKET_API 1 > | #define _NETBSD_SOURCE 1 > | #define _OPENBSD_SOURCE 1 > | #define _POSIX_PTHREAD_SEMANTICS 1 > | #define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 > | #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 > | #define __STDC_WANT_IEC_60559_DFP_EXT__ 1 > | #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 > | #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 > | #define __STDC_WANT_LIB_EXT2__ 1 > | #define __STDC_WANT_MATH_SPEC_FUNCS__ 1 > | #define _TANDEM_SOURCE 1 > | #define __EXTENSIONS__ 1 > | #define PACKAGE "apl" > | #define VERSION "1.9" > | #define HAVE_DLFCN_H 1 > | #define LT_OBJDIR ".libs/" > | #define HAVE_NCURSES_H 1 > | #define HAVE_TERM_H 1 > | #define HAVE_DIRENT_H 1 > | #define HAVE_EXECINFO_H 1 > | #define HAVE_FCNTL_H 1 > | #define HAVE_FENV_H 1 > | #define HAVE_FFTW3_H 1 > | #define HAVE_INTTYPES_H 1 > | #define HAVE_LIBPNG16_PNG_H 1 > | #define HAVE_LIMITS_H 1 > | #define HAVE_LOCALE_H 1 > | #define HAVE_NETDB_H 1 > | #define HAVE_NETINET_IN_H 1 > | #define HAVE_STDINT_H 1 > | #define HAVE_STDLIB_H 1 > | #define HAVE_STRING_H 1 > | #define HAVE_STRINGS_H 1 > | #define HAVE_SYS_UN_H 1 > | #define HAVE_TERMIOS_H 1 > | #define HAVE_UNISTD_H 1 > | #define HAVE_UTMPX_H 1 > | #define HAVE_VECTOR 1 > | #define HAVE_ZLIB_H 1 > | #define HAVE_STDBOOL_H 1 > | #define cfg_CONFIGURE_ARGS "./configure '--without-gtk3' 'CXXFLAGS=-O3 > -I/opt/local/include -std=gnu++17' 'LDFLAGS=-L/opt/local/lib'" > | #define HAVE_SYS_TIME_H 1 > | #define HAVE_SYS_PARAM_H 1 > | #define HAVE_FORK 1 > | #define HAVE_VFORK 1 > | #define HAVE_ALARM 1 > | #define HAVE_GETPAGESIZE 1 > | #define HAVE_WORKING_VFORK 1 > | #define HAVE_WORKING_FORK 1 > | #define HAVE_MALLOC 1 > | #define HAVE_MMAP 1 > | #define HAVE_DUP2 1 > | #define HAVE_FLOOR 1 > | #define HAVE_GETCWD 1 > | #define HAVE_GETHOSTBYNAME 1 > | #define HAVE_GETTIMEOFDAY 1 > | #define HAVE_MEMSET 1 > | #define HAVE_MKDIR 1 > | #define HAVE_MODF 1 > | #define HAVE_MUNMAP 1 > | #define HAVE_POW 1 > | #define HAVE_REALPATH 1 > | #define HAVE_RINT 1 > | #define HAVE_RMDIR 1 > | #define HAVE_SELECT 1 > | #define HAVE_SETENV 1 > | #define HAVE_SETLOCALE 1 > | #define HAVE_SOCKET 1 > | #define HAVE_SQRT 1 > | #define HAVE_STRCASECMP 1 > | #define HAVE_STRCHR 1 > | #define HAVE_STRDUP 1 > | #define HAVE_STRNCASECMP 1 > | #define HAVE_STRNDUP 1 > | #define HAVE_STRERROR 1 > | #define HAVE_STRRCHR 1 > | #define HAVE_STRSTR 1 > | #define HAVE_STRTOL 1 > | #define HAVE_UNAME 1 > | #define HAVE_LIBPTHREAD 1 > | #define HAVE_LIBCURSES 1 > | #define HAVE_LIBNCURSES 1 > | #define HAVE_LIBM 1 > | #define HAVE_LIBDL 1 > | #define HAVE_STRUCT_STAT_ST_BLOCKS 1 > | #define HAVE_ST_BLOCKS 1 > | #define HAVE_XCB_XCB_H 1 > | #define HAVE_X11_XLIB_H 1 > | #define HAVE_X11_XLIB_XCB_H 1 > | #define HAVE_X11_XUTIL_H 1 > | #define HAVE_LIBX11 1 > | #define HAVE_LIBXCB 1 > | #define HAVE_LIBX11_XCB 1 > | #define apl_X11 1 > | #define HAVE_LIBFFTW3 1 > | #define HAVE_LIBPNG 1 > | #define HAVE_LIBZ 1 > | #define HAVE_SQLITE3 1 > | #define apl_SQLITE3 1 > | #define apl_POSTGRES 0 > | #define HAVE_LIBPCRE2_32 1 > | #define HAVE_LIBM 1 > | #define HAVE_LIBGSLCBLAS 1 > | #define HAVE_LIBGSL 1 > | #define apl_GTK3 0 > | #define HAVE_GETTIMEOFDAY 1 > | /* end confdefs.h. */ > | #include <asm/termbits.h> /* for TIOCGWINSZ */ > | #include <sys/ioctl.h> > | > | int > | main (void) > | { > | winsize win; > | ioctl(/*fd */ 0, TIOCGWINSZ, &win); > | > | ; > | return 0; > | } > > <asm/termbits.h> doesn't exist on macOS, hence the #include failure. > > Simply including <sys/ioctl.h> is all that's needed to get the definition of > the TIOCGWINSZ ioctl on macOS. I suspect that's the same on Linux as well. > I'll test and report back. > > - paul > > > >> On Dec 28, 2024, at 12:32 PM, Dr. Jürgen Sauermann >> <mail@jürgen-sauermann.de> wrote: >> >> Hi Elias et al., >> >> thanks for the hint. I have now (SVN 1807) changed the code so that the >> initial ⎕PW >> is set from the size of the GNU APL window if: >> >> 1. the platform supports TIOCGWINSZ, and >> 2. the user has set WINCH-SETS-⎕PW to Yes in one of her preferences files, >> and >> 3. the user has NOT set INITIAL-⎕PW in one of her preferences files, and >> 4. the number of columns returned by TIOCGWINSZ is reasonable. >> >> Blake, no need to worry since WINCH-SETS-⎕PW is disabled by default (and >> INITIAL-⎕PW >> is 80 by default). >> >> Best Regards and happy new year, >> Jürgen >> >> >> >> On 12/25/24 16:15, Elias Mårtenson wrote: >>> You can actually request the terminal size. Unfortunately, the syntax to do >>> that is not standardised, but on Linux you can use TIOCGWINSZ. See the >>> documentation here: >>> https://man.archlinux.org/man/core/man-pages/TIOCGWINSZ.2const.en >>> >>> Here's what the stty command does to read this infomration: >>> >>> static int get_win_size (int fd, struct winsize *win) >>> { >>> int err = ioctl (fd, TIOCGWINSZ, (char *) win); >>> return err; >>> } >>> >>> Regards, >>> Elias >>> >>> On Wed, 25 Dec 2024 at 20:46, Dr. Jürgen Sauermann >>> <mail@jürgen-sauermann.de <mailto:mail@j%C3%BCrgen-sauermann.de>> wrote: >>>> Hi Mike, >>>> >>>> I have applied your patches - SVN 1806. >>>> >>>> A general problem with the SIGWINCH signal is that it is not emitted when >>>> the apl interpreter >>>> starts up (which make sense because the windows is not resized at that >>>> point in time). >>>> >>>> One could think of asking the window manager for the current window size >>>> but even though that >>>> would be possible it is not portable in any way. >>>> >>>> The INITIAL-⎕PW is a simple work-around to fix this. >>>> >>>> Best Regards, >>>> Jürgen >>>> >>>> >>>> On 12/23/24 22:47, M.Hall wrote not e: >>>>> Yes, I see now the behavior is not quite right, is it? With INITIAL-⎕PW >>>>> disabled, the ⎕PW still starts up at 80, ignoring the window width even >>>>> with WINCH-SETS-⎕PW. Somehow we would have to detect if it was set, and >>>>> use it only then, instead of always setting it. >>>>> >>>>> What I found unexpected was setting the initial width in the preferences >>>>> file, and not getting it -- having it overriden by the current window >>>>> width. >>>>> >>>>> I thought that if the user set the initial ⎕PW in the preferences file, >>>>> AND enabled WINCH-SET-PW, they still ought to get their initial ⎕PW. If >>>>> they resized the window later, then the ⎕PW would follow the window width. >>>>> >>>>> It's like using the command line setting "--PW 80" -- it overrides >>>>> everything else, which makes sense. Highest priority is the command line, >>>>> then the initial ⎕PW in the preferences file (if set), then the window >>>>> width (if enabled), finally DEFAULT_Quad_PW. >>>>> >>>>> I was just summarizing what I thought was the priority of the three >>>>> settings, and trying to make sense of how they work. >>>>> >>>>> Want 80? Unset both preference settings. Forget they exist. :-) >>>>> >>>>> On Mon, Dec 23, 2024 at 10:46 AM Paul Rockwell <paulrockw...@mac.com >>>>> <mailto:paulrockw...@mac.com>> wrote: >>>>>> Jürgen, >>>>>> >>>>>> It's macOS that's the problem as Mike states. I've confirmed with a >>>>>> small C program that the ioctl TIOCGWINSZ has a different value on macOS >>>>>> than on Linux. >>>>>> WINCH-SETS-⎕PW works without the patch on Linux. With Mike's first >>>>>> patch, it works the same way on both platforms. >>>>>> >>>>>> I'm a little ambivalent about out the second patch to provide a >>>>>> "priority". I like the way WINCH-SETS-⎕PW works as it's currently >>>>>> implemented. I tried using Mike's second patch but >>>>>> it didn't seem to work as I would have thought. So I backed it out. I >>>>>> would think there would be some additonal work to make it work as Mike >>>>>> wants. Personally having WINCH-SETS-⎕PW >>>>>> (which sets ⎕PW to the window size) is the ultimate override - you get >>>>>> what you're console column width is set for. Want 80? Set the console to >>>>>> 80. >>>>>> >>>>>> - paul >>>>>> >>>>>> >>>>>>> On Dec 23, 2024, at 10:26 AM, M.Hall <mgha1...@gmail.com >>>>>>> <mailto:mgha1...@gmail.com>> wrote: >>>>>>> >>>>>>> WINCH-SETS-⎕PW did not originally work, on macOS Sonoma 14.7.2. >>>>>>> Because macOS does not use the same TIOCGWINSZ magic number that was >>>>>>> hard-coded. >>>>>>> With the first patch, WINCH-SETS-⎕PW does now work on macOS. >>>>>>> >>>>>>> From my original email: >>>>>>> > I noticed that quad-pw wasn't changing with window resizes on macOS >>>>>>> > (Sonoma 14.7.2). >>>>>>> > Here's a patch; there's probably a better way to do it. >>>>>>> >>>>>>> On Mon, Dec 23, 2024 at 6:12 AM Dr. Jürgen Sauermann >>>>>>> <mail@jürgen-sauermann.de <mailto:mail@j%C3%BCrgen-sauermann.de>> wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> I am still not clear about whether the WINCH-SETS-⎕PW preference >>>>>>>> works or does not work on Mike's platform (which ?). Could someone >>>>>>>> please test that? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Jürgen >>>>>>>> >>>>>>>> >>>>>>>> On 12/22/24 20:03, M.Hall wrote: >>>>>>>>> Paul Rockwell writes: >>>>>>>>> >>>>>>>>> > There may be a side effect, though. With the option set and Mike's >>>>>>>>> > code inserted, ⎕PW will be set to whatever the current terminal >>>>>>>>> > width is, not the IBM APL2 default of 80. >>>>>>>>> >>>>>>>>> Yes. There are three settings that interact: >>>>>>>>> - command line "--PW xx" >>>>>>>>> - preferences "INITIAL-⎕PW xx" >>>>>>>>> - preferences "WINCH-SETS-⎕PW" >>>>>>>>> >>>>>>>>> The command line setting overrides all others. This makes sense to me. >>>>>>>>> >>>>>>>>> INITIAL-⎕PW is active when WINCH-SETS-⎕PW is off. Also, good. >>>>>>>>> >>>>>>>>> When WINCH-SETS-⎕PW is enabled, the code bypasses the INITIAL-⎕PW >>>>>>>>> setup. Hmmm. >>>>>>>>> >>>>>>>>> I think the user's INITIAL-⎕PW should be used at startup, even when >>>>>>>>> WINCH-SETS-⎕PW is enabled. >>>>>>>>> >>>>>>>>> So the startup priority would be (high to low): >>>>>>>>> - command line >>>>>>>>> - INITIAL-⎕PW >>>>>>>>> - then WINCH >>>>>>>>> - then default 80 columns >>>>>>>>> >>>>>>>>> Here's a patch for that, if you want (applied against the previous >>>>>>>>> patch): >>>>>>>>> >>>>>>>>> $ diff -u src/main-orig.cc src/main.cc >>>>>>>>> --- src/main-orig.cc 2024-12-19 13:20:04.000000000 -0600 >>>>>>>>> +++ src/main.cc 2024-12-22 10:11:42.000000000 -0600 >>>>>>>>> @@ -449,10 +452,8 @@ >>>>>>>>> sigaction(SIGWINCH, &new_WINCH_action, &old_WINCH_action); >>>>>>>>> signal_WINCH_handler(0); // pretend window size change >>>>>>>>> } >>>>>>>>> - else >>>>>>>>> - { >>>>>>>>> - Workspace::set_PW(UserPreferences::uprefs.initial_pw, LOC); >>>>>>>>> - } >>>>>>>>> + // honor the user's initial PW preference, even if WINCH is >>>>>>>>> enabled >>>>>>>>> + Workspace::set_PW(UserPreferences::uprefs.initial_pw, LOC); >>>>>>>>> >>>>>>>>> #if PARALLEL_ENABLED >>>>>>>>> memset(&new_control_BSL_action, 0, sizeof(struct sigaction)); >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Mike Hall >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Mike Hall >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Mike Hall >>>>> >>>>> >>>> >> >