Scrolling up and down in swipl-win does partly delete some of the contents in the window

  1. Scrolling up and down in swipl-win (GUI) does partly delete some of the contents of the upper part of the top-level prolog window.

  2. SWI-Prolog probably does not have any goals for console or display clearing (cls), moving to a user-specified point on the screen, accepting user input from a specific screen location, determining which keys on the keyboard have been pressed, etc.

I am trying to port an AI project from Arity Prolog to SWI-Prolog, but I haven’t succeeded due to the abovementioned issues encountered during the porting process.

Any help you can provide would be greatly appreciated. Thank you in advance.

Are we talking about swipl-win.exe on Windows? Note there is also a swipl-win for MacOS and Linux, but has an entirely different code base. I have occasionally seen this happen in the Windows version. A reproducible case would help.

swipl-win accepts a good deal of the ANSI escape sequences. You can implement cls as

cls :-
    format(user_error, '\e[3J\e[H\e[2J', []),
    format(user_error, '\e[3J\r', []).

It also supports moving around, color changes, bold, etc. Visual changes are supported by ansi_format/3.

You can read the keyboard key-by-key using with_tty_raw/1.

You can also modify the menu bar at the top.

You should be able to do most that you want. That could be fine for porting. For developing an interface I usually run Prolog as a web server and use a browser. The bundled xpce is old, a little deprecated, but can be another option, as well as using e.g. Python and the Janus library to connect it to Prolog.





|

  • |

Hi Jan,Thank you very much for your quick and beneficial response. I should have mentioned working on a Windows 11 Pro box.

You’re so right to suggest alternative implementation methods for the user interface. I need to port the user interface for my expert system. I wrote about it nearly thirty years ago during my doctoral studies in Arity Prolog, and SWI-Prolog seemed a perfect alternative among the other Prolog dialects for porting. However, xpce is out of the question for me.

The other point is that I could not locate short code snippets showing the use of built-in predicates in the SWI-Prolog reference manual (v9.2.9).

I’ll try out what you think. Should I use this email or the discussion forums for eventual contact?
Thank you.

Best Regards,
Burak S. Soyer

Jan Wielemaker via SWI-Prolog <notifications@swiprolog.discoursemail.com>, 19 Şub 2025 Çar, 19:36 tarihinde şunu yazdı:

Thanks for the picture, but I was more hoping for a sequence of things to do to get this picture in a reproducible way …

You are right that the docs have far too few examples. There is a pretty nice infrastructure for adding them, but someone has to write them :frowning: You may like to search through the installed system as many of the built-ins are used somewhere in the libraries.

That depends on the message. Any question (and answer) that may be of interest to others should go to the forum. Things like commercial use, request for commercial support, etc should use the swi-prolog.com contact email or direct messages in this forum.