Did you know ... Search Documentation:
portray_text.pl -- Portray text
PublicShow source

A Prolog string is a list of character-codes: (small) integers, which results in output like this:

?- writeln(`hello`).
[104, 101, 108, 108, 111]

Unless you know the Unicode tables by heart, this is pretty unpleasant for debugging. Loading this library makes the toplevel and debugger print strings with at least 3 characters as "text ...". Of course, this is an ambiguous operation because nobody can know whether [65,66] should be written as "AB" or a list: to Prolog they are the same. Therefore it is imported that the user is aware of the fact that this heuristic conversion is enabled. This is why this library must be loaded explicitly to enable this conversion.

To be done
- Allow setting the character-codes we try to convert
Source portray_text(+Boolean) is det
If true, write lists of character codes as "..." to simplify debugging.
Source set_portray_text(+Name, +Value) is det
Set options for writing lists as strings. Options are
Only consider lists that are at least this long
Write strings that are longer as "start...end"
 is_text_code(+Code:nonneg) is semidet[multifile]
Multifile hook that can be used to extend the set of character codes that is recognised as likely text. Default are non-control ASCII characters (9,10,13,32-126)
To be done
- we might be able to use the current locale to include the appropriate code page.
Source $portray_text_enabled(-Val)
Ask the current status of text portraying. Used by the graphical debugger.