X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fxio.c;h=126da025166b1ba5de6ca7c9ea4a89f12f3814e7;hp=9c5e03cf3221099515bbaaa3f03c0f24f813e29e;hb=f21d3481583b5cf877fc7b6efd6f2e08a1ade4b9;hpb=34935ff4685463b7aca1a32bd70561cdcc2f8829 diff --git a/src/xio.c b/src/xio.c index 9c5e03c..126da02 100644 --- a/src/xio.c +++ b/src/xio.c @@ -8,14 +8,38 @@ #include #include "sst.h" +#undef length /* ugh -- must get rid of ugly #defines */ + static XtAppContext app_context; static Widget toplevel, text, form; -static Widget navigation, weapons, status, planets, misc; +static Widget navigation, weapons, planets, misc; +static Widget navlabel, weaplabel, planlabel, misclabel; static String fallback[] = { - /* text window resources */ "*text.resizable: true", "*text.resize: ResizeBoth", + "*text.width: 640", + "*text.height: 200", + "*text.autoFill: True", + "*text.scrollVertical: Always", + "*text.scrollHorizontal: WhenNeeded", + "*text.displayCaret: True", + "*navigation.fromVert: text", + "*navigation.borderWidth: 0", + "*navlabel.label: Navigation: ", + "*navlabel.borderWidth: 0", + "*weapons.fromVert: navigation", + "*weapons.borderWidth: 0", + "*weaplabel.label: Weapons: ", + "*weaplabel.borderWidth: 0", + "*planets.fromVert: weapons", + "*planets.borderWidth: 0", + "*planlabel.label: Planets: ", + "*planlabel.borderWidth: 0", + "*misc.fromVert: planets", + "*misc.borderWidth: 0", + "*misclabel.label: Miscellaneous:", + "*misclabel.borderWidth: 0", NULL, }; @@ -34,10 +58,26 @@ static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data) exit (0); } +static void text_append_to(Widget w, String str) +/* append text to a specified text widget */ +{ + XawTextBlock txtblk; + XawTextPosition textend = XawTextGetInsertionPoint(w); + + txtblk.ptr = str; + txtblk.length = strlen(str); + txtblk.firstPos = 0; + txtblk.format = FMT8BIT; + + XawTextReplace(w, textend, textend, &txtblk); +} + static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data) /* use this for commands that take no arguments */ { /* currently a stub */ + text_append_to(w, XtName(w)); + printf("Button %s pressed\n", XtName(w)); } static struct cmd_t commands[] = { @@ -58,10 +98,6 @@ static struct cmd_t commands[] = { {"Deathray", noargs_proc, &weapons, 0}, {"Mayday", noargs_proc, &weapons, 0}, - {"Score", noargs_proc, &status, 0}, - {"Report", noargs_proc, &status, 0}, - {"Computer", noargs_proc, &status, 0}, - {"Sensors", noargs_proc, &planets, OPTION_PLANETS}, {"Orbit", noargs_proc, &planets, OPTION_PLANETS}, {"Transport", noargs_proc, &planets, OPTION_PLANETS}, @@ -70,13 +106,15 @@ static struct cmd_t commands[] = { {"Shuttle", noargs_proc, &planets, OPTION_PLANETS}, {"Planets", noargs_proc, &planets, OPTION_PLANETS}, - {"Emexit", noargs_proc, &misc, 0}, + {"Score", noargs_proc, &misc, 0}, + {"Report", noargs_proc, &misc, 0}, + {"Computer", noargs_proc, &misc, 0}, {"Save", NULL, &misc, 0}, {"Quit", quit_proc, &misc, 0}, {"Help", noargs_proc, &misc, 0}, }; -int main(int argc, char **argv) +static void instantiate_main(int argc, char **argv) { struct cmd_t *cp; @@ -86,36 +124,40 @@ int main(int argc, char **argv) XtNallowShellResize, True, NULL); form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL); /* the command window */ - text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, form, - XtNwidth, 400, XtNheight, 200, + text = XtVaCreateManagedWidget("text", + asciiTextWidgetClass, form, + XtNeditType, XawtextEdit, NULL); - XtVaSetValues(text, XtNeditType,XawtextRead, XtNdisplayCaret,False, NULL); /* The button panels */ navigation = XtVaCreateManagedWidget("navigation", - boxWidgetClass, form, - XtNfromVert, text, - XtNorientation, XtorientHorizontal, - NULL); + boxWidgetClass, form, + XtNorientation, XtorientHorizontal, + NULL); + navlabel = XtVaCreateManagedWidget("navlabel", + labelWidgetClass, navigation, + NULL); weapons = XtVaCreateManagedWidget("weapons", boxWidgetClass, form, - XtNfromVert, navigation, - XtNorientation, XtorientHorizontal, - NULL); - status = XtVaCreateManagedWidget("status", - boxWidgetClass, form, - XtNfromVert, weapons, XtNorientation, XtorientHorizontal, NULL); + weaplabel = XtVaCreateManagedWidget("weaplabel", + labelWidgetClass, weapons, + NULL); planets = XtVaCreateManagedWidget("planets", boxWidgetClass, form, - XtNfromVert, status, XtNorientation, XtorientHorizontal, NULL); + planlabel = XtVaCreateManagedWidget("planlabel", + labelWidgetClass, planets, + XtNborderWidth, 0, + NULL); misc = XtVaCreateManagedWidget("misc", boxWidgetClass, form, - XtNfromVert, planets, XtNorientation, XtorientHorizontal, NULL); + misclabel = XtVaCreateManagedWidget("misclabel", + labelWidgetClass, misc, + NULL); for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) { cp->widget = XtVaCreateManagedWidget(cp->name, commandWidgetClass, @@ -129,5 +171,10 @@ int main(int argc, char **argv) XtAppMainLoop(app_context); /* loop may be interrupted */ XtDestroyApplicationContext(app_context); +} + +int main(int argc, char **argv) +{ + instantiate_main(argc, argv); exit(0); }