TextPop.c File Reference

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw3d/TextP.h>
#include <X11/Xaw3d/AsciiText.h>
#include <X11/Xaw3d/Cardinals.h>
#include <X11/Xaw3d/Command.h>
#include <X11/Xaw3d/Form.h>
#include <X11/Xaw3d/Toggle.h>
#include <X11/Xmu/CharSet.h>
#include "XawI18n.h"
#include <stdio.h>
#include <X11/Xos.h>
#include <errno.h>

Include dependency graph for TextPop.c:

Go to the source code of this file.

Defines

#define INSERT_FILE   ("Enter Filename:")
#define SEARCH_LABEL_1   ("Use <Tab> to change fields.")
#define SEARCH_LABEL_2   ("Use ^q<Tab> for <Tab>.")
#define DISMISS_NAME   ("cancel")
#define DISMISS_NAME_LEN   6
#define FORM_NAME   ("form")
#define LABEL_NAME   ("label")
#define TEXT_NAME   ("text")
#define R_OFFSET   1
#define SEARCH_HEADER   ("Text Widget - Search():")
#define DO_DELETE_WINDOW   InParams(WM_DELETE_WINDOW, params, *num_params)

Functions

static void CenterWidgetOnPoint ()
static void PopdownSearch ()
static void DoInsert ()
static void _SetField ()
static void InitializeSearchWidget ()
static void SetResource ()
static void SetSearchLabels ()
static void DoReplaceOne ()
static void DoReplaceAll ()
static Widget CreateDialog ()
static Widget GetShell ()
static void SetWMProtocolTranslations ()
static Boolean DoSearch ()
static Boolean SetResourceByName ()
static Boolean Replace ()
static String GetString ()
static String GetStringRaw ()
static void AddInsertFileChildren ()
static Boolean InsertFileNamed ()
static void AddSearchChildren ()
void _XawTextInsertFileAction (Widget w, XEvent *event, String *params, Cardinal *num_params)
void _XawTextInsertFile (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void PopdownFileInsert (Widget w, XtPointer closure, XtPointer call_data)
static void DoInsert (Widget w, XtPointer closure, XtPointer call_data)
static Boolean InsertFileNamed (Widget tw, char *str)
static void AddInsertFileChildren (Widget form, char *ptr, Widget tw)
void _XawTextDoSearchAction (Widget w, XEvent *event, String *params, Cardinal *num_params)
void _XawTextPopdownSearchAction (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void PopdownSearch (Widget w, XtPointer closure, XtPointer call_data)
static void SearchButton (Widget w, XtPointer closure, XtPointer call_data)
void _XawTextSearch (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void InitializeSearchWidget (struct SearchAndReplace *search, XawTextScanDirection dir, Boolean replace_active)
static void AddSearchChildren (Widget form, char *ptr, Widget tw)
static Boolean DoSearch (struct SearchAndReplace *search)
void _XawTextDoReplaceAction (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void DoReplaceOne (Widget w, XtPointer closure, XtPointer call_data)
static void DoReplaceAll (Widget w, XtPointer closure, XtPointer call_data)
static Boolean Replace (struct SearchAndReplace *search, Boolean once_only, Boolean show_current)
static void SetSearchLabels (struct SearchAndReplace *search, String msg1, String msg2, Boolean bell)
void _XawTextSetField (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void _SetField (Widget new, Widget old)
static Boolean SetResourceByName (Widget shell, char *name, char *res_name, XtArgVal value)
static void SetResource (Widget w, char *res_name, XtArgVal value)
static String GetString (Widget text)
static String GetStringRaw (Widget tw)
static void CenterWidgetOnPoint (Widget w, XEvent *event)
static Widget CreateDialog (Widget parent, String ptr, String name, void(*func)())
static Widget GetShell (Widget w)
static Boolean InParams (String str, String *p, Cardinal n)
static void WMProtocols (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void SetWMProtocolTranslations (Widget w)

Variables

static char radio_trans_string []
static char search_text_trans []
static char rep_text_trans []
static char * WM_DELETE_WINDOW = "WM_DELETE_WINDOW"


Define Documentation

#define DISMISS_NAME   ("cancel")

Definition at line 75 of file TextPop.c.

Referenced by AddInsertFileChildren(), AddSearchChildren(), and WMProtocols().

#define DISMISS_NAME_LEN   6

Definition at line 76 of file TextPop.c.

Referenced by WMProtocols().

#define DO_DELETE_WINDOW   InParams(WM_DELETE_WINDOW, params, *num_params)

Referenced by WMProtocols().

#define FORM_NAME   ("form")

Definition at line 77 of file TextPop.c.

Referenced by CreateDialog(), DoInsert(), and SetResourceByName().

#define INSERT_FILE   ("Enter Filename:")

Definition at line 71 of file TextPop.c.

Referenced by AddInsertFileChildren(), and PopdownFileInsert().

#define LABEL_NAME   ("label")

Definition at line 78 of file TextPop.c.

Referenced by AddInsertFileChildren(), DoInsert(), and PopdownFileInsert().

#define R_OFFSET   1

Definition at line 81 of file TextPop.c.

Referenced by AddSearchChildren(), DoSearch(), and Replace().

#define SEARCH_HEADER   ("Text Widget - Search():")

Definition at line 503 of file TextPop.c.

Referenced by _XawTextSearch().

#define SEARCH_LABEL_1   ("Use <Tab> to change fields.")

Definition at line 73 of file TextPop.c.

Referenced by AddSearchChildren(), and PopdownSearch().

#define SEARCH_LABEL_2   ("Use ^q<Tab> for <Tab>.")

Definition at line 74 of file TextPop.c.

Referenced by AddSearchChildren(), and PopdownSearch().

#define TEXT_NAME   ("text")

Definition at line 79 of file TextPop.c.

Referenced by AddInsertFileChildren(), and DoInsert().


Function Documentation

static void _SetField ( Widget  new,
Widget  old 
) [static]

Definition at line 1109 of file TextPop.c.

References args, ONE, SetResource(), and TWO.

01111 {
01112   Arg args[2];
01113   Pixel new_border, old_border, old_bg;
01114 
01115   if (!XtIsSensitive(new)) {
01116     XBell(XtDisplay(old), 0);   /* Don't set field to an inactive Widget. */
01117     return;
01118   }
01119 
01120   XtSetKeyboardFocus(XtParent(new), new); 
01121                                                 
01122   XtSetArg(args[0], XtNborderColor, &old_border);
01123   XtSetArg(args[1], XtNbackground, &old_bg);
01124   XtGetValues(new, args, TWO);
01125 
01126   XtSetArg(args[0], XtNborderColor, &new_border);
01127   XtGetValues(old, args, ONE);
01128 
01129   if (old_border != old_bg)     /* Colors are already correct, return. */
01130       return;
01131 
01132   SetResource(old, XtNborderColor, (XtArgVal) old_border);
01133   SetResource(new, XtNborderColor, (XtArgVal) new_border);
01134 }

Here is the call graph for this function:

static void _SetField (  ) 

Referenced by _XawTextSetField().

Here is the caller graph for this function:

void _XawTextDoReplaceAction ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 866 of file TextPop.c.

References FALSE, NULL, PopdownSearch(), Replace(), _TextPart::search, _TextRec::text, and TRUE.

00871 {
00872   TextWidget ctx = (TextWidget) XtParent(XtParent(XtParent(w)));
00873   Boolean popdown = FALSE;
00874 
00875   if ( (*num_params == 1) &&
00876        ((params[0][0] == 'p') || (params[0][0] == 'P')) )
00877     popdown = TRUE;
00878 
00879   if (Replace( ctx->text.search, TRUE, popdown) && popdown)
00880     PopdownSearch(w, (XtPointer) ctx->text.search, (XtPointer)NULL);
00881 }

Here is the call graph for this function:

void _XawTextDoSearchAction ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 407 of file TextPop.c.

References DoSearch(), FALSE, NULL, PopdownSearch(), _TextPart::search, _TextRec::text, and TRUE.

00412 {
00413   TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w)));
00414   Boolean popdown = FALSE;
00415 
00416   if ( (*num_params == 1) &&
00417        ((params[0][0] == 'p') || (params[0][0] == 'P')) )
00418       popdown = TRUE;
00419     
00420   if (DoSearch(tw->text.search) && popdown)
00421     PopdownSearch(w, (XtPointer) tw->text.search, (XtPointer)NULL);
00422 }

Here is the call graph for this function:

void _XawTextInsertFile ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 159 of file TextPop.c.

References AddInsertFileChildren(), args, CenterWidgetOnPoint(), CreateDialog(), _TextPart::file_insert, ONE, SetWMProtocolTranslations(), _TextPart::source, _TextRec::text, and XawtextEdit.

00164 {
00165   TextWidget ctx = (TextWidget)w;
00166   char * ptr;
00167   XawTextEditType edit_mode;
00168   Arg args[1];
00169 
00170   XtSetArg(args[0], XtNeditType,&edit_mode);
00171   XtGetValues(ctx->text.source, args, ONE);
00172   
00173   if (edit_mode != XawtextEdit) {
00174     XBell(XtDisplay(w), 0);
00175     return;
00176   }
00177 
00178   if (*num_params == 0) 
00179     ptr = "";
00180   else 
00181     ptr = params[0];
00182     
00183   if (!ctx->text.file_insert) {
00184     ctx->text.file_insert = CreateDialog(w, ptr, "insertFile",
00185                                          AddInsertFileChildren);
00186     XtRealizeWidget(ctx->text.file_insert);
00187     SetWMProtocolTranslations(ctx->text.file_insert);
00188   }
00189 
00190   CenterWidgetOnPoint(ctx->text.file_insert, event);
00191   XtPopup(ctx->text.file_insert, XtGrabNone);
00192 }

Here is the call graph for this function:

void _XawTextInsertFileAction ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 133 of file TextPop.c.

References DoInsert(), and NULL.

00138 {
00139   DoInsert(w, (XtPointer) XtParent(XtParent(XtParent(w))), (XtPointer)NULL);
00140 }

Here is the call graph for this function:

void _XawTextPopdownSearchAction ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 433 of file TextPop.c.

References NULL, PopdownSearch(), _TextPart::search, and _TextRec::text.

00438 {
00439   TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w)));
00440 
00441   PopdownSearch(w, (XtPointer) tw->text.search, (XtPointer)NULL);
00442 }

Here is the call graph for this function:

void _XawTextSearch ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 506 of file TextPop.c.

References _XawTextFormat(), AddSearchChildren(), args, buf, CenterWidgetOnPoint(), CreateDialog(), dir, InitializeSearchWidget(), NULL, ONE, _TextPart::search, SEARCH_HEADER, SearchAndReplace::search_popup, SearchAndReplace::search_text, SetWMProtocolTranslations(), _TextPart::source, _TextRec::text, void(), XawFmtWide, XawsdLeft, XawsdRight, and XawtextEdit.

00511 {
00512   TextWidget ctx = (TextWidget)w;
00513   XawTextScanDirection dir;
00514   char * ptr, buf[BUFSIZ];
00515   XawTextEditType edit_mode;
00516   Arg args[1];
00517 
00518 #ifdef notdef
00519   if (ctx->text.source->Search == NULL) {
00520       XBell(XtDisplay(w), 0);
00521       return;
00522   }
00523 #endif
00524 
00525   if ( (*num_params < 1) || (*num_params > 2) ) {
00526     (void) sprintf(buf, "%s %s\n%s", SEARCH_HEADER, 
00527             "This action must have only", 
00528             "one or two parameters");
00529     XtAppWarning(XtWidgetToApplicationContext(w), buf);
00530     return;
00531   }
00532 
00533   if (*num_params == 2 )
00534       ptr = params[1];
00535   else
00536       if (_XawTextFormat(ctx) == XawFmtWide) {
00537           /*This just does the equivalent of ptr = ""L, a waste because params[1] isnt W aligned.*/
00538           ptr = (char *)XtMalloc(sizeof(wchar_t));
00539           *((wchar_t*)ptr) = (wchar_t)0;
00540       } else
00541           ptr = "";
00542 
00543   switch(params[0][0]) {
00544   case 'b':                     /* Left. */
00545   case 'B':
00546     dir = XawsdLeft;
00547     break;
00548   case 'f':                     /* Right. */
00549   case 'F':
00550     dir = XawsdRight;
00551     break;
00552   default:
00553     (void) sprintf(buf, "%s %s\n%s", SEARCH_HEADER, 
00554             "The first parameter must be",
00555             "Either 'backward' or 'forward'");
00556     XtAppWarning(XtWidgetToApplicationContext(w), buf);
00557     return;
00558   }
00559 
00560   if (ctx->text.search== NULL) {
00561     ctx->text.search = XtNew(struct SearchAndReplace);
00562     ctx->text.search->search_popup = CreateDialog(w, ptr, "search",
00563                                                   AddSearchChildren);
00564     XtRealizeWidget(ctx->text.search->search_popup);
00565     SetWMProtocolTranslations(ctx->text.search->search_popup);
00566   }
00567   else if (*num_params > 1) {
00568     XtVaSetValues(ctx->text.search->search_text, XtNstring, ptr, NULL);
00569   }
00570 
00571   XtSetArg(args[0], XtNeditType,&edit_mode);
00572   XtGetValues(ctx->text.source, args, ONE);
00573 
00574   InitializeSearchWidget(ctx->text.search, dir, (edit_mode == XawtextEdit));
00575 
00576   CenterWidgetOnPoint(ctx->text.search->search_popup, event);
00577   XtPopup(ctx->text.search->search_popup, XtGrabNone);
00578 }

Here is the call graph for this function:

void _XawTextSetField ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
)

Definition at line 1067 of file TextPop.c.

References _SetField(), SearchAndReplace::rep_text, SearchAndReplace::search_text, SetSearchLabels(), and TRUE.

01072 {
01073   struct SearchAndReplace * search;
01074   Widget new, old;
01075 
01076   search = ((TextWidget) XtParent(XtParent(XtParent(w))))->text.search;
01077 
01078   if (*num_params != 1) {
01079     SetSearchLabels(search, "*** Error: SetField Action must have",
01080                     "exactly one argument. ***", TRUE);
01081     return;
01082   }
01083   switch (params[0][0]) {
01084   case 's':
01085   case 'S':
01086     new = search->search_text;
01087     old = search->rep_text;
01088     break;
01089   case 'r':
01090   case 'R':
01091     old = search->search_text;
01092     new = search->rep_text;
01093     break;
01094   default:
01095     SetSearchLabels(search, "*** Error: SetField Action's first Argument must",
01096                     "be either 'Search' or 'Replace'. ***", TRUE);
01097     return;
01098   }
01099   _SetField(new, old);
01100 }

Here is the call graph for this function:

static void AddInsertFileChildren ( Widget  form,
char *  ptr,
Widget  tw 
) [static]

Definition at line 324 of file TextPop.c.

References args, asciiTextWidgetClass, cancel, commandWidgetClass, DISMISS_NAME, DoInsert(), insert, INSERT_FILE, label, LABEL_NAME, labelWidgetClass, PopdownFileInsert(), TEXT_NAME, TRUE, XawtextEdit, XawtextResizeWidth, XtChainLeft, XtChainRight, XtNfromHoriz, XtNfromVert, XtNlabel, XtNleft, XtNresizable, XtNresize, and XtNright.

00327 {
00328   Arg args[10];
00329   Cardinal num_args;
00330   Widget label, text, cancel, insert;
00331   XtTranslations trans;
00332 
00333   num_args = 0;
00334   XtSetArg(args[num_args], XtNlabel, INSERT_FILE);num_args++;
00335   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00336   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00337   XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
00338   XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
00339   label = XtCreateManagedWidget (LABEL_NAME, labelWidgetClass, form, 
00340                                  args, num_args);
00341   
00342   num_args = 0;
00343   XtSetArg(args[num_args], XtNfromVert, label); num_args++;
00344   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00345   XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
00346   XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
00347   XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
00348   XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
00349   XtSetArg(args[num_args], XtNstring, ptr); num_args++;
00350   text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form,
00351                                 args, num_args);
00352 
00353   num_args = 0;
00354   XtSetArg(args[num_args], XtNlabel, "Insert File"); num_args++;
00355   XtSetArg(args[num_args], XtNfromVert, text); num_args++;
00356   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00357   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00358   insert = XtCreateManagedWidget("insert", commandWidgetClass, form,
00359                                  args, num_args);
00360 
00361   num_args = 0;
00362   XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
00363   XtSetArg(args[num_args], XtNfromVert, text); num_args++;
00364   XtSetArg(args[num_args], XtNfromHoriz, insert); num_args++;
00365   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00366   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00367   cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
00368                                  args, num_args);
00369 
00370   XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (XtPointer) tw);
00371   XtAddCallback(insert, XtNcallback, DoInsert, (XtPointer) tw);
00372 
00373   XtSetKeyboardFocus(form, text);
00374 
00375 /*
00376  * Bind <CR> to insert file.
00377  */
00378 
00379   trans = XtParseTranslationTable("<Key>Return: InsertFileAction()");
00380   XtOverrideTranslations(text, trans);
00381 
00382 }

Here is the call graph for this function:

static void AddInsertFileChildren (  )  [static]

Referenced by _XawTextInsertFile().

Here is the caller graph for this function:

static void AddSearchChildren ( Widget  form,
char *  ptr,
Widget  tw 
) [static]

Definition at line 622 of file TextPop.c.

References args, asciiTextWidgetClass, cancel, commandWidgetClass, DISMISS_NAME, DoReplaceAll(), DoReplaceOne(), FALSE, SearchAndReplace::label1, SearchAndReplace::label2, labelWidgetClass, SearchAndReplace::left_toggle, PopdownSearch(), R_OFFSET, radio_trans_string, SearchAndReplace::rep_all, SearchAndReplace::rep_label, SearchAndReplace::rep_one, SearchAndReplace::rep_text, rep_text_trans, SearchAndReplace::right_toggle, SEARCH_LABEL_1, SEARCH_LABEL_2, SearchAndReplace::search_text, search_text_trans, SearchButton(), SetSearchLabels(), toggleWidgetClass, TRUE, XawsdLeft, XawsdRight, XawtextEdit, XawtextResizeWidth, XtChainLeft, XtChainRight, XtNfromHoriz, XtNfromVert, XtNlabel, XtNleft, XtNradioData, XtNradioGroup, XtNresizable, XtNresize, and XtNright.

00625 {
00626   Arg args[10];
00627   Cardinal num_args;
00628   Widget cancel, search_button, s_label, s_text, r_text;
00629   XtTranslations trans;
00630   struct SearchAndReplace * search = ((TextWidget) tw)->text.search;
00631 
00632   num_args = 0;
00633   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00634   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00635   XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
00636   XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
00637   search->label1 = XtCreateManagedWidget("label1", labelWidgetClass, form,
00638                                          args, num_args);
00639 
00640   num_args = 0;
00641   XtSetArg(args[num_args], XtNfromVert, search->label1); num_args++;
00642   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00643   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00644   XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
00645   XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
00646   search->label2 = XtCreateManagedWidget("label2", labelWidgetClass, form,
00647                                          args, num_args);
00648   
00649 /* 
00650  * We need to add R_OFFSET to the radio_data, because the value zero (0)
00651  * has special meaning.
00652  */
00653 
00654   num_args = 0;
00655   XtSetArg(args[num_args], XtNlabel, "Backward"); num_args++;
00656   XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
00657   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00658   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00659   XtSetArg(args[num_args], XtNradioData, (XPointer) XawsdLeft + R_OFFSET);
00660   num_args++;
00661   search->left_toggle = XtCreateManagedWidget("backwards", toggleWidgetClass,
00662                                               form, args, num_args);
00663 
00664   num_args = 0;
00665   XtSetArg(args[num_args], XtNlabel, "Forward"); num_args++;
00666   XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
00667   XtSetArg(args[num_args], XtNfromHoriz, search->left_toggle); num_args++;
00668   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00669   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00670   XtSetArg(args[num_args], XtNradioGroup, search->left_toggle); num_args++;
00671   XtSetArg(args[num_args], XtNradioData, (XPointer) XawsdRight + R_OFFSET);
00672   num_args++;
00673   search->right_toggle = XtCreateManagedWidget("forwards", toggleWidgetClass,
00674                                                form, args, num_args);
00675 
00676   {
00677     XtTranslations radio_translations;
00678 
00679     radio_translations = XtParseTranslationTable(radio_trans_string);
00680     XtOverrideTranslations(search->left_toggle, radio_translations);
00681     XtOverrideTranslations(search->right_toggle, radio_translations);
00682   }
00683 
00684   num_args = 0;
00685   XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
00686   XtSetArg(args[num_args], XtNlabel, "Search for:  ");num_args++;
00687   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00688   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00689   XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
00690   s_label = XtCreateManagedWidget("searchLabel", labelWidgetClass, form,
00691                                   args, num_args);
00692 
00693   num_args = 0;
00694   XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
00695   XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
00696   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00697   XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
00698   XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
00699   XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
00700   XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
00701   XtSetArg(args[num_args], XtNstring, ptr); num_args++;
00702   s_text = XtCreateManagedWidget("searchText", asciiTextWidgetClass, form,
00703                                  args, num_args);
00704   search->search_text = s_text;
00705 
00706   num_args = 0;
00707   XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
00708   XtSetArg(args[num_args], XtNlabel, "Replace with:");num_args++;
00709   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00710   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00711   XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
00712   search->rep_label = XtCreateManagedWidget("replaceLabel", labelWidgetClass,
00713                                             form, args, num_args);
00714 
00715   num_args = 0;
00716   XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
00717   XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
00718   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00719   XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
00720   XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
00721   XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
00722   XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
00723   XtSetArg(args[num_args], XtNstring, ""); num_args++;
00724   r_text = XtCreateManagedWidget("replaceText", asciiTextWidgetClass,
00725                                  form, args, num_args);
00726   search->rep_text = r_text;
00727   
00728   num_args = 0;
00729   XtSetArg(args[num_args], XtNlabel, "Search"); num_args++;
00730   XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
00731   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00732   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00733   search_button = XtCreateManagedWidget("search", commandWidgetClass, form,
00734                                         args, num_args);
00735 
00736   num_args = 0;
00737   XtSetArg(args[num_args], XtNlabel, "Replace"); num_args++;
00738   XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
00739   XtSetArg(args[num_args], XtNfromHoriz, search_button); num_args++;
00740   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00741   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00742   search->rep_one = XtCreateManagedWidget("replaceOne", commandWidgetClass,
00743                                           form, args, num_args);
00744 
00745   num_args = 0;
00746   XtSetArg(args[num_args], XtNlabel, "Replace All"); num_args++;
00747   XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
00748   XtSetArg(args[num_args], XtNfromHoriz, search->rep_one); num_args++;
00749   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00750   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00751   search->rep_all = XtCreateManagedWidget("replaceAll", commandWidgetClass,
00752                                           form, args, num_args);
00753 
00754   num_args = 0;
00755   XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
00756   XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
00757   XtSetArg(args[num_args], XtNfromHoriz, search->rep_all); num_args++;
00758   XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
00759   XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
00760   cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
00761                                  args, num_args);
00762 
00763   XtAddCallback(search_button, XtNcallback, SearchButton, (XtPointer) search);
00764   XtAddCallback(search->rep_one, XtNcallback, DoReplaceOne, (XtPointer) search);
00765   XtAddCallback(search->rep_all, XtNcallback, DoReplaceAll, (XtPointer) search);
00766   XtAddCallback(cancel, XtNcallback, PopdownSearch, (XtPointer) search);
00767 
00768 /*
00769  * Initialize the text entry fields.
00770  */
00771 
00772   {
00773     Pixel color;
00774     num_args = 0;
00775     XtSetArg(args[num_args], XtNbackground, &color); num_args++;
00776     XtGetValues(search->rep_text, args, num_args);
00777     num_args = 0;
00778     XtSetArg(args[num_args], XtNborderColor, color); num_args++;
00779     XtSetValues(search->rep_text, args, num_args);
00780     XtSetKeyboardFocus(form, search->search_text);
00781   }
00782 
00783   SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE);
00784 
00785 /*
00786  * Bind Extra translations.
00787  */
00788 
00789   trans = XtParseTranslationTable(search_text_trans);
00790   XtOverrideTranslations(search->search_text, trans);
00791 
00792   trans = XtParseTranslationTable(rep_text_trans);
00793   XtOverrideTranslations(search->rep_text, trans);
00794 }

Here is the call graph for this function:

static void AddSearchChildren (  )  [static]

Referenced by _XawTextSearch().

Here is the caller graph for this function:

static void CenterWidgetOnPoint ( Widget  w,
XEvent *  event 
) [static]

Definition at line 1229 of file TextPop.c.

References args, height, NULL, width, x, and y.

01232 {
01233   Arg args[3];
01234   Cardinal num_args;
01235   Dimension width, height, b_width;
01236   Position x = 0, y = 0, max_x, max_y;
01237   
01238   if (event != NULL) {
01239     switch (event->type) {
01240     case ButtonPress:
01241     case ButtonRelease:
01242       x = event->xbutton.x_root;
01243       y = event->xbutton.y_root;
01244       break;
01245     case KeyPress:
01246     case KeyRelease:
01247       x = event->xkey.x_root;
01248       y = event->xkey.y_root;
01249       break;
01250     default:
01251       return;
01252     }
01253   }
01254   
01255   num_args = 0;
01256   XtSetArg(args[num_args], XtNwidth, &width); num_args++;
01257   XtSetArg(args[num_args], XtNheight, &height); num_args++;
01258   XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++;
01259   XtGetValues(w, args, num_args);
01260 
01261   width += 2 * b_width;
01262   height += 2 * b_width;
01263 
01264   x -= ( (Position) width/2 );
01265   if (x < 0) x = 0;
01266   if ( x > (max_x = (Position) (XtScreen(w)->width - width)) ) x = max_x;
01267 
01268   y -= ( (Position) height/2 );
01269   if (y < 0) y = 0;
01270   if ( y > (max_y = (Position) (XtScreen(w)->height - height)) ) y = max_y;
01271   
01272   num_args = 0;
01273   XtSetArg(args[num_args], XtNx, x); num_args++;
01274   XtSetArg(args[num_args], XtNy, y); num_args++;
01275   XtSetValues(w, args, num_args);
01276 }

static void CenterWidgetOnPoint (  )  [static]

Referenced by _XawTextInsertFile(), and _XawTextSearch().

Here is the caller graph for this function:

static Widget CreateDialog ( Widget  parent,
String  ptr,
String  name,
void (*)()  func 
) [static]

Definition at line 1296 of file TextPop.c.

References args, FORM_NAME, formWidgetClass, GetShell(), NULL, transientShellWidgetClass, TRUE, XtNgeometry, and ZERO.

01300 {
01301   Widget popup, form;
01302   Arg args[5];
01303   Cardinal num_args;
01304 
01305   num_args = 0;
01306   XtSetArg(args[num_args], XtNiconName, name); num_args++;
01307   XtSetArg(args[num_args], XtNgeometry, NULL); num_args++;
01308   XtSetArg(args[num_args], XtNallowShellResize, TRUE); num_args++;
01309   XtSetArg(args[num_args], XtNtransientFor, GetShell(parent)); num_args++;
01310   popup = XtCreatePopupShell(name, transientShellWidgetClass, 
01311                              parent, args, num_args);
01312   
01313   form = XtCreateManagedWidget(FORM_NAME, formWidgetClass, popup,
01314                                (ArgList)NULL, ZERO);
01315   XtManageChild (form);
01316 
01317   (*func) (form, ptr, parent);
01318   return(popup);
01319 }

Here is the call graph for this function:

static Widget CreateDialog (  )  [static]

Referenced by _XawTextInsertFile(), _XawTextSearch(), ChooseScilabBox(), CreateSplashscreen(), ExposeChooseWindow(), and ExposeMessageWindow1().

Here is the caller graph for this function:

static void DoInsert ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 228 of file TextPop.c.

References buf, errno, _TextPart::file_insert, FORM_NAME, GetString(), InsertFileNamed(), LABEL_NAME, NULL, PopdownFileInsert(), SetResourceByName(), strerror(), _TextRec::text, TEXT_NAME, void(), and XtNlabel.

00232 {
00233   TextWidget ctx = (TextWidget) closure;
00234   char buf[BUFSIZ], msg[BUFSIZ];
00235   Widget temp_widget;
00236 
00237   (void) sprintf(buf, "%s.%s", FORM_NAME, TEXT_NAME);
00238   if ( (temp_widget = XtNameToWidget(ctx->text.file_insert, buf)) == NULL ) {
00239     (void) strcpy(msg, 
00240            "*** Error: Could not get text widget from file insert popup");
00241   }
00242   else 
00243     if (InsertFileNamed( (Widget) ctx, GetString( temp_widget ))) {
00244       PopdownFileInsert(w, closure, call_data);
00245       return;
00246     }
00247     else
00248       (void) sprintf( msg, "*** Error: %s ***", strerror(errno));
00249 
00250   (void)SetResourceByName(ctx->text.file_insert, 
00251                           LABEL_NAME, XtNlabel, (XtArgVal) msg);
00252   XBell(XtDisplay(w), 0);
00253 }

Here is the call graph for this function:

static void DoInsert (  ) 

Referenced by _XawTextInsertFileAction(), and AddInsertFileChildren().

Here is the caller graph for this function:

static void DoReplaceAll ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 915 of file TextPop.c.

References FALSE, and Replace().

00919 {
00920   Replace( (struct SearchAndReplace *) closure, FALSE, FALSE);
00921 }

Here is the call graph for this function:

static void DoReplaceAll (  ) 

Referenced by AddSearchChildren().

Here is the caller graph for this function:

static void DoReplaceOne ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 895 of file TextPop.c.

References FALSE, Replace(), and TRUE.

00899 {
00900   Replace( (struct SearchAndReplace *) closure, TRUE, FALSE);
00901 }

Here is the call graph for this function:

static void DoReplaceOne (  )  [static]

Referenced by AddSearchChildren().

Here is the caller graph for this function:

static Boolean DoSearch ( struct SearchAndReplace search  )  [static]

Definition at line 804 of file TextPop.c.

References _XawTextFormat(), dir, FALSE, XawTextBlock::firstPos, XawTextBlock::format, GetString(), GetStringRaw(), XawTextBlock::length, pos, XawTextBlock::ptr, R_OFFSET, SetSearchLabels(), TRUE, void(), XawFmtWide, XawsdRight, XawTextSearch(), XawTextSearchError, XawTextSetInsertionPoint(), XawTextSetSelection(), XawTextUnsetSelection(), and XawToggleGetCurrent().

00806 {
00807   char msg[BUFSIZ];
00808   Widget tw = XtParent(search->search_popup);
00809   XawTextPosition pos;
00810   XawTextScanDirection dir;
00811   XawTextBlock text;
00812 
00813   TextWidget ctx = (TextWidget)tw;
00814 
00815   text.ptr = GetStringRaw(search->search_text);
00816   if ((text.format = _XawTextFormat(ctx)) == XawFmtWide)
00817       text.length = wcslen((wchar_t*)text.ptr);
00818   else
00819       text.length = strlen(text.ptr);
00820   text.firstPos = 0;
00821   
00822   dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
00823                                 R_OFFSET);
00824   
00825   pos = XawTextSearch( tw, dir, &text);
00826 
00827 
00828    /* The Raw string in find.ptr may be WC I can't use here, so I re - call 
00829    GetString to get a tame version. */
00830 
00831   if (pos == XawTextSearchError) 
00832     (void) sprintf( msg, "Could not find string ``%s''.", GetString( search->search_text ) );
00833   else {
00834     if (dir == XawsdRight)
00835       XawTextSetInsertionPoint( tw, pos + text.length);
00836     else
00837       XawTextSetInsertionPoint( tw, pos);
00838     
00839     XawTextSetSelection( tw, pos, pos + text.length);
00840     search->selection_changed = FALSE; /* selection is good. */
00841     return(TRUE);
00842   }
00843   
00844   XawTextUnsetSelection(tw);
00845   SetSearchLabels(search, msg, "", TRUE);
00846   return(FALSE);
00847 }

Here is the call graph for this function:

static Boolean DoSearch (  )  [static]

Referenced by _XawTextDoSearchAction(), Replace(), and SearchButton().

Here is the caller graph for this function:

static Widget GetShell ( Widget  w  )  [static]

Definition at line 1330 of file TextPop.c.

References NULL.

01332 {
01333     while ((w != NULL) && !XtIsShell(w))
01334         w = XtParent(w);
01335     
01336     return (w);
01337 }

static Widget GetShell (  ) 

Referenced by CreateDialog().

Here is the caller graph for this function:

static String GetString ( Widget  text  )  [static]

Definition at line 1194 of file TextPop.c.

References args, ONE, and string.

01196 {
01197   String string;
01198   Arg args[1];
01199 
01200   XtSetArg( args[0], XtNstring, &string );
01201   XtGetValues( text, args, ONE );
01202   return(string);
01203 }

static String GetString (  )  [static]

static String GetStringRaw ( Widget  tw  )  [static]

Definition at line 1206 of file TextPop.c.

References _XawTextGetText(), last, _TextPart::mult, _TextPart::source, _TextRec::text, TRUE, XawsdRight, XawstAll, and XawTextSourceScan().

01208 {
01209   TextWidget ctx = (TextWidget)tw;
01210   XawTextPosition last;
01211   char *_XawTextGetText();
01212 
01213   last = XawTextSourceScan(ctx->text.source, 0, XawstAll, XawsdRight,
01214                              ctx->text.mult, TRUE);
01215   return (_XawTextGetText(ctx, 0, last));
01216 }

Here is the call graph for this function:

static String GetStringRaw (  )  [static]

Referenced by DoSearch(), and Replace().

Here is the caller graph for this function:

static void InitializeSearchWidget ( struct SearchAndReplace search,
XawTextScanDirection  dir,
Boolean  replace_active 
) [static]

Definition at line 591 of file TextPop.c.

References SetResource(), TRUE, XawsdLeft, XawsdRight, and XtNstate.

00595 {
00596   SetResource(search->rep_one, XtNsensitive, (XtArgVal) replace_active);
00597   SetResource(search->rep_all, XtNsensitive, (XtArgVal) replace_active);
00598   SetResource(search->rep_label, XtNsensitive, (XtArgVal) replace_active);
00599   SetResource(search->rep_text, XtNsensitive, (XtArgVal) replace_active);
00600 
00601   switch (dir) {
00602   case XawsdLeft:
00603     SetResource(search->left_toggle, XtNstate, (XtArgVal) TRUE);
00604     break;
00605   case XawsdRight:
00606     SetResource(search->right_toggle, XtNstate, (XtArgVal) TRUE);
00607     break;
00608   default:
00609     break;
00610   }
00611 }  

Here is the call graph for this function:

static void InitializeSearchWidget (  )  [static]

Referenced by _XawTextSearch().

Here is the caller graph for this function:

static Boolean InParams ( String  str,
String *  p,
Cardinal  n 
) [static]

Definition at line 1339 of file TextPop.c.

References i, and XmuCompareISOLatin1().

01343 {
01344     int i;
01345     for (i=0; i < n; p++, i++)
01346         if (! XmuCompareISOLatin1(*p, str)) return True;
01347     return False;
01348 }

Here is the call graph for this function:

static Boolean InsertFileNamed ( Widget  tw,
char *  str 
) [static]

Definition at line 264 of file TextPop.c.

References FALSE, file, XawTextBlock::firstPos, XawTextBlock::format, L, XawTextBlock::length, NULL, pos, XawTextBlock::ptr, TRUE, XawEditDone, XawFmt8Bit, XawTextGetInsertionPoint(), XawTextReplace(), and XawTextSetInsertionPoint().

00267 {
00268   FILE *file;
00269   XawTextBlock text;
00270   XawTextPosition pos;
00271 
00272   if ( (str == NULL) || (strlen(str) == 0) || 
00273        ((file = fopen(str, "r")) == NULL))
00274     return(FALSE);
00275 
00276   pos = XawTextGetInsertionPoint(tw);
00277 
00278   fseek(file, 0L, 2);
00279 
00280 
00281   text.firstPos = 0;
00282   text.length = (ftell(file))/sizeof(unsigned char);
00283   text.ptr = XtMalloc((text.length + 1) * sizeof(unsigned char));
00284   text.format = XawFmt8Bit;
00285 
00286   fseek(file, 0L, 0);
00287   if (fread(text.ptr, sizeof(unsigned char), text.length, file) != text.length)
00288       XtErrorMsg("readError", "insertFileNamed", "XawError",
00289                  "fread returned error.", NULL, NULL);
00290 
00291  /* DELETE if (text.format == XawFmtWide) {
00292      wchar_t* _XawTextMBToWC();
00293      wchar_t* wstr;
00294      wstr = _XawTextMBToWC(XtDisplay(tw), text.ptr, &(text.length));
00295      wstr[text.length] = NULL;
00296      XtFree(text.ptr);
00297      text.ptr = (char *)wstr;
00298   } else {
00299      (text.ptr)[text.length] = '\0';
00300   }*/
00301 
00302   if (XawTextReplace(tw, pos, pos, &text) != XawEditDone) {
00303      XtFree(text.ptr);
00304      fclose(file);
00305      return(FALSE);
00306   }
00307   pos += text.length;
00308   XtFree(text.ptr);
00309   fclose(file);
00310   XawTextSetInsertionPoint(tw, pos);
00311   return(TRUE);
00312 }

Here is the call graph for this function:

static Boolean InsertFileNamed (  )  [static]

Referenced by DoInsert().

Here is the caller graph for this function:

static void PopdownFileInsert ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 205 of file TextPop.c.

References _TextPart::file_insert, INSERT_FILE, LABEL_NAME, SetResourceByName(), _TextRec::text, void(), and XtNlabel.

Referenced by AddInsertFileChildren(), and DoInsert().

00209 {
00210   TextWidget ctx = (TextWidget) closure;
00211 
00212   XtPopdown( ctx->text.file_insert );
00213   (void) SetResourceByName( ctx->text.file_insert, LABEL_NAME, 
00214                            XtNlabel, (XtArgVal) INSERT_FILE);
00215 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void PopdownSearch ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 454 of file TextPop.c.

References FALSE, SEARCH_LABEL_1, SEARCH_LABEL_2, SearchAndReplace::search_popup, and SetSearchLabels().

00458 {
00459   struct SearchAndReplace * search = (struct SearchAndReplace *) closure;
00460 
00461   XtPopdown( search->search_popup );
00462   SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE);
00463 }

Here is the call graph for this function:

static void PopdownSearch (  ) 

Referenced by _XawTextDoReplaceAction(), _XawTextDoSearchAction(), _XawTextPopdownSearchAction(), and AddSearchChildren().

Here is the caller graph for this function:

static Boolean Replace ( struct SearchAndReplace search,
Boolean  once_only,
Boolean  show_current 
) [static]

Definition at line 936 of file TextPop.c.

References _XawTextFormat(), count, dir, DoSearch(), FALSE, find(), XawTextBlock::firstPos, XawTextBlock::format, GetString(), GetStringRaw(), XawTextBlock::length, pos, XawTextBlock::ptr, R_OFFSET, SetSearchLabels(), TRUE, void(), XawEditDone, XawFmtWide, XawsdRight, XawTextGetSelectionPos(), XawTextReplace(), XawTextSearch(), XawTextSearchError, XawTextSetInsertionPoint(), XawTextSetSelection(), XawTextUnsetSelection(), and XawToggleGetCurrent().

00939 {
00940   XawTextPosition pos, new_pos, end_pos;
00941   XawTextScanDirection dir;
00942   XawTextBlock find, replace;
00943   Widget tw = XtParent(search->search_popup);
00944   int count = 0;
00945 
00946   TextWidget ctx = (TextWidget)tw;
00947 
00948   find.ptr = GetStringRaw( search->search_text);
00949   if ((find.format = _XawTextFormat(ctx)) == XawFmtWide)
00950       find.length = wcslen((wchar_t*)find.ptr);
00951   else
00952       find.length = strlen(find.ptr);
00953   find.firstPos = 0;
00954 
00955   replace.ptr = GetStringRaw(search->rep_text);
00956   replace.firstPos = 0;
00957   if ((replace.format = _XawTextFormat(ctx)) == XawFmtWide)
00958       replace.length = wcslen((wchar_t*)replace.ptr);
00959   else
00960       replace.length = strlen(replace.ptr);
00961     
00962   dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
00963                                 R_OFFSET);
00964   /* CONSTCOND */
00965   while (TRUE) {
00966     if (count != 0) {
00967       new_pos = XawTextSearch( tw, dir, &find);
00968       
00969       if ( (new_pos == XawTextSearchError) ) {
00970         if (count == 0) {
00971           char msg[BUFSIZ];
00972 
00973              /* The Raw string in find.ptr may be WC I can't use here, 
00974                 so I call GetString to get a tame version.*/
00975 
00976           (void) sprintf( msg, "%s %s %s", "*** Error: Could not find string ``",
00977                   GetString( search->search_text ), "''. ***");
00978           SetSearchLabels(search, msg, "", TRUE);
00979           return(FALSE);
00980         }
00981         else
00982           break;
00983       }
00984       pos = new_pos;
00985       end_pos = pos + find.length;
00986     }
00987     else {
00988       XawTextGetSelectionPos(tw, &pos, &end_pos);
00989 
00990       if (search->selection_changed) {
00991         SetSearchLabels(search, "Selection has been modified, aborting.",
00992                         "", TRUE);
00993         return(FALSE);
00994       }
00995       if (pos == end_pos) 
00996           return(FALSE);
00997     }
00998 
00999     if (XawTextReplace(tw, pos, end_pos, &replace) != XawEditDone) {
01000       char msg[BUFSIZ];
01001       
01002       (void) sprintf( msg, "'%s' with '%s'. ***", find.ptr, replace.ptr);
01003       SetSearchLabels(search, "*** Error while replacing", msg, TRUE);
01004       return(FALSE);
01005     }      
01006 
01007     if (dir == XawsdRight)
01008       XawTextSetInsertionPoint( tw, pos + replace.length);
01009     else
01010       XawTextSetInsertionPoint( tw, pos);
01011 
01012     if (once_only) 
01013       if (show_current)
01014         break;
01015       else {
01016         DoSearch(search);
01017         return(TRUE);
01018       }
01019     count++;
01020   }
01021 
01022   if (replace.length == 0)
01023     XawTextUnsetSelection(tw);
01024   else
01025     XawTextSetSelection( tw, pos, pos + replace.length);
01026 
01027   return(TRUE);
01028 }

Here is the call graph for this function:

static Boolean Replace (  ) 

Referenced by _XawTextDoReplaceAction(), DoReplaceAll(), and DoReplaceOne().

Here is the caller graph for this function:

static void SearchButton ( Widget  w,
XtPointer  closure,
XtPointer  call_data 
) [static]

Definition at line 475 of file TextPop.c.

References DoSearch(), and void().

Referenced by AddSearchChildren().

00479 {
00480   (void) DoSearch( (struct SearchAndReplace *) closure );
00481 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetResource ( Widget  w,
char *  res_name,
XtArgVal  value 
) [static]

Definition at line 1173 of file TextPop.c.

References args, and ONE.

01177 {
01178   Arg args[1];
01179   
01180   XtSetArg(args[0], res_name, value);
01181   XtSetValues( w, args, ONE );
01182 }

static void SetResource (  ) 

Referenced by _SetField(), InitializeSearchWidget(), SetResourceByName(), and SetSearchLabels().

Here is the caller graph for this function:

static Boolean SetResourceByName ( Widget  shell,
char *  name,
char *  res_name,
XtArgVal  value 
) [static]

Definition at line 1147 of file TextPop.c.

References buf, FALSE, FORM_NAME, NULL, SetResource(), TRUE, and void().

01151 {
01152   Widget temp_widget;
01153   char buf[BUFSIZ];
01154 
01155   (void) sprintf(buf, "%s.%s", FORM_NAME, name);
01156 
01157   if ( (temp_widget = XtNameToWidget(shell, buf)) != NULL) {
01158     SetResource(temp_widget, res_name, value);
01159     return(TRUE);
01160   }
01161   return(FALSE);
01162 }

Here is the call graph for this function:

static Boolean SetResourceByName (  ) 

Referenced by DoInsert(), and PopdownFileInsert().

Here is the caller graph for this function:

static void SetSearchLabels ( struct SearchAndReplace search,
String  msg1,
String  msg2,
Boolean  bell 
) [static]

Definition at line 1039 of file TextPop.c.

References bell(), SetResource(), void(), and XtNlabel.

01043 {
01044   (void) SetResource( search->label1, XtNlabel, (XtArgVal) msg1);
01045   (void) SetResource( search->label2, XtNlabel, (XtArgVal) msg2);
01046   if (bell) 
01047     XBell(XtDisplay(search->search_popup), 0);
01048 }

Here is the call graph for this function:

static void SetSearchLabels (  ) 

Referenced by _XawTextSetField(), AddSearchChildren(), DoSearch(), PopdownSearch(), and Replace().

Here is the caller graph for this function:

static void SetWMProtocolTranslations ( Widget  w  )  [static]

Definition at line 1388 of file TextPop.c.

References actions, i, void(), WM_DELETE_WINDOW, wm_delete_window, and WMProtocols().

01390 {
01391     int i;
01392     XtAppContext app_context;
01393     Atom wm_delete_window;
01394     static XtTranslations compiled_table;       /* initially 0 */
01395     static XtAppContext *app_context_list;      /* initially 0 */
01396     static Cardinal list_size;                  /* initially 0 */
01397 
01398     app_context = XtWidgetToApplicationContext(w);
01399 
01400     /* parse translation table once */
01401     if (! compiled_table) compiled_table = XtParseTranslationTable
01402         ("<Message>WM_PROTOCOLS: XawWMProtocols()\n");
01403 
01404     /* add actions once per application context */
01405     for (i=0; i < list_size && app_context_list[i] != app_context; i++) ;
01406     if (i == list_size) {
01407         XtActionsRec actions[1];
01408         actions[0].string = "XawWMProtocols";
01409         actions[0].proc = WMProtocols;
01410         list_size++;
01411         app_context_list = (XtAppContext *) XtRealloc
01412             ((char *)app_context_list, list_size * sizeof(XtAppContext));
01413         XtAppAddActions(app_context, actions, 1);
01414         app_context_list[i] = app_context;
01415     }
01416 
01417     /* establish communication between the window manager and each shell */
01418     XtAugmentTranslations(w, compiled_table);
01419     wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, False);
01420     (void) XSetWMProtocols(XtDisplay(w), XtWindow(w), &wm_delete_window, 1);
01421 }

Here is the call graph for this function:

static void SetWMProtocolTranslations (  )  [static]

Referenced by _XawTextInsertFile(), and _XawTextSearch().

Here is the caller graph for this function:

static void WMProtocols ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 1352 of file TextPop.c.

References cancel, DISMISS_NAME, DISMISS_NAME_LEN, DO_DELETE_WINDOW, NULL, void(), WM_DELETE_WINDOW, and wm_delete_window.

Referenced by SetWMProtocolTranslations().

01357 {
01358     Atom wm_delete_window;
01359     Atom wm_protocols;
01360 
01361     wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, True);
01362     wm_protocols = XInternAtom(XtDisplay(w), "WM_PROTOCOLS", True);
01363 
01364     /* Respond to a recognized WM protocol request iff 
01365      * event type is ClientMessage and no parameters are passed, or
01366      * event type is ClientMessage and event data is matched to parameters, or
01367      * event type isn't ClientMessage and parameters make a request.
01368      */
01369 #define DO_DELETE_WINDOW InParams(WM_DELETE_WINDOW, params, *num_params)
01370 
01371     if ((event->type == ClientMessage &&
01372          event->xclient.message_type == wm_protocols &&
01373          event->xclient.data.l[0] == wm_delete_window &&
01374          (*num_params == 0 || DO_DELETE_WINDOW))
01375         || 
01376         (event->type != ClientMessage && DO_DELETE_WINDOW)) {
01377 
01378 #undef DO_DELETE_WINDOW
01379 
01380         Widget cancel;
01381         char descendant[DISMISS_NAME_LEN + 2];
01382         (void) sprintf(descendant, "*%s", DISMISS_NAME);
01383         cancel = XtNameToWidget(w, descendant);
01384         if (cancel) XtCallCallbacks(cancel, XtNcallback, (XtPointer)NULL);
01385     }
01386 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char radio_trans_string[] [static]

Initial value:

    "<Btn1Down>,<Btn1Up>:   set() notify()"

Definition at line 97 of file TextPop.c.

Referenced by AddSearchChildren().

char rep_text_trans[] [static]

Initial value:

 
  "~Shift<Key>Return:      DoReplaceAction(Popdown) \n\
   Shift<Key>Return:       SetField(Search) \n\
   Ctrl<Key>q,<Key>Tab:    insert-char()     \n\
   Ctrl<Key>c:             PopdownSearchAction() \n\
   <Btn1Down>:             select-start() DoSearchAction() SetField(Replace)\n\
   <Key>Tab:               SetField(Search)"

Definition at line 108 of file TextPop.c.

Referenced by AddSearchChildren().

char search_text_trans[] [static]

Initial value:

 
  "~Shift<Key>Return:      DoSearchAction(Popdown) \n\
   Shift<Key>Return:       DoSearchAction() SetField(Replace) \n\
   Ctrl<Key>q,<Key>Tab:    insert-char()    \n\
   Ctrl<Key>c:             PopdownSearchAction() \n\
   <Btn1Down>:             select-start() SetField(Search) \n\
   <Key>Tab:               DoSearchAction() SetField(Replace)"

Definition at line 100 of file TextPop.c.

Referenced by AddSearchChildren().

char* WM_DELETE_WINDOW = "WM_DELETE_WINDOW" [static]

Definition at line 1350 of file TextPop.c.

Referenced by SetWMProtocolTranslations(), and WMProtocols().


Generated on Sun Mar 4 16:02:47 2007 for Scilab [trunk] by  doxygen 1.5.1