From sam@blanche.ICS.UCI.EDU Wed Jun 28 15:13:32 1989
To: mayer@hplabs.hp.COM
Subject: New xwebster features
Reply-To: Sam Horrocks <sam@ics.UCI.EDU>
Date: Wed, 28 Jun 89 15:08:45 -0700
Message-Id: <12090.615074925@blanche.ics.uci.edu>
From: Sam Horrocks <sam@blanche.ICS.UCI.EDU>

I've added a couple of new features to xwebster and I'm sending you the
patches.  I've added a button to do spelling of the word (alternate spellings
appear in the upper window) and I've added a toggle to put xwebster into
thesaurus mode.  Here are the diffs:

: Remove anything above this line.
: This is a shar archieve.  Extract with sh, not csh.
: The rest of this file will extract:
: xwebster.diffs
echo extracting - xwebster.diffs
sed 's/^X//' > xwebster.diffs << '/*EOF'
X*** /tmp/,RCSt1a11790	Wed Jun 28 14:27:31 1989
X--- xwebster.man	Wed Jun 28 14:22:32 1989
X***************
X*** 50,55 ****
X--- 50,65 ----
X  attempt to complete the word.  If the word can be completed, the new word
X  is placed in the TextEdit widget; otherwise, the program beeps and displays
X  a message indicating that the word is ambiguous.
X+ .PP
X+ Typing \fB'.'\fP or mousing \fB[Spell]\fP causes the program to look up
X+ alternate ways to spell what you just typed.  The list of spellings will be
X+ displayed in the browser panel.
X+ .PP
X+ Clicking the \fBThesaurus\fP toggle will cause all further lookups to occur in
X+ the thesaurus.  While in thesaurus mode \fB[Define]\fP will display the
X+ thesaurus entry for the word typed.  Spelling, completion and endings should
X+ not be done in the thesaurus mode since the number of words in the thesaurus
X+ is usually smaller than the number of words in the dictionary.
X  .SH CUSTOMIZING
X  All the resources for \fIxwebster\fP are specified in the application
X  default file Xwebster.ad, which MUST be installed in
X*** /tmp/,RCSt1a11804	Wed Jun 28 14:29:00 1989
X--- Xwebster.ad	Wed Jun 28 14:22:26 1989
X***************
X*** 46,55 ****
X--- 46,63 ----
X  xwebster to list all words beginning with the partial word in the word\n\
X  browser panel. The program will beep and give an error message if nothing\n\
X  matches.\n\n\
X+ Typing '.' or mousing [Spell] causes the program to look up alternate ways to\n\
X+ spell what you just typed.  The list of spellings will be displayed in the\n\
X+ browser panel.\n\n\
X  Typing <esc> or mousing [Complete] causes the program to attempt to\n\
X  complete the word.  If the word can be completed, the new word is placed in\n\
X  the TextEdit widget; otherwise, the program beeps and displays a message\n\
X  indicating that the word is ambiguous.\n\n\
X+ Clicking the Thesaurus toggle will cause all further lookups to occur in the\n\
X+ thesaurus.  While in thesaurus mode [Define] will display the thesaurus entry\n\
X+ for the word typed.  Spelling, completion and endings should not be done in the\n\
X+ thesaurus mode since the number of words in the thesaurus is usually smaller\n\
X+ than the number of words in the dictionary.\n\n\
X  In all the above cases, the wildcard characters '%' and '*' may be used to\n\
X  specify partial words. The '%' character matches exactly one character,\n\
X  while the '*' matches zero or more characters.  If wildcards are used, the\n\
X***************
X*** 271,276 ****
X--- 279,285 ----
X  # *panel.titlebar.PushButton.highlightColor: white
X  *panel.titlebar.PushButton.highlightTile: 50_foreground
X  *panel.titlebar.PushButton.font: variable
X+ *panel.titlebar.Toggle.font: variable
X  
X  *panel.titlebar.quit_button.label: Quit
X  *panel.titlebar.quit_button.region: Left
X***************
X*** 284,289 ****
X--- 293,301 ----
X  # *panel.titlebar.help_button.rPadding: 2
X  # *panel.titlebar.help_button.precedence: 1
X  
X+ *panel.titlebar.toggle_button.label: Thesaurus
X+ *panel.titlebar.toggle_button.region: Right
X+ 
X  ###############################################################################
X  # *panel.wordlist_scroller -- XwswindowWidgetClass
X  #
X***************
X*** 352,363 ****
X  # *panel.control_panel.complete_button.lPadding: 2
X  # *panel.control_panel.complete_button.rPadding: 2
X  
X! *panel.control_panel.endings_button.label: Endings <?>
X  *panel.control_panel.endings_button.region: Center
X  *panel.control_panel.endings_button.precedence: 1
X  # *panel.control_panel.endings_button.lPadding: 2
X  # *panel.control_panel.endings_button.rPadding: 2
X  
X  #
X  # *panel.control_panel.word_input -- XwtexteditWidgetClass
X  #
X--- 364,381 ----
X  # *panel.control_panel.complete_button.lPadding: 2
X  # *panel.control_panel.complete_button.rPadding: 2
X  
X! *panel.control_panel.endings_button.label: Endings '?'
X  *panel.control_panel.endings_button.region: Center
X  *panel.control_panel.endings_button.precedence: 1
X  # *panel.control_panel.endings_button.lPadding: 2
X  # *panel.control_panel.endings_button.rPadding: 2
X  
X+ *panel.control_panel.spell_button.label: Spell '.'
X+ *panel.control_panel.spell_button.region: Center
X+ *panel.control_panel.spell_button.precedence: 1
X+ # *panel.control_panel.spell_button.lPadding: 2
X+ # *panel.control_panel.spell_button.rPadding: 2
X+ 
X  #
X  # *panel.control_panel.word_input -- XwtexteditWidgetClass
X  #
X***************
X*** 387,392 ****
X--- 405,413 ----
X  *panel.control_panel.word_input.translations: \
X       <Key>Return:		webster-define-word() \n\
X       <Key>Escape:		webster-complete-word() \n\
X+      <Key>Tab:			webster-complete-word() \n\
X+      Ctrl<Key>I:		webster-complete-word() \n\
X+      <Key>.:			webster-spell-word() \n\
X       <Key>?:			webster-list-endings() \n\
X       Shift<Key>/:		webster-list-endings() \n\
X       Ctrl<Key>M:		webster-no-op() \n\
X*** /tmp/,RCSt1a11812	Wed Jun 28 14:30:18 1989
X--- controlpanel.c	Wed Jun 28 14:22:27 1989
X***************
X*** 40,45 ****
X--- 40,46 ----
X  #include <Xw/SText.h>
X  #include <Xw/TextEdit.h>
X  #include <Xw/TitleBar.h>
X+ #include <Xw/Toggle.h>
X  
X  static Widget control_panel_Wgt = NULL;
X  static Widget word_input_Wgt = NULL;
X***************
X*** 46,53 ****
X--- 47,56 ----
X  static Widget define_button_Wgt = NULL;
X  static Widget complete_button_Wgt = NULL;
X  static Widget endings_button_Wgt = NULL;
X+ static Widget spell_button_Wgt = NULL;
X  static Widget titlebar_Wgt = NULL;
X  static Widget quit_button_Wgt = NULL;
X+ static Widget toggle_button_Wgt = NULL;
X  static Widget help_button_Wgt = NULL;
X  static int    controlpanel_active = TRUE;
X  static int    cur_word_is_from_textedit = TRUE;
X***************
X*** 206,211 ****
X--- 209,259 ----
X  /******************************************************************************
X   *
X   ******************************************************************************/
X+ static XtCallbackProc Controlpanel_Spell_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+   char* word;
X+   extern Display* display;
X+ 
X+   if (!controlpanel_active) {
X+     XBell(display, 100);
X+     return(NULL);
X+   }
X+   
X+   ARGLIST_RESET();
X+   ARGLIST_ADD(XtNset, TRUE);	/* show em which button they hit even if a key-*/
X+   XtSetValues(spell_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, "SPELL %s\r\n", temptext);
X+   cur_word_is_from_textedit = TRUE;
X+ 
X+   if (!Webster_Send(buf))
X+     Controlpanel_Reactivate();
X+ }
X+ 
X+ /******************************************************************************
X+  *
X+  ******************************************************************************/
X+ static void Controlpanel_Spell_Action(w, event, params, num_params)
X+      Widget w;
X+      XEvent *event;
X+      String *params;
X+      Cardinal *num_params;
X+ {
X+   Controlpanel_Spell_Callback(w, NULL, NULL);
X+ }
X+ 
X+ 
X+ /******************************************************************************
X+  *
X+  ******************************************************************************/
X  static XtCallbackProc Controlpanel_Quit_Callback(widget, client_data, call_data)
X       Widget widget;
X       caddr_t client_data;
X***************
X*** 222,227 ****
X--- 270,297 ----
X  }
X  
X  
X+ static XtCallbackProc Controlpanel_Toggle_Callback(widget, client_data, call_data)
X+     Widget widget;
X+     caddr_t client_data;
X+     caddr_t call_data;
X+ {
X+     static havesetit = 0;
X+     int state = (int) call_data;
X+     char buf[BUFSIZ];
X+ 
X+   if (!controlpanel_active) {
X+     XBell(display, 100);
X+     return(NULL);
X+   }
X+ 
X+   sprintf(buf, "INDEX %s\r\n", client_data);
X+   if (!Webster_Send(buf)) {
X+     Controlpanel_Deactivate();
X+   }
X+ }
X+ 
X+ 
X+ 
X  /******************************************************************************
X   *
X   ******************************************************************************/
X***************
X*** 260,265 ****
X--- 330,336 ----
X    {"webster-define-word",   Controlpanel_Define_Action},
X    {"webster-complete-word", Controlpanel_Complete_Action},
X    {"webster-list-endings",  Controlpanel_Endings_Action},
X+   {"webster-spell-word",    Controlpanel_Spell_Action},
X    {"webster-no-op",         Controlpanel_Noop_Action},
X  };
X  
X***************
X*** 303,308 ****
X--- 374,384 ----
X    XtAddCallback(endings_button_Wgt, XtNselect, 
X  		Controlpanel_Endings_Callback, NULL);
X  
X+   spell_button_Wgt = XtCreateManagedWidget("spell_button", XwpushButtonWidgetClass, 
X+ 					     control_panel_Wgt, NULL, 0);
X+   XtAddCallback(spell_button_Wgt, XtNselect, 
X+ 		Controlpanel_Spell_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***************
X*** 326,331 ****
X--- 402,415 ----
X       Widget parent_Wgt;
X  {
X    extern char xwebster_version[];
X+   static XtCallbackRec toggleCallback_on[] = {
X+     { (void (*)())Controlpanel_Toggle_Callback, "thesaurus" },
X+     { NULL, (caddr_t)NULL},
X+   };
X+   static XtCallbackRec toggleCallback_off[] = {
X+     { (void (*)())Controlpanel_Toggle_Callback, "dictionary" },
X+     { NULL, (caddr_t)NULL},
X+   };
X  
X    ARGLIST_RESET();
X    ARGLIST_ADD(XtNstring, xwebster_version);
X***************
X*** 342,347 ****
X--- 426,440 ----
X      ARGLIST_ADD(XtNtitleBackground, background);
X      XtSetValues(titlebar_Wgt, ARGLIST());
X    }
X+ 
X+   /* Create the dictionary/thesaurus toggle */
X+   toggle_button_Wgt = XtCreateManagedWidget("toggle_button",
X+       XwtoggleWidgetClass, titlebar_Wgt, NULL, 0);
X+   ARGLIST_RESET();
X+   ARGLIST_ADD(XtNselect, toggleCallback_on);
X+   ARGLIST_ADD(XtNrelease, toggleCallback_off);
X+   XtSetValues(toggle_button_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*** 390,397 ****
X--- 483,492 ----
X    XtSetSensitive(define_button_Wgt, FALSE);
X    XtSetSensitive(complete_button_Wgt, FALSE);
X    XtSetSensitive(endings_button_Wgt, FALSE);
X+   XtSetSensitive(spell_button_Wgt, FALSE);
X    /* XtSetSensitive(quit_button_Wgt, FALSE); --> allow quit while server busy*/
X    XtSetSensitive(help_button_Wgt, FALSE);
X+   XtSetSensitive(toggle_button_Wgt, FALSE);
X    Wordlist_Deactivate();
X  #endif
X  }
X***************
X*** 407,414 ****
X--- 502,511 ----
X    XtSetSensitive(define_button_Wgt, TRUE);
X    XtSetSensitive(complete_button_Wgt, TRUE);
X    XtSetSensitive(endings_button_Wgt, TRUE);
X+   XtSetSensitive(spell_button_Wgt, TRUE);
X    /* XtSetSensitive(quit_button_Wgt, TRUE); */
X    XtSetSensitive(help_button_Wgt, TRUE);
X+   XtSetSensitive(toggle_button_Wgt, TRUE);
X    Wordlist_Reactivate();
X  #endif
X  
X***************
X*** 423,428 ****
X--- 520,526 ----
X    XtSetValues(define_button_Wgt, ARGLIST());
X    XtSetValues(complete_button_Wgt, ARGLIST());
X    XtSetValues(endings_button_Wgt, ARGLIST());
X+   XtSetValues(spell_button_Wgt, ARGLIST());
X    /*XtSetValues(quit_button_Wgt, ARGLIST());*/
X    /*XtSetValues(help_button_Wgt, ARGLIST());*/
X  }
X*** /tmp/,RCSt1a11826	Wed Jun 28 14:32:56 1989
X--- xwebster.c	Wed Jun 28 14:22:31 1989
X***************
X*** 266,272 ****
X        Controlpanel_Reactivate(); /* ready for user input */
X        /* webster_state = WEBSTER_READY; */
X      }
X!     else if (strncmp(line, "MATCHS 0\n", 9) == 0) { /* returned by ENDINGS */
X        XBell(display, 100);
X        Controlpanel_Titlebar_Set_Label("No matching words!");
X        Wordlist_Reset();
X--- 266,274 ----
X        Controlpanel_Reactivate(); /* ready for user input */
X        /* webster_state = WEBSTER_READY; */
X      }
X!     else if (strncmp(line, "MATCHS 0\n", 9) == 0 ||  /* returned by ENDINGS */
X! 	     strncmp(line, "SPELLING 0\n", 11) == 0) /* returned by SPELL */
X!     {
X        XBell(display, 100);
X        Controlpanel_Titlebar_Set_Label("No matching words!");
X        Wordlist_Reset();
X***************
X*** 273,279 ****
X        Controlpanel_Reactivate(); /* ready for user input */
X        /* webster_state = WEBSTER_READY; */
X      }      
X!     else if (strncmp(line, "MATCHS\n", 7) == 0) { /* returned by ENDINGS */
X        Controlpanel_Titlebar_Set_Label("Choose a word:");
X        Wordlist_Reset();
X        webster_state = GET_WORDLIST; current_wordlist_is_xrefs = FALSE;
X--- 275,283 ----
X        Controlpanel_Reactivate(); /* ready for user input */
X        /* webster_state = WEBSTER_READY; */
X      }      
X!     else if (strncmp(line, "MATCHS\n", 7) == 0 ||  /* returned by ENDINGS */
X! 	     strncmp(line, "SPELLING\n", 9) == 0)  /* returned by SPELL */
X!     {
X        Controlpanel_Titlebar_Set_Label("Choose a word:");
X        Wordlist_Reset();
X        webster_state = GET_WORDLIST; current_wordlist_is_xrefs = FALSE;
/*EOF
