home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 4 / 4005 < prev    next >
Encoding:
Text File  |  1991-09-09  |  39.9 KB  |  1,315 lines

  1. Newsgroups: alt.sources
  2. Path: wupost!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!think.com!news.bbn.com!mips2!bubba!jtsillas
  3. From: jtsillas@bubba.ma30.bull.com (James Tsillas)
  4. Subject: mxgdb 1.0.3 (part 3/10)
  5. Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
  6. Distribution: alt
  7. Date: 6 Sep 91 14:22:25
  8. Message-ID: <JTSILLAS.91Sep6142225@bubba.ma30.bull.com>
  9. Sender: news@mips2.ma30.bull.com (Usenet News Manager)
  10.  
  11. ---- Cut Here and feed the following to sh ----
  12. #!/bin/sh
  13. # this is mxgdb.03 (part 3 of a multipart archive)
  14. # do not concatenate these parts, unpack them in order with /bin/sh
  15. # file mxgdb/source.c continued
  16. #
  17. if test ! -r _shar_seq_.tmp; then
  18.     echo 'Please unpack part 1 first!'
  19.     exit 1
  20. fi
  21. (read Scheck
  22.  if test "$Scheck" != 3; then
  23.     echo Please unpack part "$Scheck" next!
  24.     exit 1
  25.  else
  26.     exit 0
  27.  fi
  28. ) < _shar_seq_.tmp || exit 1
  29. if test ! -f _shar_wnt_.tmp; then
  30.     echo 'x - still skipping mxgdb/source.c'
  31. else
  32. echo 'x - continuing file mxgdb/source.c'
  33. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/source.c' &&
  34. X *  University of Texas and MCC makes no representations about the 
  35. X *  suitability of this software for any purpose.  It is provided "as is" 
  36. X *  without express or implied warranty.
  37. X *
  38. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  39. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  40. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  41. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  42. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  43. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  44. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  45. X *
  46. X *  Author:      Po Cheung
  47. X *  Created:       March 10, 1989
  48. X * 
  49. X *****************************************************************************
  50. X * 
  51. X *  xxgdb - X Window System interface to the gdb debugger
  52. X *  
  53. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  54. X *  
  55. X *  Permission to use, copy, modify, and distribute this software and its
  56. X *  documentation for any purpose and without fee is hereby granted,
  57. X *  provided that the above copyright notice appear in all copies and that
  58. X *  both that copyright notice and this permission notice appear in
  59. X *  supporting documentation, and that the name of Thomson Consumer
  60. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  61. X *  to distribution of the software without specific, written prior
  62. X *  permission.  TCE makes no representations about the suitability of
  63. X *  this software for any purpose.  It is provided "as is" without express
  64. X *  or implied warranty.
  65. X *
  66. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  67. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  68. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  69. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  70. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  71. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  72. X *  SOFTWARE.
  73. X *
  74. X *  Adaptation to GDB:  Pierre Willard
  75. X *  XXGDB Created:       December, 1990
  76. X *
  77. X *****************************************************************************/
  78. X
  79. /*  source.c
  80. X *
  81. X *    Create the source window and handle display of file.
  82. X *
  83. X *    source_init():     Initialization routine.
  84. X *    Update():        Action proc to update source window on scrollbar action.
  85. X *    NotifyResize():    Action proc to update source window on resize.
  86. X *    CreateSourceWindow(): Create the source window.
  87. X *    BuildLinePos():    Build an array of starting text position of each line.
  88. X *    LookUpFileTable():Check out source file info from a file table.
  89. X *    SaveDisplayedFileInfo(): records displayed file info into file table.
  90. X *    DisplayFile():    Display a file on the source window
  91. X *    LoadFile():    Search for a file and open it for display.
  92. X */
  93. X
  94. #include <X11/Xos.h>
  95. #include <sys/stat.h>
  96. #include <pwd.h>
  97. #include "global.h"
  98. #include "bitmaps.h"
  99. #ifdef SYSV 
  100. #if defined(SCO)
  101. #   include <fcntl.h>
  102. #endif
  103. #if defined(Mips)
  104. #   include <unistd.h>
  105. #endif
  106. #endif /* SYSV */
  107. X
  108. #include <Xm/Xm.h>
  109. #include <Xm/Form.h>
  110. #include <Xm/Text.h>
  111. #include <Xm/ScrolledW.h>
  112. #include <Xm/ScrollBar.h>
  113. #include <Xm/ArrowB.h>
  114. #include <Xm/PushB.h>
  115. X
  116. #define    MAXDIRS    256            /* max number of dirs in dirList */
  117. X
  118. char        CurrentFile[MAXNAME];    /* current contents of file variable */
  119. Widget        sourceWindow,        /* text window for source file */
  120. X                sourceScroll,
  121. X                scrollV,
  122. X                sourceForm,
  123. X                pageRbutton, pageLbutton,
  124. X                breakbutton, stepbutton, nextbutton, printbutton,
  125. X                downbutton, upbutton, stackbutton, contbutton, finishbutton,
  126. X                runbutton, dispbutton, undispbutton, clearbutton, printsbutton,
  127. X                argsbutton, localsbutton, commandDialog;
  128. X
  129. FileRec      *displayedFile;        /* pointer to table entry of currently
  130. X                       displayed file */
  131. X
  132. static FileRec    **fileTable;        /* table of file records */
  133. static int    fileTableSize;        /* size of file table */
  134. static char     *dirList[MAXDIRS];    /* list of dirs for searching files */
  135. static short    maxcol;
  136. static short    currvalue;
  137. X
  138. void source_init()
  139. {
  140. X    dirList[0] = NULL;
  141. }
  142. X
  143. /*
  144. X *  Update topline, bottomline, arrow sign, updown sign, stop signs, and
  145. X *  line label.
  146. X */
  147. /* ARGSUSED */
  148. void Update(w, event, params, num_params)
  149. X    Widget w;
  150. X    XEvent *event;
  151. X    String *params;
  152. X    Cardinal *num_params;
  153. {
  154. X    XmTextPosition     pos;
  155. X    int            topline;
  156. X    FileRec         *file;
  157. X    int Py;
  158. X    Arg args[5];
  159. X
  160. X    if (displayedFile) {
  161. X        file = displayedFile;
  162. X    pos = XmTextGetTopCharacter(sourceWindow);
  163. X    file->topPosition = pos;
  164. X    topline = TextPositionToLine(pos);
  165. X    /* Update the symbols only if the text scrolls */
  166. X    if (file->topline != topline) {
  167. X        file->topline = topline;
  168. X        file->bottomline = MIN (file->topline + file->lines - 1, 
  169. X                    file->lastline);
  170. X        if (*num_params == 1 && strcmp(params[0], "warp") == 0)
  171. X          {
  172. X        XmTextSetInsertionPosition(sourceWindow, 
  173. X                       file->linepos[file->topline]);
  174. X          }
  175. X
  176. X        UpdateLineLabel(file->topline);
  177. X            UpdateStops(file, -1);
  178. X            UpdateArrow(file);
  179. X            UpdateUpdown(file);
  180. X            UpdateBomb(file);
  181. X        Py = TextPositionToLine(XmTextGetTopCharacter(sourceWindow));
  182. X        XtSetArg(args[0], XmNvalue, Py);
  183. X        XtSetValues(scrollV, args, 1);
  184. X
  185. X    }
  186. X    else {/* Update caret position only */
  187. X        pos = XmTextGetInsertionPosition(sourceWindow);
  188. X        UpdateLineLabel(TextPositionToLine(pos));
  189. X    }
  190. X    }
  191. }
  192. X
  193. void UpdateSigns(reason)
  194. X     int reason;
  195. {
  196. X  int pos;
  197. X  FileRec *file;
  198. X  Arg args[MAXARGS];
  199. X
  200. X  file = displayedFile;
  201. X  pos = XmTextGetTopCharacter(sourceWindow);
  202. X  file->topline = TextPositionToLine(pos);
  203. X
  204. X  file->bottomline = MIN (file->topline + file->lines - 1, 
  205. X              file->lastline);
  206. X  UpdateStops(file, reason);
  207. X  UpdateArrow(file);
  208. X  UpdateUpdown(file);
  209. X  UpdateBomb(file);
  210. X
  211. }  
  212. X
  213. X
  214. /*  Update the position of the caret */
  215. /*  ARGSUSED */
  216. void UpdateLine(w, event, params, num_params)
  217. X    Widget w;
  218. X    XEvent *event;
  219. X    String *params;
  220. X    Cardinal *num_params;
  221. {
  222. X    XmTextPosition pos;
  223. X    int    line;
  224. X
  225. X    pos = XmTextGetInsertionPosition(w);
  226. X    line = TextPositionToLine(pos);
  227. X    UpdateLineLabel(line);
  228. }
  229. X
  230. X
  231. /*  My select-start routine that cancels the effect of automatic scrolling
  232. X *  near the bottom of an Athena text widget window.
  233. X */
  234. /*  ARGSUSED */
  235. void SelectStart(w, event, params, num_params)
  236. X    Widget w;
  237. X    XEvent *event;
  238. X    String *params;
  239. X    Cardinal *num_params;
  240. {
  241. X    XtCallActionProc(w, "set-insertion-point", event, params, num_params);
  242. X    XtCallActionProc(w, "grab-focus", event, params, num_params);
  243. }
  244. X
  245. /*  My select-end routine to store the text selection into both the PRIMARY
  246. X *  selection and cut buffer 0. 
  247. X */
  248. /*  ARGSUSED */
  249. void SelectEnd(w, event, params, num_params)
  250. X    Widget w;
  251. X    XEvent *event;
  252. X    String *params;
  253. X    Cardinal *num_params;
  254. {
  255. X    XtCallActionProc(w, "extend-end", event, params, num_params);
  256. }
  257. X
  258. /*  This is my own select word routine to replace the standard action
  259. X *  procedure provided by the Text widget.
  260. X *  It selects a word delimited by DELIMITERS, not whitespace.
  261. X */
  262. /* ARGSUSED */
  263. void SelectWord(w, event, params, num_params)
  264. X    Widget w;
  265. X    XEvent *event;
  266. X    String *params;
  267. X    Cardinal *num_params;
  268. {
  269. X    XmTextPosition left, right, center, last;
  270. X    char *valuestring;
  271. X
  272. X    XtCallActionProc(w, "set-insertion-point", event, params, num_params);
  273. X    center = XmTextGetInsertionPosition(w);
  274. X    valuestring = XmTextGetString(w);
  275. X    last = XmTextGetLastPosition(w);
  276. X
  277. X    if(strchr(DELIMITERS, valuestring[center])) return;
  278. X    left = center;
  279. X    right = center;
  280. X    
  281. X    while(left>0 && !strchr(DELIMITERS, valuestring[left-1])) left--;
  282. X    while(right<last && !strchr(DELIMITERS, valuestring[right])) right++;
  283. X
  284. X    XmTextSetSelection(w, left, right, 0);
  285. X    XtFree(valuestring);
  286. }
  287. X
  288. void SelectAdjust(w, event, params, num_params)
  289. X    Widget w;
  290. X    XEvent *event;
  291. X    String *params;
  292. X    Cardinal *num_params;
  293. {
  294. X    XtCallActionProc(w, "extend-adjust", event, params, num_params);
  295. }
  296. X
  297. void ScrollTxt(w, client_data, call_data)
  298. X     Widget w;
  299. X     XtPointer client_data;
  300. X     XmScrollBarCallbackStruct *call_data;
  301. {
  302. X  Arg args[5];
  303. X  int Py;
  304. X
  305. X  if(!displayedFile) return;
  306. X
  307. X  switch((unsigned int) client_data)
  308. X    {
  309. X    case _PAGERIGHT:
  310. X      XtCallActionProc(sourceWindow, "page-right", call_data->event, 
  311. X               NULL, 0);
  312. X      break;
  313. X    case _PAGELEFT:
  314. X      XtCallActionProc(sourceWindow, "page-left", call_data->event, 
  315. X               NULL, 0);
  316. X      break;
  317. X    case _SCROLLUPPAGE:
  318. X      XtCallActionProc(sourceWindow, "next-page", call_data->event, NULL, 0);
  319. X      Py = TextPositionToLine(XmTextGetTopCharacter(sourceWindow));
  320. X      XtSetArg(args[0], XmNvalue, Py);
  321. X      XtSetValues(scrollV, args, 1);
  322. X      break;
  323. X    case _SCROLLDOWNPAGE:
  324. X      XtCallActionProc(sourceWindow, "previous-page", call_data->event, 
  325. X               NULL, 0);
  326. X      Py = TextPositionToLine(XmTextGetTopCharacter(sourceWindow));
  327. X      XtSetArg(args[0], XmNvalue, Py);
  328. X      XtSetValues(scrollV, args, 1);
  329. X      break;
  330. X    default:
  331. X      XmTextSetTopCharacter(sourceWindow, 
  332. X                displayedFile->linepos[call_data->value]);
  333. X    }
  334. X  UpdateSigns(call_data->reason);
  335. }
  336. X
  337. void resetLineBounds(w, event, params, num_params)
  338. X     Widget w;
  339. X     XEvent *event;
  340. X     String *params;
  341. X     Cardinal *num_params;
  342. {
  343. X  Arg args[MAXARGS];
  344. X  short file_lines;
  345. X
  346. X  if(displayedFile)
  347. X    {
  348. X      XtSetArg(args[0], XmNrows, &file_lines);
  349. X      XtGetValues(sourceWindow, args, 1);
  350. X      displayedFile->lines = file_lines;
  351. X      displayedFile->bottomline = MIN (displayedFile->topline + 
  352. X                       displayedFile->lines - 1, 
  353. X                       displayedFile->lastline);
  354. X      UpdateSigns(SASH_MOTION);
  355. X    }
  356. }
  357. X
  358. #define BUTTONSNUM 18        /* Number of buttons */
  359. #define NCOLUMNS 2        /* Should divide BUTTONSNUM evenly */
  360. #define SPACEFACTOR 32        /* These number can be diddled. */
  361. #define BUTTONWIDTH 32
  362. #define FRACTIONBASE          ((BUTTONSNUM * SPACEFACTOR) / NCOLUMNS) 
  363. X
  364. void CreateCommandButtons(parent)
  365. Widget parent;
  366. {
  367. X  static buttonstruct commandbuttons[] = {
  368. X    { NULL, "stackbutton", stack_bits, stack_width, stack_height, DoIt, 
  369. X    "info stack\n" },
  370. X    { NULL, "runbutton", run_bits, run_width, run_height, DoIt, "run\n" },
  371. X    { NULL, "upbutton", up_bits, up_width, up_height, DoIt, "up\n" },
  372. X    { NULL, "localsbutton", locals_bits, locals_width, locals_height, DoIt, 
  373. X    "info locals\n" },
  374. X    { NULL, "downbutton", down_bits, down_width, down_height, DoIt, "down\n" },
  375. X    { NULL, "argsbutton", args_bits, args_width, args_height, DoIt, 
  376. X    "info args\n" },
  377. X    { NULL, "printbutton", print_bits, print_width, print_height, Print, 
  378. X    NULL },
  379. X    { NULL, "printsbutton", prints_bits, prints_width, prints_height, Print, 
  380. X    1 },
  381. X    { NULL, "nextbutton", next_bits, next_width, next_height, DoIt, "next\n" },
  382. X    { NULL, "contbutton", cont_bits, cont_width, cont_height, DoIt, "cont\n" },
  383. X    { NULL, "stepbutton", step_bits, step_width, step_height, DoIt, "step\n" },
  384. X    { NULL, "finishbutton", finish_bits, finish_width, finish_height, DoIt, 
  385. X    "finish\n" },
  386. X    { NULL, "breakbutton", stop_bits, stop_width, stop_height, Break, 
  387. X    "break" },
  388. X    { NULL, "clearbutton", clear_bits, clear_width, clear_height, Clear, 
  389. X    NULL },
  390. X    { NULL, "dispbutton", disp_bits, disp_width, disp_height, Display_, NULL },
  391. X    { NULL, "undispbutton", undisp_bits, undisp_width, undisp_height, 
  392. X    Undisplay,
  393. X    NULL },
  394. X    { NULL, "pageRbutton", pageR_bits, pageR_width, pageR_height, 
  395. X    ScrollTxt, _PAGERIGHT},
  396. X    { NULL, "pageLbutton", pageL_bits, pageL_width, pageL_height, 
  397. X    ScrollTxt, _PAGELEFT },
  398. X  };
  399. X
  400. X  Pixel bg;
  401. X  int screen;
  402. X  Display *topdisplay;
  403. X  int window1;
  404. X  int depth1;
  405. X  int buttonindex;
  406. X  XtCallbackList buttoncalls;
  407. X  Arg args[10];
  408. X
  409. X  static Arg buttonargs[] = {
  410. X    { XmNbottomAttachment, XmATTACH_POSITION },
  411. X    { XmNtopAttachment, XmATTACH_POSITION },
  412. X    { XmNrightAttachment, XmATTACH_FORM },
  413. X    { XmNwidth, BUTTONWIDTH },
  414. X    { XmNlabelType, XmPIXMAP },
  415. X    { XmNhighlightOnEnter, True },
  416. X    { 0, 0 },
  417. X    { 0, 0 },
  418. X    { 0, 0 },
  419. X  };
  420. X
  421. X  XtSetArg(args[0], XmNbackground, &bg);
  422. X  XtGetValues(sourceForm, args, 1);
  423. X  topdisplay = XtDisplay(toplevel);
  424. X  screen = DefaultScreen(topdisplay);
  425. X  window1 = DefaultRootWindow(topdisplay);
  426. X  depth1 = DefaultDepth(topdisplay, screen);
  427. X  
  428. X  for (buttonindex = 0; buttonindex < BUTTONSNUM; buttonindex++)
  429. X    {
  430. X      XtSetArg(buttonargs[6], XmNlabelPixmap, 
  431. X           XCreatePixmapFromBitmapData(topdisplay, window1,
  432. X                    commandbuttons[buttonindex].labelbits,
  433. X                    commandbuttons[buttonindex].labelwidth,
  434. X                    commandbuttons[buttonindex].labelheight, 
  435. X                    app_resources.stop_color, bg, 
  436. X                    depth1));
  437. X
  438. X      XtSetArg(buttonargs[7], XmNrightOffset,
  439. X           (buttonindex%NCOLUMNS)?(BUTTONWIDTH*(buttonindex%NCOLUMNS)):0);
  440. X      XtSetArg(buttonargs[8], XmNtopPosition, 
  441. X           ((buttonindex/NCOLUMNS) * SPACEFACTOR));
  442. X      XtSetArg(buttonargs[9], XmNbottomPosition,
  443. X           (((buttonindex/NCOLUMNS) + 1) * SPACEFACTOR));
  444. X      commandbuttons[buttonindex].button = 
  445. X    XtCreateManagedWidget(commandbuttons[buttonindex].buttonname,
  446. X                  xmPushButtonWidgetClass, parent,
  447. X                  buttonargs, 10);
  448. X      XtAddCallback(commandbuttons[buttonindex].button, 
  449. X            XmNactivateCallback, commandbuttons[buttonindex].CB, 
  450. X            commandbuttons[buttonindex].CBarg);
  451. X    }
  452. }
  453. /* 
  454. X *  On top of a form widget, we have a text widget, label
  455. X *  widgets for the stop sign, arrow sign, and updown signs.
  456. X */
  457. void CreateSourceWindow(parent)
  458. Widget parent;
  459. {
  460. X    Arg args[10];
  461. X
  462. X    static XtActionsRec command_actions[] = {
  463. X      { "SelectStart", (XtActionProc) SelectStart },
  464. X      { "SelectWord", (XtActionProc) SelectWord },
  465. X      { "SelectEnd", (XtActionProc) SelectEnd },
  466. X      { "SelectAdjust", (XtActionProc) SelectAdjust },
  467. X      { "Update", (XtActionProc) Update },
  468. X      { "resetLineBounds", (XtActionProc) resetLineBounds },
  469. X      { NULL, NULL }
  470. X    };
  471. X
  472. X    static Arg sourcewindowargs[] = {
  473. X      { XmNeditMode, XmMULTI_LINE_EDIT },
  474. X      { XmNrightAttachment, XmATTACH_FORM },
  475. X      { XmNbottomAttachment, XmATTACH_FORM },
  476. X      { XmNtopAttachment, XmATTACH_FORM },
  477. X      { XmNleftAttachment, XmATTACH_FORM },
  478. X      { XmNeditable, False },
  479. X      { XmNhighlightOnEnter, True },
  480. X      { XmNleftOffset, 50 },
  481. X      { 0, 0 },
  482. X    };
  483. X
  484. X    static Arg sourcescrollargs[] = {
  485. X      { XmNscrollingPolicy, XmAPPLICATION_DEFINED },
  486. X      { XmNscrollBarPlacement, XmBOTTOM_LEFT },
  487. X    };
  488. X
  489. X    static Arg commanddialogargs[] = {
  490. X      { XmNfractionBase, FRACTIONBASE },
  491. X      { XmNautoUnmanage, False },
  492. X    };
  493. X
  494. X    sourceScroll = XtCreateManagedWidget("sourceScroll", 
  495. X                     xmScrolledWindowWidgetClass,
  496. X                     parent, sourcescrollargs, 2);   
  497. X
  498. X    scrollV = XtCreateWidget("scrollV", xmScrollBarWidgetClass, sourceScroll,
  499. X                 args, 0);
  500. X
  501. X    XtSetArg(args[0], XmNfractionBase, FRACTIONBASE);
  502. X    sourceForm = XtCreateManagedWidget("sourceForm", xmFormWidgetClass,
  503. X                       sourceScroll, args, 1);
  504. X
  505. X    XmScrolledWindowSetAreas(sourceScroll, NULL, scrollV, sourceForm);
  506. X
  507. X    XtAddCallback(scrollV, XmNdecrementCallback, ScrollTxt, _SCROLLDOWN);
  508. X    XtAddCallback(scrollV, XmNincrementCallback, ScrollTxt, _SCROLLUP);
  509. X    XtAddCallback(scrollV, XmNpageIncrementCallback, ScrollTxt, _SCROLLUPPAGE);
  510. X    XtAddCallback(scrollV, XmNpageDecrementCallback, 
  511. X          ScrollTxt, _SCROLLDOWNPAGE);
  512. X    XtAddCallback(scrollV, XmNdragCallback, ScrollTxt, _SCROLLDRAG);
  513. X    if(!app_resources.useCommandDialog)
  514. X      XtSetArg(sourcewindowargs[8], XmNrightOffset, BUTTONWIDTH * NCOLUMNS);
  515. X    sourceWindow = XtCreateManagedWidget("sourceWindow", xmTextWidgetClass,
  516. X                     sourceForm, sourcewindowargs, 9);
  517. X    XtAppAddActions(app_context, command_actions, XtNumber(command_actions));
  518. X    if(app_resources.useCommandDialog)
  519. X      {
  520. X    commandDialog = XmCreateFormDialog(parent, "commandDialog",
  521. X                     commanddialogargs, 2);
  522. X    CreateCommandButtons(commandDialog);
  523. X      }
  524. X    else
  525. X      CreateCommandButtons(sourceForm);
  526. }
  527. X
  528. /* 
  529. X * Popup the commandDialog Box if we are using it.
  530. X *
  531. X */
  532. X
  533. void PopupCommands(w, client_data, call_data)
  534. X     Widget w;
  535. X     XtPointer client_data;
  536. X     XmPushButtonCallbackStruct *call_data;
  537. {
  538. X  if(app_resources.useCommandDialog)
  539. X    XtManageChild(commandDialog);
  540. X  else
  541. X    {
  542. X      UpdateMessageWindow("Not using command button dialog", NULL);
  543. X      bell(0);
  544. X    }
  545. }
  546. X
  547. /*
  548. X *  Build the array which gives the starting text position of each line.
  549. X *  > Estimate the number of lines in the file and allocate memory buffer.
  550. X *  > Starting position of line #1 is 0, and is stored in linepos[1].
  551. X *  > Search for '\n' till end of buffer.
  552. X */
  553. static void BuildLinePos(file)
  554. FileRec *file;
  555. {
  556. X    char *p;
  557. X    int     line, nlines;
  558. X
  559. X    nlines = MAX(2, file->filesize/CHARS_PER_LINE);
  560. X    file->linepos = (XmTextPosition *)
  561. X            XtMalloc ((nlines+1) * sizeof(XmTextPosition));
  562. X    p = file->buf;
  563. X
  564. X    file->linepos[0] = 0;
  565. X    file->linepos[1] = 0;
  566. X    line = 2;
  567. X   
  568. X    while (*p) {
  569. X    if (*p++ == '\n') {
  570. X        if (line == nlines) {     /* buffer full, need more memory */
  571. X                file->linepos = (XmTextPosition *) XtRealloc (file->linepos, 
  572. X              (nlines + ADD_LINES) * sizeof(XmTextPosition));
  573. X        nlines += ADD_LINES;
  574. X            }
  575. X            file->linepos[line++] = p - file->buf;
  576. X    }
  577. X    }
  578. X    file->lastline = line - 2;
  579. X    file->linepos = (XmTextPosition *) XtRealloc       /* shrink to min size */
  580. X            (file->linepos, line * sizeof(XmTextPosition));
  581. }
  582. X
  583. X
  584. /*
  585. X * Look up the file table for an entry with "filename"
  586. X * If not found, create an entry and initialize proper fields,
  587. X * else, return pointer to entry found.
  588. X */
  589. static LookUpFileTable(pathname, filename, file)
  590. char *pathname, *filename;
  591. FileRec **file;
  592. {
  593. X    struct stat fileinfo;
  594. X    int      fd;
  595. X    int     i, j, n;
  596. X
  597. X    for (i=0; fileTable && fileTable[i] && i<fileTableSize; i++) {
  598. X    if (!strcmp(fileTable[i]->pathname, pathname)) { /* file found */
  599. X        if (stat(pathname, &fileinfo) == -1) {
  600. X        UpdateMessageWindow("Error: cannot stat file %s", pathname);
  601. X            *file = fileTable[i];
  602. X        return 0;
  603. X        }
  604. X        if (fileinfo.st_mtime > fileTable[i]->mtime) { /* file modified */
  605. X        XtFree((char *)fileTable[i]->buf);
  606. X        XtFree((char *)fileTable[i]->linepos);
  607. X        XtFree((char *)fileTable[i]);
  608. X        displayedFile = NULL;
  609. X        break;
  610. X        }
  611. X        else if (displayedFile &&         /* same as displayed file */
  612. X             strcmp(pathname, displayedFile->pathname) == 0) {
  613. X        *file = NULL;
  614. X        return 0;
  615. X        }
  616. X        else {
  617. X            *file = fileTable[i];
  618. X        return 0;
  619. X        }
  620. X    }
  621. X    }
  622. X
  623. X    /* Record file into file table */
  624. X
  625. X    if (i == fileTableSize) {        /* file table full, enlarge it */
  626. X    fileTableSize += ADD_SIZE;
  627. X    fileTable = (FileRec **) 
  628. X             XtRealloc (fileTable, fileTableSize * sizeof(FileRec *));
  629. X    for (j=i; j<fileTableSize; j++)
  630. X        fileTable[j] = NULL;
  631. X    }
  632. X    if ((fd = open(pathname, O_RDONLY)) == -1) {
  633. X    UpdateMessageWindow("Error: cannot open file %s", pathname);
  634. X    return -1;
  635. X    }
  636. X    if (fstat(fd, &fileinfo) == -1) {
  637. X    UpdateMessageWindow("Error: cannot fstat file %s", pathname);
  638. X    close(fd);
  639. X    return -1;
  640. X    }
  641. X    fileTable[i] = (FileRec *) XtMalloc (sizeof(FileRec));
  642. X    fileTable[i]->filesize = fileinfo.st_size + 1;
  643. X    fileTable[i]->mtime = fileinfo.st_mtime;
  644. X    fileTable[i]->buf = XtMalloc((int)fileTable[i]->filesize);
  645. X    if ((n = read(fd, fileTable[i]->buf, (int) fileTable[i]->filesize)) == -1) {
  646. X    UpdateMessageWindow("Error: cannot read file %s", pathname);
  647. X    XtFree(fileTable[i]->buf);
  648. X    XtFree(fileTable[i]);
  649. X    fileTable[i] = NULL;
  650. X    close(fd);
  651. X    return -1;
  652. X    }
  653. X    fileTable[i]->buf[n] = '\0';
  654. X    fileTable[i]->pathname = XtNewString(pathname);
  655. X    fileTable[i]->filename = XtNewString(filename);
  656. X    fileTable[i]->currentline = 1;
  657. X    fileTable[i]->topline = 1;
  658. X    fileTable[i]->bottomline = 0;
  659. X    fileTable[i]->topPosition = 0;
  660. X    BuildLinePos(fileTable[i]);
  661. X    close(fd);
  662. X    *file = fileTable[i];
  663. X    return 0;
  664. }
  665. X
  666. /*  
  667. X *  Remember file position and current line before closing.
  668. X */
  669. static void SaveDisplayedFileInfo()
  670. {
  671. X    XmTextPosition pos;
  672. X    Arg args[MAXARGS];
  673. X
  674. X    if (displayedFile) {
  675. X      XtSetArg(args[0], XmNtopPosition, &(displayedFile->topPosition));
  676. X      XtGetValues(sourceWindow, args, 1);
  677. X      XtSetArg(args[0], XmNcursorPosition, &pos);
  678. X      XtGetValues(sourceWindow, args, 1);
  679. X      displayedFile->currentline = TextPositionToLine(pos);
  680. X    }
  681. }
  682. X
  683. X
  684. /*   DisplayFile() displays the file onto the source window.  It
  685. X *     uses topPosition to remember where it was last opened.  But it
  686. X *     must recalculate bottomline because the window size might be
  687. X *     different.
  688. X */
  689. static void DisplayFile(file)
  690. FileRec *file;
  691. {
  692. X    Arg     args[MAXARGS];
  693. X    short       columns, rows, rowcount;
  694. X    int         slidersize;
  695. X    Dimension   height, width;
  696. X
  697. X    XtSetArg(args[0], XmNeditable, False);
  698. X    XtSetArg(args[1], XmNvalue, file->buf);
  699. X    XtSetValues(sourceWindow, args, 2);
  700. X
  701. X    XtSetArg(args[0], XmNrows, &rows);
  702. X    XtSetArg(args[1], XmNcolumns, &columns);
  703. X    XtGetValues(sourceWindow, args, 2);
  704. X
  705. X    file->lines = rows;
  706. X    file->bottomline = MIN (file->topline + file->lines - 1, file->lastline);
  707. X
  708. X    if(file->lastline < rows)
  709. X      {
  710. X    if(XtIsManaged(scrollV))
  711. X        XtUnmanageChild(scrollV);
  712. X      }
  713. X    else
  714. X      {
  715. X    XtSetArg(args[0], XmNheight, &height);
  716. X    XtGetValues(scrollV, args, 1);
  717. X    slidersize = ((int)rows * (int)height)/(int)file->lastline;
  718. X    XmScrollBarSetValues(scrollV, 1, slidersize, 1, 0, True);
  719. X    XtSetArg(args[0], XmNmaximum, file->lastline+slidersize);
  720. X    XtSetArg(args[1], XmNminimum, 0);
  721. X    XtSetValues(scrollV, args, 2);
  722. X    XtManageChild(scrollV);
  723. X      }
  724. }
  725. X
  726. X
  727. /*  Given a filename starting with a tilde (`~'), it expands ~[user] to
  728. X *  the home directory of that user, or to the login home directory if user
  729. X *  is not specified.
  730. X */
  731. static char *expand(filename)
  732. char *filename;
  733. {
  734. X    struct passwd *pwd;
  735. X    char       *string, *name, newfile[MAXNAME];
  736. X
  737. X    string = XtNewString(filename+1);
  738. X    if (*string == '\0' || *string == '/')
  739. X    name = (char *) getlogin();
  740. X    else
  741. X        name = (char *) strtok(string, "/");
  742. X    if (name == NULL)
  743. X    return filename;
  744. X    pwd = (struct passwd *) getpwnam(name);
  745. X    if (pwd && pwd->pw_dir) {
  746. X        sprintf(newfile, "%s%s", pwd->pw_dir, filename+strlen(name)+1);
  747. X        return XtNewString(newfile);
  748. X    }
  749. X    else
  750. X    return filename;
  751. }
  752. X
  753. X
  754. /*  Create a list of directories for searching source files.
  755. X *  It reads the list of directories specified by the user, adding
  756. X *  the current directory into the list if it is not already there.
  757. X *
  758. X *  With fix from Dave Gagne (daveg@fs1.ee.ubc.ca) 7/30/90
  759. X */
  760. void MakeDirList(output)
  761. char *output;
  762. {
  763. X    char *s, list[BUFSIZ], command[LINESIZ];
  764. X    int  i, use_cwd;
  765. X
  766. X    for (i=0; dirList[i]; i++)            /* remove old list */
  767. X    XtFree(dirList[i]);
  768. X    i = 0;
  769. X    use_cwd = TRUE;
  770. X    if (output) {                                        /* create list */
  771. X        s = (char *) strtok(output, ": \n");
  772. X        while (s) {
  773. X            dirList[i] = XtNewString(s);
  774. X
  775. X            if (dirList[i][0] == '~')                   /* expand '~' */
  776. X                dirList[i] = expand(dirList[i]);
  777. X            if (LASTCH(dirList[i]) == '/')              /* remove last '/' */
  778. X                LASTCH(dirList[i]) = '\0';
  779. X            if (!strcmp(dirList[i], "."))        /* watch for "." */
  780. X                use_cwd = FALSE;
  781. X
  782. X            ++i;
  783. X            s = (char *) strtok(NULL, " \n");
  784. X        }
  785. X        dirList[i] = NULL;
  786. X    }
  787. X
  788. X    if (use_cwd) {                /* include current dir */
  789. X    dirList[i++] = XtNewString(".");        
  790. X        dirList[i] = NULL;
  791. X    }
  792. X    strcpy(list, "");                /* tell dbx our new list */
  793. X    for (i=0; dirList[i]; i++) {
  794. X    strcat(list, dirList[i]);
  795. X    strcat(list, " ");
  796. X    }
  797. X    sprintf(command, "directory %s\n", list);
  798. X    Parse = False;
  799. X    query_dbx(command);
  800. }
  801. X
  802. X
  803. /*  Returns the full pathname of a given file.
  804. X *  It searches for the file from a list of directories.
  805. X */
  806. char *GetPathname(filename)
  807. char *filename;
  808. {
  809. X    char    pathname[LINESIZ];
  810. X    int     i;
  811. X
  812. X    if (filename == NULL || !strcmp(filename, ""))
  813. X    return NULL;
  814. X    for (i=0; dirList[i]; i++) {
  815. X    if (*filename == '/' && access(filename, R_OK) == -1) { 
  816. X        /* this handles the exceptional case of sun4 dbx output */
  817. X        strcpy(filename, &filename[1]);
  818. X    }
  819. X    if (*filename == '/' || *filename == '~')
  820. X         strcpy(pathname, filename);
  821. X    else if (!strcmp(dirList[i], "."))
  822. X         sprintf(pathname, "%s/%s", cwd, filename);
  823. X    else if (*dirList[i] == '/' || *dirList[i] == '~')
  824. X         sprintf(pathname, "%s/%s", dirList[i], filename);
  825. X    else
  826. X         sprintf(pathname, "%s/%s/%s", cwd, dirList[i], filename);
  827. X    if (access(pathname, R_OK) == 0)
  828. X        return XtNewString(pathname);
  829. X    }
  830. X    UpdateMessageWindow("File not found: %s", filename);
  831. X    return NULL;
  832. }
  833. X
  834. /*
  835. X * Given a file name, LoadFile attempts to open it and displays it onto
  836. X * the source window:
  837. X *   1. get the full pathname of the file
  838. X *   2. LookUpFileTable() returns a pointer to the file's entry if it's
  839. X *      already in the table; else, creates an entry and return a pointer.
  840. X *   3. save the current displayedFile info
  841. X *   4. display the file
  842. X *   5. update the file label and the various signs on the source window.
  843. X *  LoadFile returns 0 upon successful completion, -1 otherwise.
  844. X */
  845. int LoadFile(filename)
  846. char *filename;
  847. {
  848. X    FileRec     *file;
  849. X    char    *pathname;
  850. X    Arg         args[5];
  851. X    Position    Py;
  852. X    
  853. X
  854. X    pathname = GetPathname(filename);
  855. X    if (pathname == NULL) { 
  856. X    return -1;
  857. X    }
  858. X    if (LookUpFileTable(pathname, filename, &file) != -1) {
  859. X    if (file) {    /* load new file */
  860. X        SaveDisplayedFileInfo();
  861. X        DisplayFile(file);
  862. X        UpdateFileLabel(pathname);
  863. X        XmTextClearSelection(sourceWindow,0);
  864. X        XmTextSetInsertionPosition(sourceWindow, 
  865. X                       file->linepos[file->currentline]);
  866. X        UpdateLineLabel(file->currentline);
  867. X        UpdateStops(file, -1);
  868. X        UpdateArrow(file);
  869. X        UpdateUpdown(file);
  870. X        UpdateBomb(file);
  871. X        displayedFile = file;
  872. X    }
  873. X        return 0;
  874. X    }
  875. X    else {        /* LookUpFileTable() fails */
  876. X        return -1;
  877. X    }
  878. }
  879. X
  880. int LoadCurrentFile()
  881. {
  882. X    query_dbx("info line\n");
  883. X    return LoadFile(CurrentFile);
  884. }
  885. X
  886. X
  887. SHAR_EOF
  888. echo 'File mxgdb/source.c is complete' &&
  889. chmod 0664 mxgdb/source.c ||
  890. echo 'restore of mxgdb/source.c failed'
  891. Wc_c="`wc -c < 'mxgdb/source.c'`"
  892. test 27029 -eq "$Wc_c" ||
  893.     echo 'mxgdb/source.c: original size 27029, current size' "$Wc_c"
  894. rm -f _shar_wnt_.tmp
  895. fi
  896. # ============= mxgdb/signs.c ==============
  897. if test -f 'mxgdb/signs.c' -a X"$1" != X"-c"; then
  898.     echo 'x - skipping mxgdb/signs.c (File already exists)'
  899.     rm -f _shar_wnt_.tmp
  900. else
  901. > _shar_wnt_.tmp
  902. echo 'x - extracting mxgdb/signs.c (Text)'
  903. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/signs.c' &&
  904. static char rcsid[] = "$Id: signs.c,v 1.4 1991/08/07 21:30:42 jtsillas Exp $";
  905. X
  906. /*****************************************************************************
  907. X *
  908. X *  xdbx - X Window System interface to the dbx debugger
  909. X *
  910. X *  Copyright 1989 The University of Texas at Austin
  911. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  912. X *
  913. X *  Permission to use, copy, modify, and distribute this software and its
  914. X *  documentation for any purpose and without fee is hereby granted,
  915. X *  provided that the above copyright notice appear in all copies and that
  916. X *  both that copyright notice and this permission notice appear in
  917. X *  supporting documentation, and that the name of The University of Texas
  918. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  919. X *  used in advertising or publicity pertaining to distribution of
  920. X *  the software without specific, written prior permission.  The
  921. X *  University of Texas and MCC makes no representations about the 
  922. X *  suitability of this software for any purpose.  It is provided "as is" 
  923. X *  without express or implied warranty.
  924. X *
  925. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  926. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  927. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  928. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  929. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  930. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  931. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  932. X *
  933. X *  Author:      Po Cheung
  934. X *  Created:       March 10, 1989
  935. X *
  936. X *****************************************************************************/
  937. X
  938. /*  signs.c
  939. X *
  940. X *  This file contains all the routines for the creation and manipulation of 
  941. X *  symbols used in xdbx.  There are 3 different signs:
  942. X *    arrow  - a solid right arrow to indicate the current execution point.
  943. X *    updown - an outlined right arrow to indicate position in stack trace.
  944. X *    stop   - a stop hand symbol to indicate a breakpoint is set.
  945. X *    bomb  - a bomb symbol to indicate the point of segmentation fault.
  946. X *
  947. X *  To display a sign on a given line in the source window, it is first
  948. X *  created and mapped.  To undisplay it, the sign is unmapped.  It can
  949. X *  be mapped again when the sign is needed.  Note that the sign is never
  950. X *  moved, so that there can be as many signs created (but not mapped) as
  951. X *  the number of lines in the source window.
  952. X *  For arrow and updown, there can be at most one of each mapped at a time.
  953. X *  For stop, there can be more than one mapped at the same time.
  954. X */
  955. X
  956. #include "global.h"
  957. #include "bitmaps.h"
  958. #include <Xm/Xm.h>
  959. #include <Xm/Label.h>
  960. X
  961. #define MAXSTOPS        256             /* max number of stops */
  962. #define MAXSIGNS        256             /* max number of signs */
  963. #define OFFSET            0                 /* offset for displaying signs */
  964. X
  965. ArrowSign     arrowsign[MAXSIGNS];
  966. UpdownSign     updownsign[MAXSIGNS];
  967. StopSign        stopsign[MAXSIGNS];
  968. BombSign     bombsign[MAXSIGNS];
  969. X
  970. Arrow         arrow;
  971. Updown         updown;
  972. Stops        stops[MAXSTOPS];    /* array of stops */
  973. Bomb         bomb;
  974. Cardinal    nstops;            /* number of stops */
  975. X
  976. /* Initialize data structures */
  977. X
  978. void signs_init()
  979. {
  980. X    int i;
  981. X
  982. X    for (i=0; i<MAXSIGNS; i++) {
  983. X    arrowsign[i].w = NULL;
  984. X    arrowsign[i].mapped = FALSE;
  985. X    }
  986. X    for (i=0; i<MAXSIGNS; i++) {
  987. X    stopsign[i].w = NULL;
  988. X    stopsign[i].mapped = FALSE;
  989. X    }
  990. X    arrow.i = 0;
  991. X    arrow.line = 0;
  992. X    strcpy(arrow.file, "");
  993. X    updown.i = 0;
  994. X    updown.line = 0;
  995. X    strcpy(updown.file, "");
  996. X    nstops = 0;
  997. X    bomb.i = 0;
  998. X    bomb.line = 0;
  999. X    strcpy(bomb.file, "");
  1000. }
  1001. X
  1002. X
  1003. /*  Create an arrow symbol, updown symbol or stop symbol:
  1004. X *    calculate the position of the symbol based on i, the number of lines
  1005. X *    from the top line.
  1006. X *    create the pixmap of the symbol
  1007. X *    display the symbol as a bitmap in a label widget.
  1008. X */
  1009. static Widget CreateSign(parent, textW, sign, i)
  1010. X     Widget    parent;
  1011. X     Widget     textW;
  1012. X     char    *sign;
  1013. X     Cardinal     i;
  1014. {
  1015. X    Arg     args[15];
  1016. X    Cardinal     n;
  1017. X    Dimension     source_height, height, width; 
  1018. X    char    *bits;
  1019. X    Pixel       fg, bg;
  1020. X    int     horizDistance, vertDistance, height_per_line;
  1021. X    int         screen;
  1022. X
  1023. X    if (displayedFile == NULL) return NULL;
  1024. X
  1025. X    /* Get height and background pixel values of parent window */
  1026. X    XtSetArg(args[0], XmNheight, &source_height);
  1027. X    XtSetArg(args[1], XmNbackground, &bg);
  1028. X    XtGetValues(textW, args, 2);
  1029. X
  1030. X    height_per_line = source_height/displayedFile->lines;
  1031. X    vertDistance = OFFSET + (i * height_per_line); 
  1032. X
  1033. X    screen = DefaultScreen(display);
  1034. X
  1035. X    if (sign && !strcmp(sign, "arrow")) {
  1036. X    bits = arrow_bits;
  1037. X    width = arrow_width;
  1038. X    height = arrow_height;
  1039. X    horizDistance = 0;
  1040. X    fg = app_resources.arrow_color;
  1041. X    }
  1042. X    else if (sign && !strcmp(sign, "updown")) {
  1043. X    bits = updown_bits;
  1044. X    width = updown_width;
  1045. X    height = updown_height;
  1046. X    horizDistance = 0;
  1047. X    fg = app_resources.updown_color;
  1048. X    }
  1049. X    else if (sign && !strcmp(sign, "stop")) {
  1050. X    bits = stop_bits;
  1051. X    width = stop_width;
  1052. X    height = stop_height;
  1053. X    horizDistance = arrow_width;
  1054. X    fg = app_resources.stop_color;
  1055. X    }
  1056. X    else if (sign && !strcmp(sign, "bomb")) {
  1057. X    bits = bomb_bits;
  1058. X    width = bomb_width;
  1059. X    height = bomb_height;
  1060. X    horizDistance = 0;
  1061. X    fg = app_resources.bomb_color;
  1062. X    };
  1063. X
  1064. X    n = 0;
  1065. X    XtSetArg(args[n], XmNborderWidth, 0);                n++;
  1066. X    XtSetArg(args[n], XmNwidth, (XtArgVal) width);            n++;
  1067. X    XtSetArg(args[n], XmNheight, (XtArgVal) height);            n++;
  1068. X    XtSetArg(args[n], XmNlabelType, XmPIXMAP);            n++;
  1069. X    XtSetArg(args[n], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  1070. X        display, DefaultRootWindow(display), bits, width, height,
  1071. X        fg, bg, DefaultDepth(display, screen)));            n++;
  1072. X
  1073. X    XtSetArg(args[n], XmNx, (XtArgVal) horizDistance+5);
  1074. X                                    n++;
  1075. X    XtSetArg(args[n], XmNy, (XtArgVal) vertDistance+3);    n++;
  1076. X    XtSetArg(args[n], XmNmappedWhenManaged, False);      n++;
  1077. X
  1078. X    return XtCreateManagedWidget(sign, xmLabelWidgetClass, parent, args, n);
  1079. }
  1080. X
  1081. /*
  1082. X *  Given a line number, displays a stop sign if that line is viewable.
  1083. X *  If the stop widget for that line does not exist, create one and map it.
  1084. X *  If the stop widget exists but not mapped, map it.
  1085. X */
  1086. void DisplayStop(file, line)
  1087. FileRec *file;
  1088. int    line;
  1089. {
  1090. X    Cardinal i;
  1091. X    Arg args[MAXARGS];
  1092. X
  1093. X    if (line >= file->topline && line <= file->bottomline) {
  1094. X    i = line - file->topline;
  1095. X    if (stopsign[i].w == NULL) {    /* widget does not exist */
  1096. X
  1097. X        stopsign[i].w = CreateSign(sourceForm, sourceWindow, "stop", i);
  1098. X        XtMapWidget(stopsign[i].w);
  1099. X        stopsign[i].mapped = 1;
  1100. X    }
  1101. X    else if (!stopsign[i].mapped) { /* widget not mapped */
  1102. X        XtMapWidget(stopsign[i].w);
  1103. X        stopsign[i].mapped = 1;
  1104. X    }
  1105. X    }
  1106. }
  1107. X
  1108. /*
  1109. X *  Unmap all stop signs and then display only those stops that are viewable.
  1110. X */
  1111. void UpdateStops(file, reason)
  1112. FileRec *file;
  1113. int reason;
  1114. {
  1115. X    Cardinal i;
  1116. X    int     line; 
  1117. X    Position vert;
  1118. X    Dimension source_height;
  1119. X    Arg args[1];
  1120. X
  1121. X
  1122. X    if (file == NULL) return;
  1123. X    for (i=0; i<file->lines; i++)
  1124. X    if (stopsign[i].w && stopsign[i].mapped) {
  1125. X        XtUnmapWidget(stopsign[i].w);
  1126. X        stopsign[i].mapped = 0;
  1127. X    }
  1128. X
  1129. X    for (i=1; i<=nstops; i++)
  1130. X    if (stops[i].file && !strcmp(stops[i].file, file->pathname) &&
  1131. X        (line=stops[i].line) && line >= file->topline &&
  1132. X        line <= file->bottomline) {
  1133. X        DisplayStop(file, line);
  1134. X    }
  1135. }
  1136. X
  1137. /*
  1138. X * Given a line number, unmap the stop sign associated with that line.
  1139. X */
  1140. void RemoveStop(line)
  1141. int line;
  1142. {
  1143. X    Cardinal i;
  1144. X    char command[30];
  1145. X
  1146. X    if (displayedFile && line >= displayedFile->topline && 
  1147. X             line <= displayedFile->bottomline) {
  1148. X    i = line - displayedFile->topline;
  1149. X    if (stopsign[i].w && stopsign[i].mapped) {
  1150. X        XtUnmapWidget(stopsign[i].w);
  1151. X        stopsign[i].mapped = 0;
  1152. X
  1153. X        sprintf(command, "clear %d\n", line);
  1154. X        send_command(command);
  1155. X        Echo = False;
  1156. X        Parse = False;
  1157. X        Prompt = False;
  1158. X        while(!Prompt) read_dbx();
  1159. X        
  1160. X    }
  1161. X    }
  1162. }
  1163. X
  1164. void ClearStops()
  1165. {
  1166. X    int i;
  1167. X
  1168. X    for (i=1; i<=nstops; i++) {
  1169. X    stops[i].file = NULL;
  1170. X    stops[i].line = 0;
  1171. X    }
  1172. }
  1173. X
  1174. /*  Unmap the current arrow sign.
  1175. X *  Display a new arrow sign if it is viewable.
  1176. X */
  1177. void UpdateArrow(file)
  1178. FileRec *file;
  1179. {
  1180. X    Cardinal i;
  1181. X    int         line;
  1182. X
  1183. X    if (file == NULL) return;
  1184. X    i = arrow.i;
  1185. X    if (i>=0 && i<file->lines)
  1186. X    if (arrowsign[i].w && arrowsign[i].mapped) {
  1187. X        XtUnmapWidget(arrowsign[i].w);
  1188. X        arrowsign[i].mapped = 0;
  1189. X    }
  1190. X    line = arrow.line;
  1191. X    if (arrow.file && !strcmp(arrow.file, file->pathname) &&
  1192. X        line >= file->topline && line <= file->bottomline) {
  1193. X        i = line - file->topline;
  1194. X    arrow.i = i;
  1195. X    if (arrowsign[i].w == NULL) {
  1196. X        arrowsign[i].w = CreateSign(sourceForm, sourceWindow, "arrow", i);
  1197. X        XtMapWidget(arrowsign[i].w);
  1198. X        arrowsign[i].mapped = TRUE;
  1199. X    }
  1200. X    else if (!arrowsign[i].mapped) {
  1201. X        XtMapWidget(arrowsign[i].w);
  1202. X        arrowsign[i].mapped = TRUE;
  1203. X    }
  1204. X    }
  1205. }
  1206. X
  1207. X
  1208. /*  If the new updown is on the same line as the arrow, remove the updown.
  1209. X *  Unmap current updown sign.
  1210. X *  Display the updown if it is viewable.
  1211. X */
  1212. void UpdateUpdown(file)
  1213. FileRec *file;
  1214. {
  1215. X    Cardinal i;
  1216. X    int         line;
  1217. X
  1218. X    if (file == NULL) return;
  1219. X    if (updown.file && !strcmp(updown.file, arrow.file) && 
  1220. X    !strcmp(updown.func, arrow.func) && (updown.line == arrow.line)) {
  1221. X    updown.line = 0;
  1222. X    strcpy(updown.file, "");
  1223. X    }
  1224. X    i = updown.i;
  1225. X    if (i>=0 && i<file->lines)
  1226. X    if (updownsign[i].w && updownsign[i].mapped) {
  1227. X        XtUnmapWidget(updownsign[i].w);
  1228. X        updownsign[i].mapped = 0;
  1229. X    }
  1230. X    line = updown.line;
  1231. X    if (updown.file && !strcmp(updown.file, file->pathname) &&
  1232. X        line >= file->topline && line <= file->bottomline) {
  1233. X        i = line - file->topline;
  1234. X    updown.i = i;
  1235. X    if (updownsign[i].w == NULL) {
  1236. X        updownsign[i].w = CreateSign(sourceForm, sourceWindow, "updown", i);
  1237. X        XtMapWidget(updownsign[i].w);
  1238. X        updownsign[i].mapped = TRUE;
  1239. X    }
  1240. X    else if (!updownsign[i].mapped) {
  1241. X        XtMapWidget(updownsign[i].w);
  1242. X        updownsign[i].mapped = TRUE;
  1243. X    }
  1244. X    }
  1245. }
  1246. X
  1247. /*  Unmap the current bomb sign, if any.
  1248. X *  Display a new bomb sign.
  1249. X */
  1250. void UpdateBomb(file)
  1251. FileRec *file;
  1252. {
  1253. X    Cardinal i;
  1254. X    int         line;
  1255. X
  1256. X    if (file == NULL) return;
  1257. X    i = bomb.i;
  1258. X    if (i>=0 && i<file->lines)
  1259. X    if (bombsign[i].w && bombsign[i].mapped) {
  1260. X        XtUnmapWidget(bombsign[i].w);
  1261. X        bombsign[i].mapped = 0;
  1262. X    }
  1263. X    line = bomb.line;
  1264. X    if (bomb.file && !strcmp(bomb.file, file->pathname) &&
  1265. X        line >= file->topline && line <= file->bottomline) {
  1266. X        i = line - file->topline;
  1267. X    bomb.i = i;
  1268. X    if (bombsign[i].w == NULL) {
  1269. X        bombsign[i].w = CreateSign(sourceForm, sourceWindow, "bomb", i);
  1270. X        XtMapWidget(bombsign[i].w);
  1271. X        bombsign[i].mapped = TRUE;
  1272. X    }
  1273. X    else if (!bombsign[i].mapped) {
  1274. X        XtMapWidget(bombsign[i].w);
  1275. X        bombsign[i].mapped = TRUE;
  1276. X    }
  1277. X    }
  1278. }
  1279. SHAR_EOF
  1280. chmod 0644 mxgdb/signs.c ||
  1281. echo 'restore of mxgdb/signs.c failed'
  1282. Wc_c="`wc -c < 'mxgdb/signs.c'`"
  1283. test 10834 -eq "$Wc_c" ||
  1284.     echo 'mxgdb/signs.c: original size 10834, current size' "$Wc_c"
  1285. rm -f _shar_wnt_.tmp
  1286. fi
  1287. # ============= mxgdb/windows.c ==============
  1288. if test -f 'mxgdb/windows.c' -a X"$1" != X"-c"; then
  1289.     echo 'x - skipping mxgdb/windows.c (File already exists)'
  1290.     rm -f _shar_wnt_.tmp
  1291. else
  1292. > _shar_wnt_.tmp
  1293. echo 'x - extracting mxgdb/windows.c (Text)'
  1294. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/windows.c' &&
  1295. static char rcsid[] = "$Id: windows.c,v 1.17 1991/08/23 16:34:46 jtsillas Exp $";
  1296. X
  1297. /*****************************************************************************
  1298. X *
  1299. X *  xdbx - X Window System interface to dbx
  1300. X *
  1301. X *  Copyright 1989, 1990 The University of Texas at Austin
  1302. X *
  1303. X *  Permission to use, copy, modify, and distribute this software and its
  1304. X *  documentation for any purpose and without fee is hereby granted,
  1305. X *  provided that the above copyright notice appear in all copies and that
  1306. X *  both that copyright notice and this permission notice appear in
  1307. X *  supporting documentation, and that the name of The University of Texas
  1308. SHAR_EOF
  1309. true || echo 'restore of mxgdb/windows.c failed'
  1310. fi
  1311. echo 'End of  part 3'
  1312. echo 'File mxgdb/windows.c is continued in part 4'
  1313. echo 4 > _shar_seq_.tmp
  1314. exit 0
  1315.