BSD 4_3_Net_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 30 Apr 1991 09:01:48 +0000 (01:01 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 30 Apr 1991 09:01:48 +0000 (01:01 -0800)
Work on file usr/src/usr.bin/groff/grot/xditview/Imakefile.mit
Work on file usr/src/usr.bin/groff/grot/xditview/Makefile.gnu
Work on file usr/src/usr.bin/groff/grot/xditview/README
Work on file usr/src/usr.bin/groff/grot/xditview/Xditview.ad
Work on file usr/src/usr.bin/groff/grot/xditview/xdit.bm
Work on file usr/src/usr.bin/groff/grot/xditview/xdit_mask.bm
Work on file usr/src/usr.bin/groff/grot/xditview/xditview.c
Work on file usr/src/usr.bin/groff/grot/xditview/xditview.man

Synthesized-from: CSRG/cd2/net.2

usr/src/usr.bin/groff/grot/xditview/Imakefile.mit [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/Makefile.gnu [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/README [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/Xditview.ad [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/xdit.bm [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/xdit_mask.bm [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/xditview.c [new file with mode: 0644]
usr/src/usr.bin/groff/grot/xditview/xditview.man [new file with mode: 0644]

diff --git a/usr/src/usr.bin/groff/grot/xditview/Imakefile.mit b/usr/src/usr.bin/groff/grot/xditview/Imakefile.mit
new file mode 100644 (file)
index 0000000..fdf7169
--- /dev/null
@@ -0,0 +1,23 @@
+#define IHaveSubdirs
+#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
+       INCLUDES = -I$(TOP) -I$(TOP)/X11
+        XDVISRC = libXdvi
+        XDVILIB = $(XDVISRC)/libXdvi.a
+     DEPXDVILIB = $(XDVILIB)
+        DEPLIBS = $(DEPXDVILIB) $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
+LOCAL_LIBRARIES = $(XDVILIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
+  SYS_LIBRARIES = -lm
+          SRCS1 = xditview.c
+          OBJS1 = xditview.o
+          SRCS2 = xtotroff.c
+          OBJS2 = xtotroff.o
+       PROGRAMS = xditview xtotroff
+        SUBDIRS = libXdvi
+    CDEBUGFLAGS = -g -Bstatic
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+ComplexProgramTarget_1(xditview,$(LOCAL_LIBRARIES), /**/)
+SingleProgramTarget(xtotroff,$(OBJS2),$(XDVILIB) $(XLIB), /**/)
+InstallAppDefaults(Xditview)
diff --git a/usr/src/usr.bin/groff/grot/xditview/Makefile.gnu b/usr/src/usr.bin/groff/grot/xditview/Makefile.gnu
new file mode 100644 (file)
index 0000000..4d359c5
--- /dev/null
@@ -0,0 +1,49 @@
+CC=cc
+CFLAGS=-g
+LDFLAGS=-g -Bstatic
+RANLIB=ranlib
+AR=ar
+BINDIR=/usr/local/bin
+GROFFLIBDIR=/usr/local/lib/groff
+FONTDIR=$(GROFFLIBDIR)/font
+MACRODIR=$(GROFFLIBDIR)/tmac
+MANEXT=1
+MANDIR=/usr/local/man/man$(MANEXT)
+# Delete devX100 if you don't have 100dpi fonts installed.
+DEVICES=devX75 devX100
+
+all: xditview xtotroff
+
+xditview: xditview.o libXdvi/libXdvi.a
+       $(CC) $(LDFLAGS) -o $@ xditview.o libXdvi/libXdvi.a \
+       -lXaw -lXmu -lXt -lXext -lX11 -lm
+
+xtotroff: xtotroff.o libXdvi/libXdvi.a
+       $(CC) $(LDFLAGS) -o $@ xtotroff.o libXdvi/libXdvi.a \
+       -lXext -lX11 -lm
+
+clean:
+       -rm -f xditview xtotroff *.o core
+       @echo Making clean in libXdvi
+       @cd libXdvi; $(MAKE) clean
+
+libXdvi/libXdvi.a: FORCE
+       @echo Making all in libXdvi
+       @cd libXdvi; \
+       $(MAKE) "CC=$(CC)" "CFLAGS=$(CFLAGS)" "RANLIB=$(RANLIB)" "AR=$(AR)" \
+               libXdvi.a
+
+FORCE:
+
+xditview.o: libXdvi/Dvi.h xdit.bm xdit_mask.bm
+xtotroff.o: libXdvi/XFontName.h libXdvi/DviChar.h
+
+install: all
+       @for dir in $(DEVICES); do \
+       echo Making install in $$dir; \
+       (cd $$dir; $(MAKE) "FONTDIR=$(FONTDIR)" install); done
+       -[ -d $(MACRODIR) ] || mkdir $(MACRODIR)
+       cp tmac.X $(MACRODIR)
+       -[ -d $(BINDIR) ] || mkdir $(BINDIR)
+       cp xditview $(BINDIR)/gxditview
+       cp xditview.man $(MANDIR)/gxditview.$(MANEXT)
diff --git a/usr/src/usr.bin/groff/grot/xditview/README b/usr/src/usr.bin/groff/grot/xditview/README
new file mode 100644 (file)
index 0000000..1669311
--- /dev/null
@@ -0,0 +1,8 @@
+This is version of MIT's xditview from X11R4 modified to work better
+with groff.  You will need X11R4 in order to install it.  You will
+probably need to edit the Makefile.  Then just do a make and make
+install.  The make install runs xtotroff to generate the groff font
+files; it must be able to connect to an R4 server, so make sure the
+DISPLAY environment variable is set correctly when you do the make
+install.  The modified version probably won't work with ditroff, so
+you by default it's installed as gxditview.
diff --git a/usr/src/usr.bin/groff/grot/xditview/Xditview.ad b/usr/src/usr.bin/groff/grot/xditview/Xditview.ad
new file mode 100644 (file)
index 0000000..9c2eda7
--- /dev/null
@@ -0,0 +1,38 @@
+Xditview.paned.allowResize:            true
+Xditview.paned.viewport.allowVert:     true
+Xditview.paned.viewport.allowHoriz:    true
+Xditview.paned.viewport.skipAdjust:    false
+Xditview.paned.viewport.width:         600
+Xditview.paned.viewport.height:                800
+Xditview.paned.viewport.showGrip:      false
+Xditview.paned.label.skipAdjust:       true
+
+Xditview.paned.viewport.dvi.translations: #augment \
+       <Btn1Down>:     XawPositionSimpleMenu(menu) MenuPopup(menu)\n\
+       <Key>Next:      NextPage()\n\
+       <Key>Prior:     PreviousPage()\n\
+       <Key>Select:    SelectPage()\n\
+       <Key>Find:      OpenFile()
+Xditview.paned.label.translations: #augment \
+       <Btn1Down>:     XawPositionSimpleMenu(menu) MenuPopup(menu)\n\
+       <Key>Next:      NextPage()\n\
+       <Key>Prior:     PreviousPage()\n\
+       <Key>Select:    SelectPage()\n\
+       <Key>Find:      OpenFile()
+Xditview.menu.nextPage.label:          Next Page
+Xditview.menu.previousPage.label:      Previous Page
+Xditview.menu.selectPage.label:                Select Page
+Xditview.menu.openFile.label:          Open
+Xditview.menu.quit.label:              Quit
+
+Xditview.promptShell.allowShellResize: true
+Xditview.promptShell.promptDialog.value.translations: #override \
+       <Key>Return:    Accept()
+
+Xditview.promptShell.promptDialog.accept.label: Accept
+Xditview.promptShell.promptDialog.accept.translations: #override \
+       <BtnUp>:        Accept() unset()
+
+Xditview.promptShell.promptDialog.cancel.label: Cancel
+Xditview.promptShell.promptDialog.cancel.translations: #override \
+       <BtnUp>:        Cancel() unset()
diff --git a/usr/src/usr.bin/groff/grot/xditview/xdit.bm b/usr/src/usr.bin/groff/grot/xditview/xdit.bm
new file mode 100644 (file)
index 0000000..67b9c8a
--- /dev/null
@@ -0,0 +1,14 @@
+#define xdit_width 32
+#define xdit_height 32
+static char xdit_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x03, 0x02, 0x00, 0x00, 0x02,
+   0x8a, 0xa2, 0xfc, 0x03, 0x52, 0x14, 0x03, 0x04, 0x02, 0x80, 0x00, 0x08,
+   0x52, 0x54, 0x00, 0x10, 0x8a, 0x22, 0x8f, 0x23, 0x02, 0x20, 0x06, 0x21,
+   0x8a, 0x12, 0x8c, 0x40, 0x52, 0x14, 0x8c, 0x40, 0x02, 0x10, 0x58, 0x40,
+   0x52, 0x14, 0x30, 0x40, 0x8a, 0x12, 0x30, 0x40, 0x02, 0x10, 0x70, 0x40,
+   0x8a, 0x12, 0xc8, 0x40, 0x52, 0x24, 0xc4, 0xe0, 0x02, 0x20, 0x84, 0xe1,
+   0x52, 0x54, 0xce, 0xf3, 0x8a, 0xa2, 0x00, 0xf8, 0x02, 0x00, 0x03, 0xfc,
+   0x8a, 0x22, 0xfc, 0xf3, 0x52, 0x14, 0x00, 0xc2, 0x02, 0x00, 0x00, 0x02,
+   0x52, 0x14, 0x45, 0x02, 0x8a, 0xa2, 0x28, 0x02, 0x02, 0x00, 0x00, 0x02,
+   0x02, 0x00, 0x00, 0x02, 0xfe, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/usr/src/usr.bin/groff/grot/xditview/xdit_mask.bm b/usr/src/usr.bin/groff/grot/xditview/xdit_mask.bm
new file mode 100644 (file)
index 0000000..f34a4f8
--- /dev/null
@@ -0,0 +1,14 @@
+#define xdit_mask_width 32
+#define xdit_mask_height 32
+static char xdit_mask_bits[] = {
+   0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07,
+   0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x1f,
+   0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xc7,
+   0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07,
+   0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/usr/src/usr.bin/groff/grot/xditview/xditview.c b/usr/src/usr.bin/groff/grot/xditview/xditview.c
new file mode 100644 (file)
index 0000000..945633a
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * xditview -- 
+ *
+ *   Display ditroff output in an X window
+ */
+
+#ifndef lint
+static char rcsid[] = "$XConsortium: xditview.c,v 1.17 89/12/10 17:05:08 rws Exp $";
+#endif /* lint */
+
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Viewport.h>
+#include <X11/Xaw/Box.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Dialog.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSB.h>
+
+#include "libXdvi/Dvi.h"
+
+#include "xdit.bm"
+#include "xdit_mask.bm"
+#include "stdio.h"
+
+extern FILE *popen();
+extern void exit();
+
+/* Command line options table.  Only resources are entered here...there is a
+   pass over the remaining options after XtParseCommand is let loose. */
+
+static XrmOptionDescRec options[] = {
+{"-page",          "*dvi.pageNumber",      XrmoptionSepArg,    NULL},
+{"-backingStore",   "*dvi.backingStore",    XrmoptionSepArg,   NULL},
+{"-noPolyText",            "*dvi.noPolyText",      XrmoptionNoArg,     "TRUE"},
+};
+
+static char    current_file_name[1024];
+static FILE    *current_file;
+
+/*
+ * Report the syntax for calling xditview.
+ */
+
+static
+Syntax(call)
+       char *call;
+{
+       (void) printf ("Usage: %s [-fg <color>] [-bg <color>]\n", call);
+       (void) printf ("       [-bd <color>] [-bw <pixels>] [-help]\n");
+       (void) printf ("       [-display displayname] [-geometry geom]\n");
+       (void) printf ("       [-page <page-number>] [-backing <backing-store>]\n\n");
+       exit(1);
+}
+
+static void    NewFile (), SetPageNumber ();
+static Widget  toplevel, paned, viewport, dvi;
+static Widget  page;
+static Widget  simpleMenu;
+
+static void    NextPage(), PreviousPage(), SelectPage(), OpenFile(), Quit();
+
+static struct menuEntry {
+    char    *name;
+    void    (*function)();
+} menuEntries[] = {
+    "nextPage",            NextPage,
+    "previousPage", PreviousPage,
+    "selectPage",   SelectPage,
+    "openFile",            OpenFile,
+    "quit",        Quit,
+};
+
+static void    NextPageAction(), PreviousPageAction(), SelectPageAction();
+static void    OpenFileAction(), QuitAction();
+static void    AcceptAction(), CancelAction();
+
+XtActionsRec xditview_actions[] = {
+    "NextPage",            NextPageAction,
+    "PreviousPage", PreviousPageAction,
+    "SelectPage",   SelectPageAction,
+    "OpenFile",            OpenFileAction,
+    "Quit",        QuitAction,
+    "Accept",      AcceptAction,
+    "Cancel",      CancelAction,
+};
+
+#define MenuNextPage           0
+#define MenuPreviousPage       1
+#define MenuSelectPage         2
+#define MenuOpenFile           3
+#define        MenuQuit                4
+
+static char    pageLabel[256] = "Page <none>";
+
+void main(argc, argv)
+    int argc;
+    char **argv;
+{
+    char           *file_name = 0;
+    int                    i;
+    static Arg     labelArgs[] = {
+                       {XtNlabel, (XtArgVal) pageLabel},
+    };
+    Arg                    topLevelArgs[2];
+    Widget          entry;
+    Arg                    pageNumberArgs[1];
+    int                    page_number;
+
+    toplevel = XtInitialize("main", "Xditview",
+                           options, XtNumber (options),
+                           &argc, argv);
+    if (argc > 2)
+       Syntax(argv[0]);
+
+    XtAppAddActions(XtWidgetToApplicationContext(toplevel),
+                   xditview_actions, XtNumber (xditview_actions));
+
+    XtSetArg (topLevelArgs[0], XtNiconPixmap,
+             XCreateBitmapFromData (XtDisplay (toplevel),
+                                    XtScreen(toplevel)->root,
+                                    xdit_bits, xdit_width, xdit_height));
+                                   
+    XtSetArg (topLevelArgs[1], XtNiconMask,
+             XCreateBitmapFromData (XtDisplay (toplevel),
+                                    XtScreen(toplevel)->root,
+                                    xdit_mask_bits, 
+                                    xdit_mask_width, xdit_mask_height));
+    XtSetValues (toplevel, topLevelArgs, 2);
+    if (argc > 1)
+       file_name = argv[1];
+
+    /*
+     * create the menu and insert the entries
+     */
+    simpleMenu = XtCreatePopupShell ("menu", simpleMenuWidgetClass, toplevel,
+                                   NULL, 0);
+    for (i = 0; i < XtNumber (menuEntries); i++) {
+       entry = XtCreateManagedWidget(menuEntries[i].name, 
+                                     smeBSBObjectClass, simpleMenu,
+                                     NULL, (Cardinal) 0);
+       XtAddCallback(entry, XtNcallback, menuEntries[i].function, NULL);
+    }
+
+    paned = XtCreateManagedWidget("paned", panedWidgetClass, toplevel,
+                                   NULL, (Cardinal) 0);
+    viewport = XtCreateManagedWidget("viewport", viewportWidgetClass, paned,
+                                    NULL, (Cardinal) 0);
+    dvi = XtCreateManagedWidget ("dvi", dviWidgetClass, viewport, NULL, 0);
+    page = XtCreateManagedWidget ("label", labelWidgetClass, paned,
+                                       labelArgs, XtNumber (labelArgs));
+    XtSetArg (pageNumberArgs[0], XtNpageNumber, &page_number);
+    XtGetValues (dvi, pageNumberArgs, 1);
+    if (file_name)
+       NewFile (file_name);
+    XtRealizeWidget (toplevel);
+    if (file_name)
+       SetPageNumber (page_number);
+    XtMainLoop();
+}
+
+static void
+SetPageNumber (number)
+{
+    Arg        arg[2];
+    int        actual_number, last_page;
+
+    XtSetArg (arg[0], XtNpageNumber, number);
+    XtSetValues (dvi, arg, 1);
+    XtSetArg (arg[0], XtNpageNumber, &actual_number);
+    XtSetArg (arg[1], XtNlastPageNumber, &last_page);
+    XtGetValues (dvi, arg, 2);
+    if (actual_number == 0)
+       sprintf (pageLabel, "Page <none>");
+    else if (last_page > 0)
+       sprintf (pageLabel, "Page %d of %d", actual_number, last_page);
+    else
+       sprintf (pageLabel, "Page %d", actual_number);
+    XtSetArg (arg[0], XtNlabel, pageLabel);
+    XtSetValues (page, arg, 1);
+}
+
+static void
+SelectPageNumber (number_string)
+char   *number_string;
+{
+       SetPageNumber (atoi(number_string));
+}
+
+static int hadFile = 0;
+
+static void
+NewFile (name)
+char   *name;
+{
+    Arg            arg[2];
+    char    *n, *rindex ();
+    FILE    *new_file;
+    Boolean seek = 0;
+
+    if (current_file) {
+       if (!strcmp (current_file_name, "-"))
+           ;
+       else if (current_file_name[0] == '|')
+           pclose (current_file);
+       else
+           fclose (current_file);
+    }
+    if (!strcmp (name, "-"))
+       new_file = stdin;
+    else if (name[0] == '|')
+       new_file = popen (name+1, "r");
+    else {
+       new_file = fopen (name, "r");
+       seek = 1;
+    }
+    if (!new_file) {
+       /* XXX display error message */
+       return;
+    }
+    XtSetArg (arg[0], XtNfile, new_file);
+    XtSetArg (arg[1], XtNseek, seek);
+    XtSetValues (dvi, arg, 2);
+    if (hadFile || name[0] != '-' || name[1] != '\0') {
+       XtSetArg (arg[0], XtNtitle, name);
+       if (name[0] != '/' && (n = rindex (name, '/')))
+           n = n + 1;
+       else
+           n = name;
+       XtSetArg (arg[1], XtNiconName, n);
+       XtSetValues (toplevel, arg, 2);
+    }
+    hadFile = 1;
+    SelectPageNumber ("1");
+    strcpy (current_file_name, name);
+    current_file = new_file;
+}
+
+static char fileBuf[1024];
+
+ResetMenuEntry (entry)
+    Widget  entry;
+{
+    Arg        arg[1];
+
+    XtSetArg (arg[0], XtNpopupOnEntry, entry);
+    XtSetValues (XtParent(entry) , arg, (Cardinal) 1);
+}
+
+static void
+NextPage (entry, name, data)
+    Widget  entry;
+    caddr_t name, data;
+{
+    NextPageAction();
+    ResetMenuEntry (entry);
+}
+
+static void
+NextPageAction ()
+{
+    Arg        args[1];
+    int        number;
+
+    XtSetArg (args[0], XtNpageNumber, &number);
+    XtGetValues (dvi, args, 1);
+    SetPageNumber (number+1);
+}
+
+static void
+PreviousPage (entry, name, data)
+    Widget  entry;
+    caddr_t name, data;
+{
+    PreviousPageAction ();
+    ResetMenuEntry (entry);
+}
+
+static void
+PreviousPageAction ()
+{
+    Arg        args[1];
+    int        number;
+
+    XtSetArg (args[0], XtNpageNumber, &number);
+    XtGetValues (dvi, args, 1);
+    SetPageNumber (number-1);
+}
+
+static void
+SelectPage (entry, name, data)
+    Widget  entry;
+    caddr_t name, data;
+{
+    SelectPageAction ();
+    ResetMenuEntry (entry);
+}
+
+static void
+SelectPageAction ()
+{
+    MakePrompt (toplevel, "Page number", SelectPageNumber, "");
+}
+
+static void
+OpenFile (entry, name, data)
+    Widget  entry;
+    caddr_t name, data;
+{
+    OpenFileAction ();
+    ResetMenuEntry (entry);
+}
+
+static void
+OpenFileAction ()
+{
+    if (current_file_name[0])
+       strcpy (fileBuf, current_file_name);
+    else
+       fileBuf[0] = '\0';
+    MakePrompt (toplevel, "File to open:", NewFile, fileBuf);
+}
+
+static void
+Quit (entry, closure, data)
+    Widget  entry;
+    caddr_t closure, data;
+{
+    QuitAction ();
+}
+
+static void
+QuitAction ()
+{
+    exit (0);
+}
+
+Widget promptShell, promptDialog;
+void   (*promptfunction)();
+
+/* ARGSUSED */
+static
+void CancelAction (widget, event, params, num_params)
+    Widget     widget;
+    XEvent     *event;
+    String     *params;
+    Cardinal   *num_params;
+{
+    if (promptShell) {
+       XtSetKeyboardFocus(toplevel, (Widget) None);
+       XtDestroyWidget(promptShell);
+       promptShell = (Widget) 0;
+    }
+}
+
+
+/* ARGSUSED */
+static
+void AcceptAction (widget, event, params, num_params)
+    Widget     widget;
+    XEvent     *event;
+    String     *params;
+    Cardinal   *num_params;
+{
+    (*promptfunction)(XawDialogGetValueString(promptDialog));
+    CancelAction (widget, event, params, num_params);
+}
+
+MakePrompt(centerw, prompt, func, def)
+Widget centerw;
+char *prompt;
+void (*func)();
+char   *def;
+{
+    static Boolean true = TRUE;
+    static Arg dialogArgs[] = {
+       {XtNlabel, NULL},
+       {XtNvalue, NULL},
+    };
+    Arg valueArgs[1];
+    Arg centerArgs[2];
+    Position   source_x, source_y;
+    Position   dest_x, dest_y;
+    Dimension center_width, center_height;
+    Dimension prompt_width, prompt_height;
+    Widget  valueWidget;
+    
+    CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0);
+    promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass,
+                                     toplevel, NULL, (Cardinal) 0);
+    dialogArgs[0].value = (XtArgVal)prompt;
+    dialogArgs[1].value = (XtArgVal)def;
+    promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass,
+                   promptShell, dialogArgs, XtNumber (dialogArgs));
+    XawDialogAddButton(promptDialog, "accept", NULL, (caddr_t) 0);
+    XawDialogAddButton(promptDialog, "cancel", NULL, (caddr_t) 0);
+    valueWidget = XtNameToWidget (promptDialog, "value");
+    if (valueWidget) {
+       XtSetArg (valueArgs[0], XtNresizable, TRUE);
+       XtSetValues (valueWidget, valueArgs, 1);
+       /*
+        * as resizable isn't set until just above, the
+        * default value will be displayed incorrectly.
+        * rectify the situation by resetting the values
+        */
+        XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs));
+    }
+    XtSetKeyboardFocus (promptDialog, valueWidget);
+    XtSetKeyboardFocus (toplevel, valueWidget);
+    XtRealizeWidget (promptShell);
+    /*
+     * place the widget in the center of the "parent"
+     */
+    XtSetArg (centerArgs[0], XtNwidth, &center_width);
+    XtSetArg (centerArgs[1], XtNheight, &center_height);
+    XtGetValues (centerw, centerArgs, 2);
+    XtSetArg (centerArgs[0], XtNwidth, &prompt_width);
+    XtSetArg (centerArgs[1], XtNheight, &prompt_height);
+    XtGetValues (promptShell, centerArgs, 2);
+    source_x = (center_width - prompt_width) / 2;
+    source_y = (center_height - prompt_height) / 3;
+    XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y);
+    XtSetArg (centerArgs[0], XtNx, dest_x);
+    XtSetArg (centerArgs[1], XtNy, dest_y);
+    XtSetValues (promptShell, centerArgs, 2);
+    XtMapWidget(promptShell);
+    promptfunction = func;
+}
+
+/*
+Local Variables:
+c-indent-level: 4
+c-continued-statement-offset: 4
+c-brace-offset: -4
+c-argdecl-indent: 4
+c-label-offset: -4
+c-tab-always-indent: nil
+End:
+*/
diff --git a/usr/src/usr.bin/groff/grot/xditview/xditview.man b/usr/src/usr.bin/groff/grot/xditview/xditview.man
new file mode 100644 (file)
index 0000000..c443580
--- /dev/null
@@ -0,0 +1,106 @@
+.TH XDITVIEW 1 "Release 4" "X Version 11"
+.SH NAME
+xditview \(em display ditroff DVI files
+.SH SYNOPSIS
+.B xditview
+[-\fItoolkitoption\fP ...] [-option ...]
+.SH DESCRIPTION
+The
+.I xditview 
+program displays ditroff output on an X display.  It uses special
+font metrics which match the font set distributed with X11vR3, so
+it does not require access to the server machine for font loading.
+.SH OPTIONS
+.I Xditview
+accepts all of the standard X Toolkit command line options along with the 
+additional options listed below:
+.TP 8
+.B \-help
+This option indicates that a brief summary of the allowed options should be
+printed.
+.TP 8
+.B \-page
+This option specifies the page number of the document to be displayed.
+.TP 8
+.B \-backingStore \fIbacking-store-type\fP
+Redisplay of the DVI window can take upto a second or so, this option causes
+the server to save the window contents so that when it is scrolled around the
+viewport, the window is painted from contents saved in backing store. 
+\fIbacking-store-type\fP can be one of \fBAlways\fP, \fPWhenMapped\fP or
+\fPNotUseful\fP.
+.PP
+The following standard X Toolkit command line arguments are commonly used with 
+.I xditview:
+.TP 8
+.B \-bg \fIcolor\fP
+This option specifies the color to use for the background of the window.  
+The default is \fIwhite\fP.
+.TP 8
+.B \-bd \fIcolor\fP
+This option specifies the color to use for the border of the window.
+The default is \fIblack\fP.
+.TP 8
+.B \-bw \fInumber\fP
+This option specifies the width in pixels of the border surrounding the window.
+.TP 8
+.B \-fg \fIcolor\fP
+This option specifies the color to use for displaying text.  The default is 
+\fIblack\fP.
+.TP 8
+.B \-fn \fIfont\fP
+This option specifies the font to be used for displaying widget text.  The
+default is \fIfixed\fP.
+.TP 8
+.B \-rv
+This option indicates that reverse video should be simulated by swapping
+the foreground and background colors.
+.TP 8
+.B \-geometry \fIgeometry\fP
+This option specifies the preferred size and position of the window.
+.TP 8
+.B \-display \fIhost\fP:\fIdisplay\fP
+This option specifies the X server to contact.
+.TP 8
+.B \-xrm \fIresourcestring\fP
+This option specifies a resource string to be used.
+.SH X DEFAULTS
+This program uses the 
+.I Dvi
+widget in the X Toolkit.  It understands all of the core resource names and
+classes as well as:
+.PP
+.TP 8
+.B width (\fPclass\fB Width)
+Specifies the width of the window.
+.TP 8
+.B height (\fPclass\fB Height)
+Specifies the height of the window.
+.TP 8
+.B foreground (\fPclass\fB Foreground)
+Specifies the default foreground color.
+.TP 8
+.B font (\fPclass\fB Font)
+Specifies the font to be used for error messages.
+.SH "SEE ALSO"
+X(1), xrdb(1), ditroff(1)
+.SH BUGS
+.I Xditview
+can be easily confused by attempting to display a file constructed
+for the wrong device.
+.SH ORIGIN
+Portions of this program originated in xtroff which was derived
+from suntroff.  
+.SH COPYRIGHT
+Copyright 1989, Massachusetts Institute of Technology.
+.br
+See \fIX(1)\fP for a full statement of rights and permissions.
+.SH AUTHORS
+Keith Packard (MIT X Consortium)
+.br
+Richard L. Hyde (Purdue)
+.br
+David Slattengren (Berkeley)
+.br
+Malcom Slaney (Schlumberger Palo Alto Research)
+.br
+Mark Moraes (University of Toronto)