[comp.sys.apollo] invoking the dm editor from inside a Bourne shell

ammon@Neon.Stanford.EDU (Daniel Ammon) (08/17/90)

Is there anyway to get a (Bourne) shell script to bring up a file
in the dm editor?  Right now I am calling vi, but I would also like
to be able to bring up the editor you get when pressing the EDIT key.

Thanks.

danny ammon
ammon@neon.stanford.edu

valante_g@apollo.HP.COM (Glen E Valante) (08/18/90)

In article <1990Aug16.231437.28459@Neon.Stanford.EDU>,
ammon@Neon.Stanford.EDU (Daniel Ammon) writes:
> 
> Is there anyway to get a (Bourne) shell script to bring up a file
> in the dm editor?  Right now I am calling vi, but I would also like
> to be able to bring up the editor you get when pressing the EDIT key.

from the shell, you can execute:

/com/xdmc ce <file_name>

The xdmc will execute a display manager command, and the ce is a create
edit.....

A help on Dm commands will give you some other ideas of things to try, like dr
to specify placement of the window and cv for a read only pad.

thanks,

--glen
-------------------------------------------------------------------------------
  Glen Valante                     | These are my opinions...
  Apollo / Hewlett-Packard         |    
  North American Customer Support  |
________________________________________________________________________
________

glenn@huxley.huxley.bitstream.com (Glenn P. Parker) (08/22/90)

In article <4c41b6e2.20b6d@apollo.HP.COM>,
valante_g@apollo.HP.COM (Glen E Valante) writes:
> In article <1990Aug16.231437.28459@Neon.Stanford.EDU>,
> ammon@Neon.Stanford.EDU (Daniel Ammon) writes:
>>
>> Is there anyway to get a (Bourne) shell script to bring up a file
>> in the dm editor?  Right now I am calling vi, but I would also like
>> to be able to bring up the editor you get when pressing the EDIT key.
> 
> from the shell, you can execute:
> 
> /com/xdmc ce <file_name>

Unfortunately, /com/xdmc only works if it is executed from an Apollo pad,
i.e. _not_ inside an xterm.  So, your script won't be as portable if you
use this technique.  You _can_ do the following:

/usr/bin/X11/dmwin /usr/apollo/bin/xdmc ce <absolute_path_name>

But this leaves a "scrap" DM window lying around.  Ah well, if you like the
DM editor, you probably don't care about xterms anyway...  :-/
--
--------------------------------------------------------------------------
Glenn P. Parker        Bitstream, Inc.
uunet!huxley!glenn     215 First Street
glenn@bitstream.com    Cambridge, MA 02142-1270

schneidr@cs.washington.edu (Scott Schneider) (08/22/90)

In article <GLENN.90Aug21184506@huxley.huxley.bitstream.com>, glenn@huxley.huxley.bitstream.com (Glenn P. Parker) writes:
> In article <4c41b6e2.20b6d@apollo.HP.COM>,
> valante_g@apollo.HP.COM (Glen E Valante) writes:
> > In article <1990Aug16.231437.28459@Neon.Stanford.EDU>,
> > ammon@Neon.Stanford.EDU (Daniel Ammon) writes:
> >>
> >> Is there anyway to get a (Bourne) shell script to bring up a file
> >> in the dm editor?  Right now I am calling vi, but I would also like
> >> to be able to bring up the editor you get when pressing the EDIT key.
> > 
> > from the shell, you can execute:
> > 
> > /com/xdmc ce <file_name>
> 
> Unfortunately, /com/xdmc only works if it is executed from an Apollo pad,
> i.e. _not_ inside an xterm.  So, your script won't be as portable if you
> use this technique.  You _can_ do the following:
> 
> /usr/bin/X11/dmwin /usr/apollo/bin/xdmc ce <absolute_path_name>
> 
> But this leaves a "scrap" DM window lying around.  Ah well, if you like the
> DM editor, you probably don't care about xterms anyway...  :-/

You can also modify the 'dmwin' source (/usr/X11/examples/dmwin) to create
an EDIT pad instead of a TRANSCRIPT pad so that it doesn't leave a "scrap"
DM window laying around.  It also creates the EDIT pad a lot faster.

Here are my modifications to DMWIN.  Note: the code is not very clean cuz
I was in a hurry.

---------------  dmedit.c  -----------------

pad_$window_desc_t      w_desc = {200,300,875,650};

main(
        int             argc,
        char            **argv,
        char            **envp
     )
{
 extern char     *optarg, *getenv(char *a);
        extern int      optind;
        status_$t       st;
        ios_$id_t       fd;
        char            **ep;
        char            sw;
        char            *infile;
        int     errflag = 0, rawflag = 0, i;

        infile = "/usr/tmp/tempfile";    /* default file if none passed */

 while ( (getopt( argc, argv, "?fh" )) != EOF )
          switch(sw)
   {
   case 'f':
           infile = argv[optind];
                  break;
          case 'h':
          case '?':
                  errflag++;
          }

   if (errflag)
          {
                fprintf( stderr, "usage: %s [-f filename]\n", argv[0] );
                exit(2);
          }

   /* create an edit pad */
   pad_$create_window (infile, (short)strlen(infile), pad_$edit, 1, w_desc, &fd, &st);
   if (st.all != status_$ok) {
                fprintf (stderr, "%s: could not create window\n", argv[0]);
                exit (1);
          }

        close (fd);
        exit (1);
}


> --
> --------------------------------------------------------------------------
> Glenn P. Parker        Bitstream, Inc.
> uunet!huxley!glenn     215 First Street
> glenn@bitstream.com    Cambridge, MA 02142-1270

Enjoy!

-- 
Scott Schneider                  
Boeing Commercial Airplane
schneidr@june.cs.washington.edu

sasjfp@unx.sas.com (Jeffrey L. Phillips) (08/24/90)

In article <4c41b6e2.20b6d@apollo.HP.COM> valante_g@APOLLO.HP.COM writes:
>In article <1990Aug16.231437.28459@Neon.Stanford.EDU>,
>ammon@Neon.Stanford.EDU (Daniel Ammon) writes:
>> 
>> Is there anyway to get a (Bourne) shell script to bring up a file
>> in the dm editor?  Right now I am calling vi, but I would also like
>> to be able to bring up the editor you get when pressing the EDIT key.
>
>from the shell, you can execute:
>
>/com/xdmc ce <file_name>

This is nice, but will not work from any foreign windows, ie. xterms.  This
will create an error like this:

?(xdmc)  Error executing DM command "ce" - stream is not a pad (display manager/Pad manager)

One way to get around this (if you use xterms, at least) is to prefix it with
/usr/bin/X11/dmwin.  This creates a DM window so that an 'xdmc' command can be 
executed.  Here is an example:

#!/bin/sh

/usr/bin/X11/dmwin /com/sh "xdmc 'ce $1'"

You may have to play with the quotes to get it right, but it works in foreign
windows like xterms.  Enjoy.
-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"Just because I don't know what it means doesn't mean I'm lying." 

     Jeff Phillips             Email: sasjfp@dev.sas.com