Checksum: 65208
Lines: 69
Path: utzoo!sq!hobie
From: hobie@sq.uucp (Hobie Orris)
Date: Thu, 14-Jan-88 22:59:23 EST
Message-ID: <1988Jan14.225923.6337@sq.uucp>
Newsgroups: comp.sys.amiga
Subject: Shell 2.07 title bar hack
Reply-To: hobie@sq.com (Hobie Orris)
Organization: Idiots Become Managers, Inc.
Keywords: D.I.Y.

	So, instead of whining and begging someone else to put the current 
directory in the Shell's title bar, I unshar'ed the source and did it myself.
It took me about an hour in all, but with these easy to follow instructions, 
anyone can have a whizzo title bar in about 10 minutes.  Instead of giving diffs
which I don't have the technology to do, I'll make you type it in.

	I couldn't find an elegant way for a task to find the address of the 
CLI window it's running in, so this is sort of ugly.  

	First of all, declare in globals.c (and as externs in shell.h):

		#include <intuition/intuition.h>
		
		struct Window *wb_window;
		long IntuitionBase;

	Next, in the routine init() in main.c, open the Intuition library and
and chase those windows until you find a likely one.  This checks for a window
title of "AmigaDOS" or "New CLI" and grabs a pointer to it. Like so:
#include <intuition/intution.h>
#include <functions.h>
init()
{
	ULONG wb_stuff[2];	/* little buffer to keep stuff in */

	[ the rest of init() goes here ]

	if (!(IntuitionBase = (long) OpenLibrary("intuition.library",0L))
	{
		puts("Gack! Cough! cough! Aggggh...\n") /* some error message */
		wb_window = NULL;
		return;	/* this results in no fun */
	}
	if (GetScreenData(wb_stuff, (long)sizeof(wb_stuff), 1L, 0L))
		wb_window = (struct Window *) wb_stuff[1]; /* get FirstWindow */
	while (wb_window != NULL)
	{
		if ((strncmp(wb_window->Title, "AmigaDOS",8) == 0) ||
		(strncmp(wb_winodw->Title, "New CLI",7) == 0))
			return;	/* HA! We got it */
		else
			wb_window = wb_window->NextWindow;
	}
	wb_window = NULL;	/* Can't find one, oh well, forget about it */
}
	
Now the window is firmly in our grasp.  All that remains is to change the title
bar every time current working directory changes.  Do this in the routine 
do_pwd() in file comm1.c:

do_pwd(str)
char *str;
{
	[ all of do_pwd() goes here except final return statement ]
	
	SetWindowTitles(wb_window, cwd, -1L);
	return(0);
}

Fanatical weenies may want to hunt down the proper places to close the intuition
library on abort and such, but I didn't bother.  That's all there is to it. My
fingers need never type `pwd' again, and I get to keep my austere `$' prompt.
I do have to roll my eyes upward to the title bar each time I need to see what
directory  I'm in, but what the hell; I need the exercise!


 Hobie Orris			| "I'm checking out of this bourgeois motel 
 guest of SoftQuad Inc. Toronto	| Push myself away from the dinner table and say
 utzoo!sq!hobie			| NO MORE JELLO FOR ME, MOM!"
