# Tty\_get\_capability gives strange numbers

**URL:** <https://swi-prolog.discourse.group/t/tty-get-capability-gives-strange-numbers/9438>\
**Category:** Help!\
**Created:** [December 19, 2025, 5:39pm UTC](https://swi-prolog.discourse.group/t/tty-get-capability-gives-strange-numbers/9438 "2025-12-19T17:39:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hnbeck](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hnbeck/32/3149_2.png) [@hnbeck](https://swi-prolog.discourse.group/u/hnbeck)\
**Post date:** [December 19, 2025, 5:39pm UTC](https://swi-prolog.discourse.group/t/tty-get-capability-gives-strange-numbers/9438/1 "2025-12-19T17:39:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hnbeck](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hnbeck/32/3149_2.png) [@hnbeck](https://swi-prolog.discourse.group/u/hnbeck)\
**Post date:** [December 19, 2025, 7:43pm UTC](https://swi-prolog.discourse.group/t/tty-get-capability-gives-strange-numbers/9438/2 "2025-12-19T19:43:26Z")

</div>

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

```prolog
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

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 20, 2025, 11:51am UTC](https://swi-prolog.discourse.group/t/tty-get-capability-gives-strange-numbers/9438/3 "2025-12-20T11:51:57Z")

</div>

> [@hnbeck](#):
>
> ` process_create('/bin/stty', ['size'],`

A somewhat shorter version is this 🙂

```
?- 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](https://chatgpt.com/share/69468d8d-4a08-8011-b438-011ecb79e8be) Probably requires a chatgpt account ☹
