|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T v
Length: 9236 (0x2414)
Types: TextFile
Names: »view.c«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
└─⟦e10a7c8ba⟧ »./UNRELEASED/xgdb.tar.Z«
└─⟦ae30648b5⟧
└─⟦this⟧ »./view.c«
\f
#ifndef lint
static char rcsid[] = "$Header: view.c,v 1.1 89/07/05 15:37:01 hubbard Exp $";
#endif
/*
*
* Copyright 1988, 1989
* PCS Computer Systeme, GmbH
* Munich, West Germany
*
* All rights reserved.
*
* This is unsupported software and is subject to change without notice.
* PCS makes no representations about the suitability of this software
* for any purpose. It is supplied "as is" without express or implied
* warranty.
*
* 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, and that the name of PCS Computer Systeme not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission.
*
*/
/*
* Author: Jordan K. Hubbard
* For: PCS Computer Systems, GmbH.
* When: April 2nd, 1989.
*
* $Log: view.c,v $
* Revision 1.1 89/07/05 15:37:01 hubbard
* Initial revision
*
*
*/
#include "xgdb.h"
XContext ViewContext;
/*
* Close a view. Destroys the top level (view) widget and sets it to NULL.
*/
void viewClose(w, client_data, data)
Widget w;
caddr_t client_data;
caddr_t data;
{
View *tmp;
Entry("viewClose");
tmp = (View *)client_data;
XDeleteContext(XtDisplay(w), tmp->parent, ViewContext);
XDeleteContext(XtDisplay(w), tmp->output, ViewContext);
XtDestroyWidget(tmp->view);
tmp->view = (Widget)NULL;
XSync(XtDisplay(Toplevel), FALSE);
Leave_void;
}
/*
* Create a "view". Usage of this routine to create "views" is not
* manadatory, as one might want the output areas to look differently,
* but it is necessary that the View structure be filled in by whatever
* routine is used. Every view is created as a form containing a number of
* labels and an output area of type "wtype". Pre-initialized argument
* values for this output widget are passed in via "a" and "num".
*/
void viewCreate(view, parent, name, aux, wtype, a, num)
View *view;
Widget parent;
String name;
Field *aux;
WidgetClass wtype;
Arg *a;
Cardinal num;
{
Widget tmp = (Widget)NULL;
static XtCallbackRec callbck[2];
Entry("viewCreate");
#ifdef SYSV
suspendProcessHandling();
#endif
if (!ViewContext)
ViewContext = XUniqueContext();
i = 0;
view->parent = parent;
view->name = name;
view->view = XtCreateManagedWidget(strconcat(name, "-view"),
formWidgetClass, parent,
args, i);
if (aux) {
i = 0;
createFields(view->view, aux, view);
view->fields = aux;
tmp = aux[0].me;
}
/* Some of these were pre-set by the caller */
if (tmp) {
XtSetArg(a[num], XtNfromVert, tmp); num++;
}
XtSetArg(a[num], XtNtop, XtChainTop); num++;
XtSetArg(a[num], XtNbottom, XtChainBottom); num++;
XtSetArg(a[num], XtNleft, XtChainLeft); num++;
XtSetArg(a[num], XtNright, XtChainRight); num++;
view->output = XtCreateManagedWidget(strconcat(name, "-output"),
wtype, view->view,
a, num);
view->type = wtype;
XSaveContext(XtDisplay(parent), parent, ViewContext, view);
XSaveContext(XtDisplay(parent), view->output, ViewContext, view);
#ifdef SYSV
resumeProcessHandling();
#endif
Leave_void;
}
/*
* Destroy a shell view.
*/
void viewDestroyShell(view)
View *view;
{
Entry("viewDestroyShell");
XtPopdown(view->parent);
viewClose(view->parent, view, 0);
XtDestroyWidget(view->parent);
XtFree(view);
Leave_void;
}
/*
* Close a shell view. (Don't destroy, just pop down).
*/
void viewCloseShell(w, client_data, data)
Widget w;
caddr_t client_data, data;
{
View *vp;
FieldAttributes fla;
Entry("viewCloseShell");
vp = (View *)client_data;
XtPopdown(vp->parent);
vp->mapped = FALSE;
/* Put the menu pane label back */
fla.sensitive = TRUE;
changeField(nameToField(vp->name, MenuButtons), FldSensitive,
&fla);
Leave_void;
}
/*
* For translation close.
*/
void view_close(w, ev, av, ac)
Widget w;
XEvent *ev;
String *av;
Cardinal *ac;
{
View *tmp;
Entry("view_close");
if (!XFindContext(XtDisplay(w), w, ViewContext, &tmp))
viewCloseShell(NULL, tmp, NULL);
else
puke("%p: Can't find view struct for widget '%x'", w);
Leave_void;
}
/*
* Creates a view in its own top level window.
*/
View *viewCreateShell(name, aux, type, a, num)
String name;
Field *aux;
WidgetClass type;
Arg *a;
Cardinal num;
{
View *me;
Widget shell;
XWindowAttributes xwa;
static char view_trans[] = "<Key>Q: ViewClose()\n<Key>C: ViewClose()";
static XtTranslations trans = NULL;
Entry("viewCreateShell");
if (!trans)
trans = XtParseTranslationTable(view_trans);
me = (View *)XtMalloc(sizeof(View));
bzero(me, sizeof(View));
/* This seems a reasonable default size. */
i = 0;
XtSetArg(args[i], XtNwidth, 450); i++;
XtSetArg(args[i], XtNheight, 200); i++;
shell = XtCreatePopupShell(name, topLevelShellWidgetClass,
Toplevel, args, i);
/* assume a size */
xwa.width = 450;
xwa.height = 200;
/* Try to make view fit reasonably (with some padding) in shell */
XtSetArg(a[num], XtNwidth, xwa.width - 13); num++;
XtSetArg(a[num], XtNheight, xwa.height - 35); num++;
viewCreate(me, shell, name, aux, type, a, num);
XtOverrideTranslations(shell, trans);
XtOverrideTranslations(me->output, trans);
Leave(me);
}
/*
* Append string to view (either asciiStringWidget or ttyWidget)
*/
void viewAppendText(view, src, srclen)
View *view;
char *src;
int srclen;
{
Entry("viewAppendText");
if (!view) {
puke("%p: Passed NULL pointer");
Leave_void;
}
#ifdef SYSV
suspendProcessHandling();
#endif
/*
* If it's an asciiStringWidget, we do our own buffer management.
*/
if (view->type == asciiStringWidgetClass) {
int len;
i = 0;
XtSetArg(args[i], XtNinsertPosition, &len); i++;
XtGetValues(view->output, args, i);
len = insertString(view->buffer, len, view->maxlen, src, srclen);
XtTextSetLastPos(view->output, len + srclen);
XtTextSetInsertionPoint(view->output, len + srclen + 1);
}
else if (view->type == ttyWidgetClass) { /* much easier */
XtTtyPutString(view->output, src);
}
else {
puke("%p: Don't know how to deal with view type '%x'\n",
view->type);
}
#ifdef SYSV
resumeProcessHandling();
#endif
Leave_void;
}
/*
* Sets the cursor of a view to something (where "something" is a glyph #
* from the cursor font). Useful for letting the user know when a view
* is doing something special (like chewing on lots of output). If change_top
* is TRUE, change the toplevel cursor as well (indicating that the view is
* something that affects the state of the entire application).
*/
void viewChangeCursor(vw, new, change_top)
View *vw;
Cursor new;
Boolean change_top;
{
static Cursor original_cursor = 0, last_cursor = 0;
Cursor tmp, tmp2;
Widget victim;
Entry("viewChangeCursor");
#ifdef SYSV
suspendProcessHandling();
#endif
victim = vw->output;
/* Init default cursor */
if (!original_cursor) {
i = 0;
XtSetArg(args[i], XtNcursor, &original_cursor); i++;
XtGetValues(victim, args, i);
}
/*
* Changing the cursor to the same value twice is a NOOP.
*/
if (new == last_cursor) {
Leave_void;
}
else {
/*
* Our server has a bug that will cause the cursor to be munged
* unless it's undefined first. Shouldn't cause any harm on other
* servers.
*/
if (change_top)
XUndefineCursor(XtDisplay(Toplevel), XtWindow(Toplevel));
XUndefineCursor(XtDisplay(victim), XtWindow(victim));
last_cursor = new;
if (new)
tmp = tmp2 = new;
else { /* restore default */
tmp = original_cursor;
tmp2 = app_resources.cursors.dbg;
}
}
XDefineCursor(XtDisplay(victim), XtWindow(victim), tmp);
if (change_top)
XDefineCursor(XtDisplay(Toplevel), XtWindow(Toplevel), tmp2);
XSync(XtDisplay(victim), 0);
#ifdef SYSV
resumeProcessHandling();
#endif
Leave_void;
}
/*
* Do anything special to mark/record the position of a prompt
* in a view.
*/
void viewMarkPrompt(proc)
Process *proc;
{
Entry("viewMarkPrompt");
/*
* for now, we just assume that the caller is the debugger process and
* it wants the position of its prompt marked. This may changed.
*/
if (proc->view->type != ttyWidgetClass) {
puke("%p: Currently only works for the debugger's output view");
Leave_void;
}
XtTtyPrompt(proc->view->output);
Leave_void;
}
/*
* Update all views.
*/
void updateAllViews()
{
Entry("updateAllViews");
assemblyUpdateView();
autoExecUpdateView();
sourceUpdateView();
stackUpdateView();
breakUpdateView();
statusUpdateView();
Leave_void;
}