Tty_get_capability gives strange numbers

Hi,

I’m using SWI 10.0.0 on MacOS 15.5.
tty_get_capability(co, number , A) and tty_get_capability(li, number, B) should provide columns and rows of the current terminal. If I type this goals in the SWI GUI command line, then I get 80x24, independent how big or small I arrange the SWI window. (BTW this is the same using term package commands of TCL and running them in a Mac Terminal App).
Could someone explain me the reason and even more important, how to get the real number of columns and rows of the swish window?

Best

Hans

I found the way to ask the SWI window about the real size:

ttysize(C, R) :-
    setup_call_cleanup(
        process_create('/bin/stty', ['size'],
                       [ stdout(pipe(Out))
                       ]),
        read_string(Out, _, String),
         close(Out)),
        split_string(String, " ", "", [CStr, RStr]), 
        term_string(C, CStr),
        term_string(R, RStr).

This basic principle to fetch the output of a process was provided by @jan some posts earlier. In this way now I get the effective size in columns and rows of the swish as numbers.

But I’m still interested to learn why tty_get_capability (which in facts goes to termcap) gives fix 80x24….?

Best

Hans

A somewhat shorter version is this :slight_smile:

?- tty_size(Rows,Cols).

That works on all versions, including the Windows console and swipl-win terminal in Windows. On non-Windows it uses the ioctl() call and works on any tty, while the new swipl-win for non-Windows uses a pseudo-tty.

P.s. The SWI-Prolog assistent answers this flawlessly. See ChatGPT - Get Prolog console size Probably requires a chatgpt account :frowning:

1 Like