From jan@swi.psy.uva.nl Thu Sep 27 11:33:32 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8R9XWv06598;
	Thu, 27 Sep 2001 11:33:32 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f8R9XWW26768;
	Thu, 27 Sep 2001 11:33:32 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Sebastian Sardina <ssardina@cs.toronto.edu>, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] writing in another window
Date: Thu, 27 Sep 2001 11:27:32 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <3B65EA54.5AD6ADA4@cs.toronto.edu>
In-Reply-To: <3B65EA54.5AD6ADA4@cs.toronto.edu>
MIME-Version: 1.0
Message-Id: <0109271133320A.25592@gollem>
Content-Transfer-Encoding: 8bit

On Tue, 31 Jul 2001, Sebastian Sardina wrote:
>I use SWI on Linux. I know how to read from and write on files using
>the open, read, and write predicates with explicit streams.
>
>Now, I want to make my Prolog program to write messages in a special
>window.
>That is, I want to use a special Linux window to show special messages
>instead
>of showing them in the same window in which Prolog was called.
>
>I think my problem is how to create a named xterm window that I can
>refer from
>Prolog and write on it. Can anyone help me on that? Thanks a lot.

It requires a bit of C-hacking.  It is done in the file pl-xterm.c,
which deals with attaching an xterm to a Prolog thread for the
multi-threaded version.  This code is only used in the MT version,
but you could use it as an example for writing your own version
usable in the single-thread version.

Simpler though is to use XPCE:

open_window :-
	send(new(V, view('My output')), open),
	pce_open(V, write, Stream),
	set_stream(Stream, alias(my_out)),
	set_stream(Stream, buffer(line)).

?- format(my_out, 'Hello World~n', []).

You need 4.0.9 for the set_stream/2 support used here, but
of course you can also write your own wrapper to record the
stream reference and provide the required output buffering.

	Regards --- Jan

