v03i035: Webster client, Part02/02

Mike Wexler mikew at wyse.wyse.com
Wed Mar 8 04:07:34 AEST 1989


Submitted-by: mayer at hplabs.hp.com (Niels P. Mayer)
Posting-number: Volume 3, Issue 35
Archive-name: xweb/part02

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  AUTHOR Makefile controlpanel.c patchlevel.h user_prefs.h
#   wordlist.c xwebster.h xwebster.man
# Wrapped by mikew at wyse on Tue Mar  7 10:04:00 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'AUTHOR' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(314 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X	Xwebster, A Dictionary Browser
X		Niels P. Mayer
X		Hewlett-Packard Laboratories
X		Software Technology Lab.
X-------------------------------------------------------------------------------
X	    Niels Mayer -- hplabs!mayer -- mayer at hplabs.hp.com
X		       Hewlett-Packard Laboratories
X			      Palo Alto, CA.
X				   *
END_OF_FILE
if test 314 -ne `wc -c <'AUTHOR'`; then
    echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(7074 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit Sun.macros to change
X
X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system:   SunOS 3.4
X
XBOOTSTRAPCFLAGS =
X             AS = as
X             CC = cc
X            CPP = /lib/cpp
X             LD = ld
X           LINT = lint
X        INSTALL = install
X           TAGS = ctags
X             RM = rm -f
X             MV = mv
X             LN = ln -s
X         RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -xz
X    LINTLIBFLAG = -C
X           MAKE = make
XSTD_CPP_DEFINES =
X    STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL =  /bin/sh
X
X        DESTDIR = /global
X      USRLIBDIR = $(DESTDIR)/lib
X         BINDIR = $(DESTDIR)/bin/X11
X         INCDIR = $(DESTDIR)/include
X         ADMDIR = $(DESTDIR)/usr/adm
X         LIBDIR = $(USRLIBDIR)/X11
X     LINTLIBDIR = $(USRLIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X          DTDIR = $(LIBDIR)/dt
X        MANPATH = /usr/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)n
X      LIBMANDIR = $(MANSOURCEPATH)n3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -m 4755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(BINDIR)/makedepend
X          IMAKE = $(BINDIR)/imake
X            RGB = $(LIBDIR)/rgb
X             FC = $(BINDIR)/bdftosnf
X      MKFONTDIR = $(BINDIR)/mkfontdir
X      MKDIRHIER = $(BINDIR)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) -L$(USRLIBDIR) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X
X       IRULESRC = $(LIBDIR)/imake.includes
X
X   EXTENSIONLIB = $(USRLIBDIR)/libext.a
X           XLIB = $(USRLIBDIR)/libX11.a
X         XMULIB = $(USRLIBDIR)/libXmu.a
X        OLDXLIB = $(USRLIBDIR)/liboldX.a
X       XTOOLLIB = $(USRLIBDIR)/libXt.a
X         XAWLIB = $(USRLIBDIR)/libXaw.a
X       LINTXLIB = $(USRLIBDIR)/lint/llib-lX11.ln
X        LINTXMU = $(USRLIBDIR)/lint/llib-lXmu.ln
X      LINTXTOOL = $(USRLIBDIR)/lint/llib-lXt.ln
X        LINTXAW = $(USRLIBDIR)/lint/llib-lXaw.ln
X       INCLUDES = -I$(INCDIR)
X      MACROFILE = Sun.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X#XWSRC         = $(CONTRIBSRC)/widgets/Xhp
X#INCLUDES      = -I$(XWSRC) -I$(TOP)
X# Define FAST_SERVER if you have an X server that is fast enough to make
X# sensitizing and desensitizing buttons non-painful. On Suns with the
X# MIT sample server, it is VERY painful.
XDEFINES       = -DAPPDEFAULTSDIR=\"$(XAPPLOADDIR)\" # -DFAST_SERVER
XCDEBUGFLAGS   = -g -O # +Nd4000 +Ns4000
XHDRS	      = user_prefs.h \
X		xwebster.h
XLOCAL_LIBRARIES = $(XWLIB) \
X		$(XTOOLLIB) \
X		$(XLIB)
XOBJS	      = controlpanel.o \
X		display_def.o \
X		wordlist.o \
X		xwebster.o
XSRCS	      = controlpanel.c \
X		display_def.c \
X		wordlist.c \
X		xwebster.c
X
X PROGRAM = xwebster
X
Xall:: xwebster
X
Xxwebster: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xwebster
X	$(INSTALL) -c $(INSTALLFLAGS) xwebster $(BINDIR)
X
Xinstall.man:: xwebster.man
X	$(INSTALL) -c $(INSTMANFLAGS) xwebster.man $(MANDIR)/xwebster.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X	@echo "making $@"; \
X	cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X	$(RM) $(PROGRAM)
X
Xinstall:: Xwebster.ad
X	$(INSTALL) -c $(INSTAPPFLAGS) Xwebster.ad $(XAPPLOADDIR)/Xwebster
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	- at if [ -f Makefile ]; then \
X	echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X	@echo "making $@"; \
X	cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 7074 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'controlpanel.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'controlpanel.c'\"
else
echo shar: Extracting \"'controlpanel.c'\" \(14667 characters\)
sed "s/^X//" >'controlpanel.c' <<'END_OF_FILE'
X/* -*-C-*-
X********************************************************************************
X*
X* File:         controlpanel.c
X* RCS:          $Header: controlpanel,v 1.7 88/09/13 17:19:48 mayer Exp $
X* Description:  Control Panel for Webster
X* Author:       Niels Mayer, HPLabs
X* Created:      Wed Aug 31 21:40:58 1988
X* Modified:     Tue Sep 13 15:44:00 1988 (Niels Mayer) mayer at hplnpm
X* Language:     C
X* Package:      N/A
X* Status:       G-Job
X*
X* xwebster - dictionary browser
X*
X* Copyright 1988 Hewlett-Packard Company
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appear in all copies and that both that
X* copyright notice and this permission notice appear in supporting
X* documentation, and that the name of HP not be used in advertising or
X* publicity pertaining to distribution of the software without specific,
X* written prior permission.  HP makes no representations about the
X* suitability of this software for any purpose.  It is provided "as is"
X* without express or implied warranty.
X*
X* Please send any improvements, bug fixes, useful modifications, and comments
X* to mayer at hplabs.hp.com.
X********************************************************************************
X*/
Xstatic char rcs_identity[] = "@(#)$Header: controlpanel,v 1.7 88/09/13 17:19:48 mayer Exp $";
X
X#include "xwebster.h"
X#include "user_prefs.h"
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <Xw/PButton.h>
X#include <Xw/SText.h>
X#include <Xw/TextEdit.h>
X#include <Xw/TitleBar.h>
X
Xstatic Widget control_panel_Wgt = NULL;
Xstatic Widget word_input_Wgt = NULL;
Xstatic Widget define_button_Wgt = NULL;
Xstatic Widget complete_button_Wgt = NULL;
Xstatic Widget endings_button_Wgt = NULL;
Xstatic Widget titlebar_Wgt = NULL;
Xstatic Widget quit_button_Wgt = NULL;
Xstatic Widget help_button_Wgt = NULL;
Xstatic int    controlpanel_active = TRUE;
Xstatic int    cur_word_is_from_textedit = TRUE;
X
X/******************************************************************************
X * note that this callback is used for 3 different callbacks:
X * 1) called from the controlpanel define_button_Wgt with client_data==NULL,
X *    this proc. assumes that word to be defined is in the word_input_Wgt.
X * 2) called from Controlpanel_Define_Action (which is a actionproc that is
X *    called from the word_input_Wgt) with client_data==NULL, this proc.
X *    again assumes that word to be defined is in the word_input_Wgt.
X * 3) called from a callback on a wordbutton_Wgt in module Wordlist, 
X *    client_data is set to the word to be defined. In this case, 
X *    subsequent calls to Controlpanel_Cur_Word_Is_From_TextEdit()
X *    will return false.
X ******************************************************************************/
XXtCallbackProc Controlpanel_Define_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  char buf[BUFSIZ];
X  extern int webster_Socket;	/* in main.c */
X
X  Display_Def_Text_Reset();	/* clear the def buffer to show text is coming */
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNset, TRUE);	/* show em which button they hit even if a key-*/
X  XtSetValues(define_button_Wgt, ARGLIST()); /*-action resulted in the callback*/
X  Controlpanel_Deactivate();	/* disallow further input till ready. */
X  
X  if (client_data == NULL) {	/* IF not called from Wordlist word button */
X    char* word;			/* THEN get the word from word_input_Wgt */
X    word = (char *) XwTextCopyBuffer(word_input_Wgt);
X    sscanf(word, "%[^\n]", temptext); /* get only one word, no newlines */
X    XtFree(word);
X    sprintf(buf, "DEFINE %s\r\n", temptext);
X    cur_word_is_from_textedit = TRUE;
X  }
X  else {			/* ELSE get the word from the callback data */
X    sprintf(buf, "DEFINE %s\r\n", (char*)client_data);
X    Controlpanel_Set_Input_Word((char*)client_data);
X    cur_word_is_from_textedit = FALSE;
X  }
X  WebsterSend(buf);
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic void Controlpanel_Define_Action(w, event, params, num_params)
X     Widget w;
X     XEvent *event;
X     String *params;
X     Cardinal *num_params;
X{
X  if (controlpanel_active)
X    Controlpanel_Define_Callback(w, NULL, NULL);
X  else
X    XBell(XtDisplay(w), 100);
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic XtCallbackProc Controlpanel_Complete_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  char buf[BUFSIZ];
X  extern int webster_Socket;	/* in main.c */
X  char* word;
X
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNset, TRUE);	/* show em which button they hit even if a key-*/
X  XtSetValues(complete_button_Wgt, ARGLIST()); /*-action resulted in the callback*/
X  Controlpanel_Deactivate();	/* disallow further input till ready. */
X  
X  word = (char *) XwTextCopyBuffer(word_input_Wgt);
X  sscanf(word, "%[^\n]", temptext); /* don't get newlines */
X  XtFree(word);
X  sprintf(buf, "COMPLETE %s\r\n", temptext);
X  cur_word_is_from_textedit = TRUE;
X
X  WebsterSend(buf);
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic void Controlpanel_Complete_Action(w, event, params, num_params)
X     Widget w;
X     XEvent *event;
X     String *params;
X     Cardinal *num_params;
X{
X  if (controlpanel_active)
X    Controlpanel_Complete_Callback(w, NULL, NULL);
X  else
X    XBell(XtDisplay(w), 100);
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic XtCallbackProc Controlpanel_Endings_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  char buf[BUFSIZ];
X  extern int webster_Socket;	/* in main.c */
X  char* word;
X
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNset, TRUE);	/* show em which button they hit even if a key-*/
X  XtSetValues(endings_button_Wgt, ARGLIST()); /*-action resulted in the callback*/
X  Controlpanel_Deactivate();	/* disallow further input till ready. */
X  
X  word = (char *) XwTextCopyBuffer(word_input_Wgt);
X  sscanf(word, "%[^\n]", temptext); /* get only one word, no newlines */
X  XtFree(word);
X  sprintf(buf, "ENDINGS %s\r\n", temptext);
X  cur_word_is_from_textedit = TRUE;
X
X  WebsterSend(buf);
X
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic void Controlpanel_Endings_Action(w, event, params, num_params)
X     Widget w;
X     XEvent *event;
X     String *params;
X     Cardinal *num_params;
X{
X  if (controlpanel_active)
X    Controlpanel_Endings_Callback(w, NULL, NULL);
X  else
X    XBell(XtDisplay(w), 100);
X}
X
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic XtCallbackProc Controlpanel_Quit_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  extern int webster_Socket;	/* in main.c */
X  close(webster_Socket);
X  exit(0);
X}
X
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic XtCallbackProc Controlpanel_Help_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  Display_Def_Show_Help();
X}
X
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic void Controlpanel_Noop_Action(w, event, params, num_params)
X     Widget w;
X     XEvent *event;
X     String *params;
X     Cardinal *num_params;
X{
X  XBell(XtDisplay(w), 100);
X}
X
X
XXtActionsRec word_input_Wgt_actions_table [] = {
X  {"webster-define-word",   Controlpanel_Define_Action},
X  {"webster-complete-word", Controlpanel_Complete_Action},
X  {"webster-list-endings",  Controlpanel_Endings_Action},
X  {"webster-no-op",         Controlpanel_Noop_Action},
X};
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Init(w)
X     Widget w;
X{
X  control_panel_Wgt = XtCreateManagedWidget("control_panel", 
X					    XwtitlebarWidgetClass, 
X					    w, NULL, 0);
X  word_input_Wgt = XtCreateManagedWidget("word_input", XwtexteditWidgetClass,
X					 control_panel_Wgt, NULL, 0);
X  { 
X    XFontStruct *font;
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNfont, &font);
X    XtGetValues(word_input_Wgt, ARGLIST());
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNheight, (Dimension) (FONTHEIGHT(font) + 6));
X    ARGLIST_ADD(XtNwidth,  (Dimension) (user_prefs.word_input_Wgt_width
X     * FONTWIDTH(font)));
X    XtSetValues(word_input_Wgt, ARGLIST());
X  }
X  XtAddActions(word_input_Wgt_actions_table, 
X	       XtNumber(word_input_Wgt_actions_table));
X  
X  define_button_Wgt = XtCreateManagedWidget("define_button", XwpushButtonWidgetClass, 
X					    control_panel_Wgt, NULL, 0);
X  XtAddCallback(define_button_Wgt, XtNselect, 
X		Controlpanel_Define_Callback, NULL);
X
X  complete_button_Wgt = XtCreateManagedWidget("complete_button", XwpushButtonWidgetClass, 
X					      control_panel_Wgt, NULL, 0);
X  XtAddCallback(complete_button_Wgt, XtNselect, 
X		Controlpanel_Complete_Callback, NULL);
X
X  endings_button_Wgt = XtCreateManagedWidget("endings_button", XwpushButtonWidgetClass, 
X					     control_panel_Wgt, NULL, 0);
X  XtAddCallback(endings_button_Wgt, XtNselect, 
X		Controlpanel_Endings_Callback, NULL);
X
X  {/*
X    * force the controlpanel to have no sash's -- do this by setting XtNmin
X    * and XtNmax constraint resources to the same values -- the height of the
X    * widget. See XWVPANED(3x) for details.
X    */
X    Dimension height;
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNheight, &height);
X    XtGetValues(control_panel_Wgt, ARGLIST());
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNmin, height); 
X    ARGLIST_ADD(XtNmax, height);
X    XtSetValues(control_panel_Wgt, ARGLIST());
X  }
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Titlebar_Init(parent_Wgt)
X     Widget parent_Wgt;
X{
X  extern char xwebster_version[];
X
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNstring, xwebster_version);
X  titlebar_Wgt = XtCreateManagedWidget("titlebar", XwtitlebarWidgetClass, 
X				       parent_Wgt, ARGLIST());
X  { /** force the title{back,fore}ground to be the same as {back,fore}ground**/
X    Pixel foreground, background;
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNforeground, &foreground);
X    ARGLIST_ADD(XtNbackground, &background);
X    XtGetValues(titlebar_Wgt, ARGLIST());
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNtitleForeground, foreground); 
X    ARGLIST_ADD(XtNtitleBackground, background);
X    XtSetValues(titlebar_Wgt, ARGLIST());
X  }
X  quit_button_Wgt = XtCreateManagedWidget("quit_button", XwpushButtonWidgetClass,
X					  titlebar_Wgt, NULL, 0);
X  XtAddCallback(quit_button_Wgt, XtNselect, Controlpanel_Quit_Callback, NULL);
X  
X  help_button_Wgt = XtCreateManagedWidget("help_button", XwpushButtonWidgetClass,
X					  titlebar_Wgt, NULL, 0);
X  XtAddCallback(help_button_Wgt, XtNselect, Controlpanel_Help_Callback, NULL);
X
X  {/*
X    * force the titlebar to have no sash's -- do this by setting XtNmin
X    * and XtNmax constraint resources to the same values -- the height of the
X    * widget. See XWVPANED(3x) for details.
X    */
X    Dimension height;
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNheight, &height);
X    XtGetValues(titlebar_Wgt, ARGLIST());
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNmin, height); 
X    ARGLIST_ADD(XtNmax, height);
X    XtSetValues(titlebar_Wgt, ARGLIST());    
X  }
X}
X
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Titlebar_Set_Label(str)
X     char* str;
X{
X  ARGLIST_RESET(); 
X  ARGLIST_ADD(XtNstring, str);
X  XtSetValues(titlebar_Wgt, ARGLIST());
X}
X
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Deactivate()
X{
X#ifdef FAST_SERVER
X  controlpanel_active = FALSE;
X
X  XtSetSensitive(define_button_Wgt, FALSE);
X  XtSetSensitive(complete_button_Wgt, FALSE);
X  XtSetSensitive(endings_button_Wgt, FALSE);
X  /* XtSetSensitive(quit_button_Wgt, FALSE); --> allow quit while server busy*/
X  XtSetSensitive(help_button_Wgt, FALSE);
X
X  Wordlist_Deactivate();
X#endif
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Reactivate()
X{
X#ifdef FAST_SERVER
X  controlpanel_active = TRUE;
X
X  XtSetSensitive(define_button_Wgt, TRUE);
X  XtSetSensitive(complete_button_Wgt, TRUE);
X  XtSetSensitive(endings_button_Wgt, TRUE);
X  /* XtSetSensitive(quit_button_Wgt, TRUE); */
X  XtSetSensitive(help_button_Wgt, TRUE);
X
X  /* the following is a lamo hack to fix a "feature" of PushButtons -- when they're
X     pressed, they invert colors. if the push callback then insensitizes them,
X     upon resensitizing they'll not invert back to the "off" color. So force them
X     off here. */
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNset, FALSE);
X  XtSetValues(define_button_Wgt, ARGLIST());
X  XtSetValues(complete_button_Wgt, ARGLIST());
X  XtSetValues(endings_button_Wgt, ARGLIST());
X  /*XtSetValues(quit_button_Wgt, ARGLIST());*/
X  /*XtSetValues(help_button_Wgt, ARGLIST());*/
X
X  Wordlist_Reactivate();
X#endif
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
XControlpanel_Set_Input_Word(word)
X     char* word;
X{
X  XwTextClearBuffer(word_input_Wgt);
X  XwTextInsert(word_input_Wgt, word);
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xint Controlpanel_Cur_Word_Is_From_TextEdit()
X{
X  return(cur_word_is_from_textedit);
X}
END_OF_FILE
if test 14667 -ne `wc -c <'controlpanel.c'`; then
    echo shar: \"'controlpanel.c'\" unpacked with wrong size!
fi
# end of 'controlpanel.c'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
END_OF_FILE
if test 21 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'user_prefs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'user_prefs.h'\"
else
echo shar: Extracting \"'user_prefs.h'\" \(1892 characters\)
sed "s/^X//" >'user_prefs.h' <<'END_OF_FILE'
X/* -*-C-*-
X********************************************************************************
X*
X* File:         user_prefs.h
X* RCS:          $Header: user_prefs.h,v 1.4 88/09/13 17:20:08 mayer Exp $
X* Description:  type definition and global datastructure for user preferences
X* Author:       Niels Mayer, HPLabs
X* Created:      Thu Aug 11 00:06:04 1988
X* Modified:     Tue Sep 13 15:34:34 1988 (Niels Mayer) mayer at hplnpm
X* Language:     C
X* Package:      N/A
X* Status:       G-Job
X*
X* xwebster - dictionary browser
X*
X* Copyright 1988 Hewlett-Packard Company
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appear in all copies and that both that
X* copyright notice and this permission notice appear in supporting
X* documentation, and that the name of HP not be used in advertising or
X* publicity pertaining to distribution of the software without specific,
X* written prior permission.  HP makes no representations about the
X* suitability of this software for any purpose.  It is provided "as is"
X* without express or implied warranty.
X*
X* Please send any improvements, bug fixes, useful modifications, and comments
X* to mayer at hplabs.hp.com.
X********************************************************************************
X*/
Xstatic char rcs_identity_user_prefs[] = "@(#)$Header: user_prefs.h,v 1.4 88/09/13 17:20:08 mayer Exp $";
X
Xtypedef struct {
X  String help_text;
X  String host_addr_list;	/* a list of whitespace separated host addrs */
X  int    host_port;
X  String host_service_name;
X  int    word_input_Wgt_width;
X  int    use_editor_as_display;	/* if TRUE use TextEdit, else StaticText */
X  int    display_width;
X  int    display_height;
X  int    num_words_before_refresh;
X} USER_PREFS_DATA, *USER_PREFS_DATA_PTR;
X
Xextern USER_PREFS_DATA user_prefs;
END_OF_FILE
if test 1892 -ne `wc -c <'user_prefs.h'`; then
    echo shar: \"'user_prefs.h'\" unpacked with wrong size!
fi
# end of 'user_prefs.h'
fi
if test -f 'wordlist.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wordlist.c'\"
else
echo shar: Extracting \"'wordlist.c'\" \(5470 characters\)
sed "s/^X//" >'wordlist.c' <<'END_OF_FILE'
X/* -*-C-*-
X********************************************************************************
X*
X* File:         wordlist.c
X* RCS:          $Header: wordlist.c,v 1.6 88/09/13 17:19:57 mayer Exp $
X* Description:  Module to display a list of words
X* Author:       Niels Mayer, HPLabs
X* Created:      Wed Aug 31 21:17:29 1988
X* Modified:     Tue Sep 13 15:40:30 1988 (Niels Mayer) mayer at hplnpm
X* Language:     C
X* Package:      N/A
X* Status:       G-Job
X*
X* xwebster - dictionary browser
X*
X* Copyright 1988 Hewlett-Packard Company
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appear in all copies and that both that
X* copyright notice and this permission notice appear in supporting
X* documentation, and that the name of HP not be used in advertising or
X* publicity pertaining to distribution of the software without specific,
X* written prior permission.  HP makes no representations about the
X* suitability of this software for any purpose.  It is provided "as is"
X* without express or implied warranty.
X*
X* Please send any improvements, bug fixes, useful modifications, and comments
X* to mayer at hplabs.hp.com.
X********************************************************************************
X*/
Xstatic char rcs_identity[] = "@(#)$Header: wordlist.c,v 1.6 88/09/13 17:19:57 mayer Exp $";
X
X#include "xwebster.h"
X#include "user_prefs.h"
X#include <Xw/SWindow.h>
X#include <Xw/RCManager.h>
X#include <Xw/PButton.h>
X
Xstatic Widget wordlist_Wgt = NULL;
Xstatic Widget wordlist_scroller_Wgt = NULL;
Xstatic Widget wordlist[2000];
Xstatic int    wordlist_base = 0; /* points to the first elt to be managed */
Xstatic int    wordlist_idx = 0;	/* points to the elt after last in wordlist */
X
Xextern XtCallbackProc Controlpanel_Define_Callback();
X
X/******************************************************************************
X *
X ******************************************************************************/
XWordlist_Init(parent_Wgt)
X     Widget parent_Wgt;
X{
X  wordlist_scroller_Wgt = XtCreateManagedWidget("wordlist_scroller", 
X						XwswindowWidgetClass,
X						parent_Wgt, NULL, 0);
X  wordlist_Wgt = XtCreateManagedWidget("wordlist", 
X				       XwrowColWidgetClass,
X				       wordlist_scroller_Wgt, NULL, 0);
X}
X
X
X/******************************************************************************
X * Clears all the buttons.
X ******************************************************************************/
XWordlist_Reset()
X{
X  register int i;
X
X  /*
X   * the following seems to prevent a ridiculous amount of display updating 
X   * thatwas occuring as each widget got deleted and others moved to fill the
X   * gap
X   */
X  XtUnmanageChildren(wordlist, wordlist_idx);
X
X  /*
X   * Now we can delete all the word widgets with a minimum of display noize
X   */
X  for (i=0; (i < wordlist_idx); i++) {
X    XtDestroyWidget(wordlist[i]);
X  }
X  wordlist_idx = 0;
X  wordlist_base = 0;
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
Xstatic XtCallbackProc Wordlist_Button_Destroy_Callback(widget, client_data, call_data)
X     Widget widget;
X     caddr_t client_data;
X     caddr_t call_data;
X{
X  XtFree(client_data);		/* frees the string containing the word */
X}
X
X/******************************************************************************
X *
X ******************************************************************************/
XWordlist_Add(str)
X     char* str;
X{
X  Widget wordbutton_Wgt;
X  char* word;
X
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNlabel, str);
X  wordbutton_Wgt = XtCreateWidget("word", XwpushButtonWidgetClass,
X			wordlist_Wgt, ARGLIST());
X  word = COPY_STRING(str);
X  XtAddCallback(wordbutton_Wgt, XtNselect, 
X		Controlpanel_Define_Callback, word);
X
X  XtAddCallback(wordbutton_Wgt, XtNdestroyCallback, /* on destroy, of Wgt, dealloc the word */
X		Wordlist_Button_Destroy_Callback, word);
X  XtSetSensitive(wordbutton_Wgt, FALSE);
X  wordlist[wordlist_idx++] = wordbutton_Wgt;
X
X  /*
X   * Refresh the display of words every <num_words_before_refresh> words
X   */
X  if ((wordlist_idx % user_prefs.num_words_before_refresh) == 0) {
X    XtManageChildren(&wordlist[wordlist_base], (wordlist_idx - wordlist_base));
X    wordlist_base += user_prefs.num_words_before_refresh;
X  }
X}
X
X/******************************************************************************
X * 
X ******************************************************************************/
XWordlist_Show()
X{
X  register int i;
X  
X  for (i=0; (i < wordlist_idx); i++) {
X    XtSetSensitive(wordlist[i], TRUE);
X  }
X  XtManageChildren(wordlist, wordlist_idx);
X}
X
X/******************************************************************************
X * Desensitizes wordlist buttons
X ******************************************************************************/
XWordlist_Deactivate()
X{
X  register int i;
X
X  for (i=0; (i < wordlist_idx); i++) {
X    XtSetSensitive(wordlist[i], FALSE);
X  }
X}
X
X/******************************************************************************
X * Resensitizes wordlist buttons
X ******************************************************************************/
XWordlist_Reactivate()
X{
X  register int i;
X
X  ARGLIST_RESET();
X  ARGLIST_ADD(XtNset, FALSE);
X  for (i=0; (i < wordlist_idx); i++) {
X    XtSetSensitive(wordlist[i], TRUE);
X    XtSetValues(wordlist[i], ARGLIST());
X  }
X}
END_OF_FILE
if test 5470 -ne `wc -c <'wordlist.c'`; then
    echo shar: \"'wordlist.c'\" unpacked with wrong size!
fi
# end of 'wordlist.c'
fi
if test -f 'xwebster.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xwebster.h'\"
else
echo shar: Extracting \"'xwebster.h'\" \(2358 characters\)
sed "s/^X//" >'xwebster.h' <<'END_OF_FILE'
X/* -*-C-*-
X********************************************************************************
X*
X* File:         xwebster.h
X* RCS:          $Header: xwebster.h,v 1.4 88/09/13 17:20:10 mayer Exp $
X* Description:  Miscellaneous macros
X* Author:       Niels Mayer, HPLabs
X* Created:      Wed Aug 31 14:09:08 1988
X* Modified:     Tue Sep 13 15:33:32 1988 (Niels Mayer) mayer at hplnpm
X* Language:     C
X* Package:      N/A
X* Status:       G-Job
X*
X* xwebster - dictionary browser
X*
X* Copyright 1988 Hewlett-Packard Company
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appear in all copies and that both that
X* copyright notice and this permission notice appear in supporting
X* documentation, and that the name of HP not be used in advertising or
X* publicity pertaining to distribution of the software without specific,
X* written prior permission.  HP makes no representations about the
X* suitability of this software for any purpose.  It is provided "as is"
X* without express or implied warranty.
X*
X* Please send any improvements, bug fixes, useful modifications, and comments
X* to mayer at hplabs.hp.com.
X********************************************************************************
X*/
Xstatic char rcs_identity_xwebster[] = "@(#)$Header: xwebster.h,v 1.4 88/09/13 17:20:10 mayer Exp $";
X
X#include <X11/Xos.h>
X#include <X11/StringDefs.h>
X#include <X11/Intrinsic.h>
X#include <Xw/Xw.h>
X
X
X/*----------------------------------------------------------------------------
X * Kludges to sweeten Xt's ugly argument processing for widget creation.
X *---------------------------------------------------------------------------*/
Xstatic Arg _args[100];
Xstatic int _num_args;
X
X#define ARGLIST_RESET() \
X  _num_args = 0
X
X#define ARGLIST_ADD(name, value) \
X  XtSetArg(_args[_num_args], (name), (value)); _num_args++
X
X#define ARGLIST_SET_LAST_ELT(name, value) \
X  XtSetArg(_args[(_num_args - 1)], (name), (value))
X
X#define ARGLIST() \
X  _args, _num_args
X
Xstatic char temptext[1024]; /* local text storage, mostly used for sprintf */
X
X#define FONTHEIGHT(f) ((f)->max_bounds.ascent + (f)->max_bounds.descent)
X#define FONTWIDTH(f)  (f)->max_bounds.width
X
X#define COPY_STRING(str) \
X  (char *) strcpy(XtMalloc((strlen(str)+1) * sizeof(char)), (str))
END_OF_FILE
if test 2358 -ne `wc -c <'xwebster.h'`; then
    echo shar: \"'xwebster.h'\" unpacked with wrong size!
fi
# end of 'xwebster.h'
fi
if test -f 'xwebster.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xwebster.man'\"
else
echo shar: Extracting \"'xwebster.man'\" \(3308 characters\)
sed "s/^X//" >'xwebster.man' <<'END_OF_FILE'
X.TH XWEBSTER 1 "December 1, 1988" "X Version 11"
X.SH NAME
Xxwebster \- X interface to look up words in the dictionary
X.SH SYNOPSIS
X.B xwebster
X[\fBX Toolkit option\fP]
X.SH DESCRIPTION
X.PP
X.B Xwebster
Xis used to look up words in the online copy of Webster's 7th
Xdictionary.  It puts up an application window that contains subwindows
Xto interact
Xwith the user and display the results. The top half has a browser window
Xin which alternative words will be shown, below that is a row of
Xwindows consisting of an interaction window where the user may enter
Xwords to be looked up, and buttons which the user may click on to
Xselect a program function. The lower window is used to display
Xthe definitions that are found.
X.PP
XJust type the word you want defined in the interaction window and hit
XReturn to see the definition (or click on the [Define] button).
XIf the word is found,
X.B xwebster
Xwill then provide the complete dictionary entry for the word including
Xdefinitions,
Xpronunciation,
Xand derivation.
XIf the specified word was not found,
X.B xwebster
Xwill try to find close matches,
Xas if you spelled the word wrong.
XThe possibilities are displayed in buttons.
XTo select one of them,
Xyou can just click on it.
X.PP
XAdditionally,
X.B xwebster
Xcan match words using wildcards.
XThe character
X`%' in a word means match exactly one character,
Xso ``w%n'' matches
X``win'',
X``won'',
X``wan'',
Xetc.
XThe character `*' matches
X.I "zero or more"
Xcharacters,
Xso ``a*d''matches
X``ad'',
X``and'',
X``abound'',
X``absentminded'',
Xand so on.
XAny number of wildcards can be used,
Xand in any arrangement.
X.PP
XTyping '?' or mousing [Endings] following part of a word will cause
Xxwebster to list all words beginning with the partial word in the word
Xbrowser panel. The program will beep and give an error message if nothing
Xmatches.
X.PP
XTyping <esc> or mousing [Complete] causes the program to attempt to
Xcomplete the word.  If the word can be completed, the new word is placed in
Xthe TextEdit widget; otherwise, the program beeps and displays a message
Xindicating that the word is ambiguous.
X.SH SEE ALSO
X.BR look (1),
X.BR spell (1),
X.BR webster (1)
X.BR websterd (8)
X.SH BUGS
X.PP
XThe first word takes a long time to define,
Xbecause there is a non-trivial (15 to 45 seconds) setup time
Xinvolved on initially starting the server.
X.PP
XThe translation between all the neat special characters in the dictionary
Xsuch as upside-down e's,
Xcedillas,
Xaccent marks,
Xetc. and a simple ASCII terminal is marginal at best.
XMost of the characters are fairly well faked,
Xbut a few of them are impossible.
XIn particular,
Xthe schwa (upside-down e) is represented by an asterisk.
X.PP
XOccasionally,
Xwhen you type a word to the prompt,
Xanother prompt appears without the word being defined.
XIf this happens,
Xtry typing the word again.
XIf it still doesn't work,
Xexit the program and start again.
X.SH FILES
X/usr/lib/X11/app-defaults/Xwebster
X.SH AUTHOR
XNiels Mayer (mayer at hplabs.hp.com)
X.SH BUGS
XThere are fixed internal limits on the number of words that can be
Xdisplayed in the browser, and the number of lines of text in the lower
Xwindow. The defaults should be adequate.
X.PP
XThere is no documentation on the available X defaults except in the 
Xfile /usr/lib/X11/app-defaults/Xwebster. Like most Toolkit programs, 
Xthis is just too configurable to document.
END_OF_FILE
if test 3308 -ne `wc -c <'xwebster.man'`; then
    echo shar: \"'xwebster.man'\" unpacked with wrong size!
fi
# end of 'xwebster.man'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list