🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #13645

Help with Sunview file descriptor events

#13645
From: chris mcdonald
Date: Fri, 02 Feb 1990 07:50
85 lines
3067 bytes
I posted this just before Christmas but got no replies. Hopefully everyone
enjoyed their holiday and would now like to offer their help.

I would like a tty subwindow to receive an event when its underlying shell
writes some output to the window.  As far as my understanding goes, the
following code segment should come close, but not quite ...  My guess is
that if WIN_FD delivers the input fd, then fd+1 is the output descriptor
of the subwindow. This simple bit of code should (I think) just beep when
the shell writes to the window (the first prompt?).

Any help muchly appreciated; if you can answer this in terms of the source
of contool that will be fine, though that uses its own pseudo terminal to
detect the output. Thanks for your help.

Chris McDonald.

Department of Computer Science,   ACSnet:   chris@wacsvax.oz
University of Western Australia,  ARPA:     chris%wacsvax.oz@uunet.uu.net
Mounts Bay Road,                  UUCP:     ..!uunet!murtoa!wacsvax!chris
Crawley, Western Australia, 6009. SDI:      (31.97 +/-10% S, 115.81 +/-10% E)
PHONE:  (09) 380 2533             OVERSEAS: +61 9 380 2533

***** Cut Here *****

#include <stdio.h>
#include <strings.h>
#include <suntool/sunview.h>
#include <suntool/tty.h>

int	ttysw_fd;

static	Frame			base_frame;
static	Icon			tool_icon;
static	Tty			ttysw;
static	Notify_client		client;

Notify_value	output_func();

static short tty_image[258] = {
#include <images/terminal.icon>
};
mpr_static(tty_pixrect, 64, 64, 1, tty_image);

main(argc,argv) int argc; char **argv;
{
	char	*ttyname();

	base_frame = window_create((Window)NULL, FRAME,
			FRAME_NO_CONFIRM,	TRUE,
			FRAME_ARGC_PTR_ARGV,	&argc, argv,
			0);
	++argv;
	ttysw = window_create(base_frame,	TTY,
		  	TTY_ARGV,		argv,
		  	TTY_QUIT_ON_CHILD_DEATH,TRUE,
		  	0);
	ttysw_fd	= (int) window_get(ttysw, WIN_FD) + 1;
/*
	If WIN_FD delivers the input fd,
	then I guess fd+1 is the output descriptor (?).
 */
	tool_icon = icon_create(
			ICON_IMAGE,		&tty_pixrect,
			ICON_LABEL,		ttyname(ttysw_fd)+5,
			0);
	(void) window_set(base_frame,
			FRAME_LABEL,		ttyname(ttysw_fd),
			FRAME_ICON,		tool_icon,
			0);

	notify_set_event_func(client, output_func, NOTIFY_SAFE);
	notify_set_output_func(client, output_func, ttysw_fd);
	window_main_loop(base_frame);
	exit(0);
}

Notify_value	output_func(who,fd)
Notify_client	who;
int		fd;
{
    (void) window_bell(base_frame);
    (void) printf("in output_func, ttysw_fd=%d, fd=%d\n",ttysw_fd,fd);
    notify_set_output_func(who, NOTIFY_FUNC_NULL, fd);
    return(NOTIFY_DONE);
}
Technical Details
Message-ID: <4743@brazos.Rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!iuvax!mailrus!cs.utexas.edu!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!iuvax!mailrus!cs.utexas.edu!rice!sun-spots-request
From: chris@wacsvax.uwa.oz.au (chris mcdonald)
Newsgroups: comp.sys.sun
Subject: Help with Sunview file descriptor events
Keywords: Windows
Message-ID: <4743@brazos.Rice.edu>
Date: 2 Feb 90 07:50:41 GMT
Sender: root@rice.edu
Organization: Sun-Spots
Lines: 85
Approved: Sun-Spots@rice.edu
X-Sun-Spots-Digest: Volume 9, Issue 28, message 5 of 11