home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * xdbx - X Window System interface to dbx
- *
- * Copyright 1989 The University of Texas at Austin
- *
- * Author: Po Cheung
- * Date: March 10, 1989
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation. The University of Texas at Austin makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- ******************************************************************************/
-
-
- #include "global.h"
-
- XtTextPosition StartPos; /* starting position of input text */
-
- /* Write s to dbx, and flush the output. */
-
- void writeDbx(s)
- char *s;
- {
- fputs(s, dbxfp);
- fflush(dbxfp);
- }
-
- /* Returns the working directory of dbx (for Sun dbx only).
- */
- char *dbxpwd()
- {
- char s[LINESIZ], *dir;
-
- #ifdef BSD
- return NULL;
- #else
- if (dbxfp == NULL) return (".");
- Echo = FALSE;
- writeDbx("pwd\n");
- while (fgets(s, LINESIZ, dbxfp) == NULL);
- s[strlen(s)-1] = '\0';
- dir = XtNewString(s);
- while (fgets(s, LINESIZ, dbxfp));
- Echo = TRUE;
- return dir;
- #endif
- }
-
-
- XtTextPosition TextGetLastPos(w)
- Widget w;
- {
- TextWidget ctx = (TextWidget) w;
- return (ctx->text.lastPos);
- }
-
-
- void AppendDialogText(s)
- char *s;
- {
- XtTextPosition i, lastPos;
- XtTextBlock textblock;
-
- if (!s || !strcmp(s, "")) return;
-
- textblock.firstPos = 0;
- textblock.length = strlen(s);
- textblock.ptr = s;
-
- lastPos = TextGetLastPos(dialogWindow);
- if (lastPos + textblock.length > DIALOGSIZE) {
- for (i=lastPos/2; DialogText[i] != '\n'; i++);
- strcpy(DialogText, &DialogText[i+1]);
- lastPos = strlen(DialogText);
- XtTextSetLastPos(dialogWindow, lastPos);
- }
- XtTextReplace(dialogWindow, lastPos, lastPos, &textblock);
- StartPos = TextGetLastPos(dialogWindow);
- XtTextSetInsertionPoint(dialogWindow, StartPos);
- }
-
- /*
- * Get the line number where the caret is.
- */
- Line TextPositionToLine(pos)
- XtTextPosition pos;
- {
- Line line;
-
- if (displayedFile) {
- for (line = displayedFile->topline;
- pos >= displayedFile->linepos[line]; line++);
- return (line-1);
- }
- else
- return 0;
- }
-
- /*
- * Return the stop number associated with a given line number.
- * Return 0 if stop number not found.
- */
- int LineToStop_no(line)
- Line line;
- {
- int i;
-
- for (i=1; i <= nstops; i++)
- if (stops[i].line == line && stops[i].filename && displayedFile &&
- strcmp(stops[i].filename, displayedFile->filename) == NULL) {
- return i;
- }
- return 0;
- }
-
-
- void DisableWindowResize(w)
- Widget w;
- {
- Arg args[MAXARGS];
- Cardinal n;
- Dimension height;
-
- n = 0;
- XtSetArg(args[n], XtNheight, &height); n++;
- XtGetValues(w, args, n);
- XtPanedSetMinMax(w, height, height);
- XtPanedAllowResize(w, False);
- }
-
-
- void Bell(volume)
- int volume;
- {
- XBell(XtDisplay(toplevel), volume);
- }
-