Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!aurora!labrea!decwrl!cgofs.dec.com!drew From: drew@cgofs.dec.com (Steve Drew) Newsgroups: comp.sys.amiga Subject: Re: Shell 2.07 title bar hack Message-ID: <8801180431.AA23871@decwrl.dec.com> Date: 18 Jan 88 04:31:56 GMT Organization: Digital Equipment Corporation Lines: 87 > 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. > 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: Here's some of the code I'll include into shell 2.08m for directory string in title bar. Just to show how to get the window ptr of your current window. It does not rely on the window title bar string to contain AmigaDos ect..., but rather sends the ACTION_DISK_INFO to the console device which returns the window ptr in the Volume field. #include #include #include #include #include #define DOS_TRUE -1L /* Set_My_TitleBar() Steve Drew, 1988. * * (Assumes intuition.library already open.) * In Shell we could do this at init(); * like: #include struct IntuitionBase *IntuitionBase; init() { IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0L); if (IntuitionBase == 0L) exit(20); : : ect.... * * Find OUR window ptr via ACTION_DISK_INFO. * * For using to set current directory spec in title bar: * It would be best to set str to current directory * string from our cli structure, since that string * will still be allocated when our program exits. * Using the cwd string under shell, would be okay until * shell exits. * So at then end of do_pwd() in comm1.c change: movemem(cwd,ptr+1,(int)ptr[0]); to: strcpy(ptr+1,cwd); /* make BSTR but still NULL terminated */ Set_My_TitleBar(ptr+1); */ Set_My_TitleBar(str) char *str; { struct Process *mp; struct InfoData *id; long ret; char *wptr; id = (struct InfoData *) AllocMem((long)sizeof (struct InfoData), MEMF_CHIP | MEMF_CLEAR); if (id == 0) { return(0); } mp = (struct Process *)FindTask(0L); if (mp->pr_Task.tc_Node.ln_Type == NT_PROCESS && mp->pr_ConsoleTask) ret = dos_packet(mp->pr_ConsoleTask, ACTION_DISK_INFO, (ULONG)id>>2); if (ret == DOS_TRUE) { wptr = (char *)id->id_VolumeNode; if (wptr) { SetWindowTitles(wptr,str,-1L); } } FreeMem(id, (long) sizeof (struct InfoData)); } ============================================================================== Steve Drew at ENET: CGFSV1::DREW ARPA: drew%cfgsv1.dec.com@decwrl.dec.com USENET: {decvax!decwrl}!cgfsv1.dec.com!drew