Reformat all C files.
I'll push a formatting guide at some point. There may still be outstanding changes, but please feel free to resolve those as you arrive a them. To the best of my knowledge, there is no changes to the actual code content, but the formatter does have the occasional bug. If you run into an issue, please fix it!
This commit is contained in:
+107
-99
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 Window.c $NHDT-Date: 1430899134 2015/05/06 07:58:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
|
||||
/* NetHack 3.6 Window.c $NHDT-Date: 1431192774 2015/05/09 17:32:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 Window.c $Date: 2009/05/06 10:55:43 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)Window.c 3.5 1993/02/02 */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
|
||||
#ifndef SYSV
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#endif
|
||||
|
||||
#ifdef MSDOS /* from compiler */
|
||||
#ifdef MSDOS /* from compiler */
|
||||
#define SHORT_FILENAMES
|
||||
#endif
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
# ifdef SYSV
|
||||
# undef SYSV
|
||||
# endif
|
||||
# undef PRESERVE_NO_SYSV
|
||||
#ifdef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "xwindowp.h"
|
||||
@@ -40,60 +40,63 @@ static XtResource resources[] = {
|
||||
#define offset(field) XtOffset(WindowWidget, window.field)
|
||||
/* {name, class, type, size, offset, default_type, default_addr}, */
|
||||
{ nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension),
|
||||
offset(rows), XtRImmediate, (XtPointer) 21},
|
||||
offset(rows), XtRImmediate, (XtPointer) 21 },
|
||||
{ nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension),
|
||||
offset(columns), XtRImmediate, (XtPointer) 80},
|
||||
offset(columns), XtRImmediate, (XtPointer) 80 },
|
||||
{ nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel),
|
||||
offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
|
||||
offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
|
||||
|
||||
{ nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(black), XtRString, (XtPointer) "black"},
|
||||
{ nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(red), XtRString, (XtPointer) "red" },
|
||||
{ nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(green), XtRString, (XtPointer) "pale green" },
|
||||
{ nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(brown), XtRString, (XtPointer) "brown" },
|
||||
{ nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(blue), XtRString, (XtPointer) "blue" },
|
||||
{ nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(magenta), XtRString, (XtPointer) "magenta" },
|
||||
{ nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(cyan), XtRString, (XtPointer) "light cyan" },
|
||||
{ nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(gray), XtRString, (XtPointer) "gray" },
|
||||
{ nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(orange), XtRString, (XtPointer) "orange" },
|
||||
{ nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), offset(black),
|
||||
XtRString, (XtPointer) "black" },
|
||||
{ nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), offset(red),
|
||||
XtRString, (XtPointer) "red" },
|
||||
{ nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), offset(green),
|
||||
XtRString, (XtPointer) "pale green" },
|
||||
{ nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), offset(brown),
|
||||
XtRString, (XtPointer) "brown" },
|
||||
{ nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), offset(blue),
|
||||
XtRString, (XtPointer) "blue" },
|
||||
{ nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), offset(magenta),
|
||||
XtRString, (XtPointer) "magenta" },
|
||||
{ nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), offset(cyan),
|
||||
XtRString, (XtPointer) "light cyan" },
|
||||
{ nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), offset(gray),
|
||||
XtRString, (XtPointer) "gray" },
|
||||
{ nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), offset(orange),
|
||||
XtRString, (XtPointer) "orange" },
|
||||
{ nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(bright_green), XtRString, (XtPointer) "green" },
|
||||
{ nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(yellow), XtRString, (XtPointer) "yellow" },
|
||||
offset(bright_green), XtRString, (XtPointer) "green" },
|
||||
{ nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), offset(yellow),
|
||||
XtRString, (XtPointer) "yellow" },
|
||||
{ nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(bright_blue), XtRString, (XtPointer) "royal blue" },
|
||||
offset(bright_blue), XtRString, (XtPointer) "royal blue" },
|
||||
{ nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(bright_magenta), XtRString, (XtPointer) "violet" },
|
||||
offset(bright_magenta), XtRString, (XtPointer) "violet" },
|
||||
{ nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(bright_cyan), XtRString, (XtPointer) "cyan" },
|
||||
{ nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel),
|
||||
offset(white), XtRString, (XtPointer) "white" },
|
||||
offset(bright_cyan), XtRString, (XtPointer) "cyan" },
|
||||
{ nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), offset(white),
|
||||
XtRString, (XtPointer) "white" },
|
||||
|
||||
{ nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
|
||||
offset(font), XtRString, (XtPointer) XtDefaultFont },
|
||||
{ nhStr(XtNexposeCallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
|
||||
offset(expose_callback), XtRCallback, (char *)0 },
|
||||
offset(font), XtRString, (XtPointer) XtDefaultFont },
|
||||
{ nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
|
||||
sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
|
||||
(char *) 0 },
|
||||
{ nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
|
||||
offset(input_callback), XtRCallback, (char *)0 },
|
||||
{ nhStr(XtNresizeCallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
|
||||
offset(resize_callback), XtRCallback, (char *)0 },
|
||||
offset(input_callback), XtRCallback, (char *) 0 },
|
||||
{ nhStr(XtNresizeCallback), XtCCallback, XtRCallback,
|
||||
sizeof(XtCallbackList), offset(resize_callback), XtRCallback,
|
||||
(char *) 0 },
|
||||
#undef offset
|
||||
};
|
||||
|
||||
/* ARGSUSED */
|
||||
static void no_op(w, event, params, num_params)
|
||||
Widget w; /* unused */
|
||||
XEvent *event; /* unused */
|
||||
String *params; /* unused */
|
||||
Cardinal *num_params; /* unused */
|
||||
static void
|
||||
no_op(w, event, params, num_params)
|
||||
Widget w; /* unused */
|
||||
XEvent *event; /* unused */
|
||||
String *params; /* unused */
|
||||
Cardinal *num_params; /* unused */
|
||||
{
|
||||
nhUse(w);
|
||||
nhUse(event);
|
||||
@@ -103,20 +106,19 @@ static void no_op(w, event, params, num_params)
|
||||
return;
|
||||
}
|
||||
|
||||
static XtActionsRec actions[] =
|
||||
{
|
||||
{ nhStr("no-op"), no_op },
|
||||
static XtActionsRec actions[] = {
|
||||
{ nhStr("no-op"), no_op },
|
||||
};
|
||||
|
||||
static char translations[] =
|
||||
"<BtnDown>: input() \
|
||||
static char translations[] = "<BtnDown>: input() \
|
||||
";
|
||||
|
||||
/* ARGSUSED */
|
||||
static void Redisplay(w, event, region)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
Region region; /* unused */
|
||||
static void
|
||||
Redisplay(w, event, region)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
Region region; /* unused */
|
||||
{
|
||||
nhUse(region);
|
||||
|
||||
@@ -125,57 +127,63 @@ static void Redisplay(w, event, region)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static void Resize(w)
|
||||
Widget w;
|
||||
static void
|
||||
Resize(w)
|
||||
Widget w;
|
||||
{
|
||||
XtCallCallbacks(w, XtNresizeCallback, (caddr_t) 0);
|
||||
}
|
||||
|
||||
|
||||
WindowClassRec windowClassRec = {
|
||||
{ /* core fields */
|
||||
/* superclass */ (WidgetClass) &widgetClassRec,
|
||||
/* class_name */ nhStr("Window"),
|
||||
/* widget_size */ sizeof(WindowRec),
|
||||
/* class_initialize */ 0,
|
||||
/* class_part_initialize */ 0,
|
||||
/* class_inited */ FALSE,
|
||||
/* initialize */ 0,
|
||||
/* initialize_hook */ 0,
|
||||
/* realize */ XtInheritRealize,
|
||||
/* actions */ actions,
|
||||
/* num_actions */ XtNumber(actions),
|
||||
/* resources */ resources,
|
||||
/* num_resources */ XtNumber(resources),
|
||||
/* xrm_class */ NULLQUARK,
|
||||
/* compress_motion */ TRUE,
|
||||
/* compress_exposure */ TRUE,
|
||||
/* compress_enterleave */ TRUE,
|
||||
/* visible_interest */ FALSE,
|
||||
/* destroy */ 0,
|
||||
/* resize */ Resize,
|
||||
/* expose */ Redisplay,
|
||||
/* set_values */ 0,
|
||||
/* set_values_hook */ 0,
|
||||
/* set_values_almost */ XtInheritSetValuesAlmost,
|
||||
/* get_values_hook */ 0,
|
||||
/* accept_focus */ 0,
|
||||
/* version */ XtVersion,
|
||||
/* callback_private */ 0,
|
||||
/* tm_table */ translations,
|
||||
/* query_geometry */ XtInheritQueryGeometry,
|
||||
/* display_accelerator */ XtInheritDisplayAccelerator,
|
||||
/* extension */ 0
|
||||
},
|
||||
{ /* window fields */
|
||||
/* empty */ 0
|
||||
}
|
||||
{ /* core fields */
|
||||
/* superclass */ (WidgetClass) &widgetClassRec,
|
||||
/* class_name */ nhStr("Window"),
|
||||
/* widget_size */ sizeof(WindowRec),
|
||||
/* class_initialize */ 0,
|
||||
/* class_part_initialize */ 0,
|
||||
/* class_inited */ FALSE,
|
||||
/* initialize */ 0,
|
||||
/* initialize_hook */ 0,
|
||||
/* realize */ XtInheritRealize,
|
||||
/* actions */ actions,
|
||||
/* num_actions */ XtNumber(actions),
|
||||
/* resources */ resources,
|
||||
/* num_resources */ XtNumber(resources),
|
||||
/* xrm_class */ NULLQUARK,
|
||||
/* compress_motion */ TRUE,
|
||||
/* compress_exposure */ TRUE,
|
||||
/* compress_enterleave */ TRUE,
|
||||
/* visible_interest */ FALSE,
|
||||
/* destroy */ 0,
|
||||
/* resize */ Resize,
|
||||
/* expose */ Redisplay,
|
||||
/* set_values */ 0,
|
||||
/* set_values_hook */ 0,
|
||||
/* set_values_almost */ XtInheritSetValuesAlmost,
|
||||
/* get_values_hook */ 0,
|
||||
/* accept_focus */ 0,
|
||||
/* version */ XtVersion,
|
||||
/* callback_private */ 0,
|
||||
/* tm_table */ translations,
|
||||
/* query_geometry */ XtInheritQueryGeometry,
|
||||
/* display_accelerator */ XtInheritDisplayAccelerator,
|
||||
/* extension */ 0 },
|
||||
{ /* window fields */
|
||||
/* empty */ 0 }
|
||||
};
|
||||
|
||||
WidgetClass windowWidgetClass = (WidgetClass)&windowClassRec;
|
||||
WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
|
||||
|
||||
Font
|
||||
WindowFont(w) Widget w; { return ((WindowWidget)w)->window.font->fid; }
|
||||
WindowFont(w)
|
||||
Widget w;
|
||||
{
|
||||
return ((WindowWidget) w)->window.font->fid;
|
||||
}
|
||||
|
||||
XFontStruct *
|
||||
WindowFontStruct(w) Widget w; { return ((WindowWidget)w)->window.font; }
|
||||
WindowFontStruct(w)
|
||||
Widget w;
|
||||
{
|
||||
return ((WindowWidget) w)->window.font;
|
||||
}
|
||||
|
||||
+154
-107
@@ -14,7 +14,8 @@
|
||||
*
|
||||
* THE UNIVERSITY OF WISCONSIN-MADISON DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN-MADISON BE LIABLE FOR
|
||||
* FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN-MADISON BE LIABLE
|
||||
*FOR
|
||||
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
@@ -48,12 +49,12 @@
|
||||
* target type" issued by 'gcc -Wwrite-strings' as used by nethack.
|
||||
* (For this file, always the second parameter to XtSetArg().)
|
||||
*
|
||||
* $NHDT-Date: 1430899133 2015/05/06 07:58:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.3 $
|
||||
* $NHDT-Date: 1431192774 2015/05/09 17:32:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $
|
||||
* $Date: 2002/03/31 17:11:23 $ $Revision: 1.2 $
|
||||
*/
|
||||
|
||||
#ifndef SYSV
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
@@ -66,26 +67,23 @@
|
||||
#include <X11/Xaw/Command.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
# ifdef SYSV
|
||||
# undef SYSV
|
||||
# endif
|
||||
# undef PRESERVE_NO_SYSV
|
||||
#ifdef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "config.h" /* #define for const for non __STDC__ compilers */
|
||||
#include "lint.h" /* for nethack's nhStr() macro */
|
||||
#include "config.h" /* #define for const for non __STDC__ compilers */
|
||||
#include "lint.h" /* for nethack's nhStr() macro */
|
||||
|
||||
/* ":" added to both translations below to allow limited redefining of
|
||||
* keysyms before testing for keysym values -- dlc */
|
||||
static const char okay_accelerators[] =
|
||||
"#override\n\
|
||||
static const char okay_accelerators[] = "#override\n\
|
||||
:<Key>Return: set() notify() unset()\n";
|
||||
|
||||
static const char cancel_accelerators[] =
|
||||
"#override\n\
|
||||
static const char cancel_accelerators[] = "#override\n\
|
||||
:<Key>Escape: set() notify() unset()\n\
|
||||
:<Ctrl>[: set() notify() unset()\n"; /* for keyboards w/o an ESC */
|
||||
|
||||
:<Ctrl>[: set() notify() unset()\n"; /* for keyboards w/o an ESC */
|
||||
|
||||
/* Create a dialog widget. It is just a form widget with
|
||||
* a label prompt
|
||||
@@ -95,99 +93,139 @@ static const char cancel_accelerators[] =
|
||||
*/
|
||||
Widget
|
||||
CreateDialog(parent, name, okay_callback, cancel_callback)
|
||||
Widget parent;
|
||||
String name;
|
||||
XtCallbackProc okay_callback;
|
||||
XtCallbackProc cancel_callback;
|
||||
Widget parent;
|
||||
String name;
|
||||
XtCallbackProc okay_callback;
|
||||
XtCallbackProc cancel_callback;
|
||||
{
|
||||
Widget form, prompt, response, okay, cancel;
|
||||
Arg args[20];
|
||||
Cardinal num_args;
|
||||
|
||||
num_args = 0;
|
||||
num_args = 0;
|
||||
#ifdef SPECIAL_CMAP
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
form = XtCreateManagedWidget(name, formWidgetClass, parent, args, num_args);
|
||||
form =
|
||||
XtCreateManagedWidget(name, formWidgetClass, parent, args, num_args);
|
||||
|
||||
num_args = 0;
|
||||
num_args = 0;
|
||||
#ifdef SPECIAL_CMAP
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), 0); num_args++;
|
||||
prompt = XtCreateManagedWidget("prompt", labelWidgetClass,
|
||||
form, args, num_args);
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), 0);
|
||||
num_args++;
|
||||
prompt = XtCreateManagedWidget("prompt", labelWidgetClass, form, args,
|
||||
num_args);
|
||||
|
||||
num_args = 0;
|
||||
num_args = 0;
|
||||
#ifdef SPECIAL_CMAP
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), prompt); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNeditType), XawtextEdit); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNstring), ""); num_args++;
|
||||
response = XtCreateManagedWidget("response", asciiTextWidgetClass,
|
||||
form, args, num_args);
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), prompt);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNeditType), XawtextEdit);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNstring), "");
|
||||
num_args++;
|
||||
response = XtCreateManagedWidget("response", asciiTextWidgetClass, form,
|
||||
args, num_args);
|
||||
|
||||
num_args = 0;
|
||||
num_args = 0;
|
||||
#ifdef SPECIAL_CMAP
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), response); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), response);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNaccelerators),
|
||||
XtParseAcceleratorTable(okay_accelerators)); num_args++;
|
||||
okay = XtCreateManagedWidget("okay", commandWidgetClass,
|
||||
form, args, num_args);
|
||||
XtParseAcceleratorTable(okay_accelerators));
|
||||
num_args++;
|
||||
okay = XtCreateManagedWidget("okay", commandWidgetClass, form, args,
|
||||
num_args);
|
||||
XtAddCallback(okay, XtNcallback, okay_callback, form);
|
||||
|
||||
/* Only create cancel button if there is a callback for it. */
|
||||
if (cancel_callback) {
|
||||
num_args = 0;
|
||||
num_args = 0;
|
||||
#ifdef SPECIAL_CMAP
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++;
|
||||
}
|
||||
if (special_cmap) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), black);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), white);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), response); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), okay); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNaccelerators),
|
||||
XtParseAcceleratorTable(cancel_accelerators)); num_args++;
|
||||
cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
|
||||
form, args, num_args);
|
||||
XtAddCallback(cancel, XtNcallback, cancel_callback, form);
|
||||
XtInstallAccelerators(response, cancel);
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), response);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), okay);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNresizable), True);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNaccelerators),
|
||||
XtParseAcceleratorTable(cancel_accelerators));
|
||||
num_args++;
|
||||
cancel = XtCreateManagedWidget("cancel", commandWidgetClass, form,
|
||||
args, num_args);
|
||||
XtAddCallback(cancel, XtNcallback, cancel_callback, form);
|
||||
XtInstallAccelerators(response, cancel);
|
||||
}
|
||||
|
||||
XtInstallAccelerators(response, okay);
|
||||
@@ -217,8 +255,8 @@ GetDialogPrompt(w)
|
||||
/* set the prompt. This is used to put error information in the prompt */
|
||||
void
|
||||
SetDialogPrompt(w, newprompt)
|
||||
Widget w;
|
||||
String newprompt;
|
||||
Widget w;
|
||||
String newprompt;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget label;
|
||||
@@ -231,7 +269,7 @@ SetDialogPrompt(w, newprompt)
|
||||
/* get what the user typed; caller must free the response */
|
||||
String
|
||||
GetDialogResponse(w)
|
||||
Widget w;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget response;
|
||||
@@ -243,12 +281,12 @@ GetDialogResponse(w)
|
||||
return XtNewString(s);
|
||||
}
|
||||
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
/* set the default reponse */
|
||||
void
|
||||
SetDialogResponse(w, s)
|
||||
Widget w;
|
||||
String s;
|
||||
Widget w;
|
||||
String s;
|
||||
{
|
||||
Arg args[4];
|
||||
Widget response;
|
||||
@@ -262,9 +300,9 @@ SetDialogResponse(w, s)
|
||||
XtSetArg(args[3], nhStr(XtNwidth), &width);
|
||||
XtGetValues(response, args, FOUR);
|
||||
/* width includes margins as per Xaw documentation */
|
||||
nwidth = (font->max_bounds.width * strlen(s))+leftMargin+rightMargin;
|
||||
nwidth = (font->max_bounds.width * strlen(s)) + leftMargin + rightMargin;
|
||||
if (nwidth < width)
|
||||
nwidth = width;
|
||||
nwidth = width;
|
||||
|
||||
XtSetArg(args[0], nhStr(XtNstring), s);
|
||||
XtSetArg(args[1], nhStr(XtNwidth), nwidth);
|
||||
@@ -288,14 +326,14 @@ ClearDialogResponse(w)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Not a part of the original dialogs.c from ghostview --------------------- */
|
||||
/* Not a part of the original dialogs.c from ghostview ---------------------
|
||||
*/
|
||||
|
||||
/* position popup window under the cursor */
|
||||
void
|
||||
positionpopup(w, bottom)
|
||||
Widget w;
|
||||
boolean bottom; /* position y on bottom? */
|
||||
Widget w;
|
||||
boolean bottom; /* position y on bottom? */
|
||||
{
|
||||
Arg args[3];
|
||||
Cardinal num_args;
|
||||
@@ -310,38 +348,47 @@ positionpopup(w, bottom)
|
||||
/* following line deals with a race condition w/brain-damaged WM's -dlc */
|
||||
XtUnrealizeWidget(w);
|
||||
|
||||
XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel), &root, &child,
|
||||
&x, &y, &dummyx, &dummyy, &dummymask);
|
||||
XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel), &root, &child, &x,
|
||||
&y, &dummyx, &dummyy, &dummymask);
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNwidth, &width); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, &height); num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, &width);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, &height);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, &b_width);
|
||||
num_args++;
|
||||
XtGetValues(w, args, num_args);
|
||||
|
||||
/* position so that the cursor is center,center or center,bottom */
|
||||
width += 2 * b_width;
|
||||
x -= ( (Position) width/2 );
|
||||
if (x < 0) x = 0;
|
||||
if ( x > (max_x = (Position) (XtScreen(w)->width - width)) ) x = max_x;
|
||||
x -= ((Position) width / 2);
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
if (x > (max_x = (Position)(XtScreen(w)->width - width)))
|
||||
x = max_x;
|
||||
|
||||
if (bottom) {
|
||||
y -= (height+b_width-1);
|
||||
height += 2 * b_width;
|
||||
y -= (height + b_width - 1);
|
||||
height += 2 * b_width;
|
||||
} else {
|
||||
height += 2 * b_width;
|
||||
y -= ( (Position) height/2 );
|
||||
height += 2 * b_width;
|
||||
y -= ((Position) height / 2);
|
||||
}
|
||||
if (y < 0) y = 0;
|
||||
if ( y > (max_y = (Position) (XtScreen(w)->height - height)) ) y = max_y;
|
||||
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
if (y > (max_y = (Position)(XtScreen(w)->height - height)))
|
||||
y = max_y;
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNx, x); num_args++;
|
||||
XtSetArg(args[num_args], XtNy, y); num_args++;
|
||||
XtSetArg(args[num_args], XtNx, x);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNy, y);
|
||||
num_args++;
|
||||
XtSetValues(w, args, num_args);
|
||||
|
||||
/* Some older window managers ignore XtN{x,y}; hint the same values */
|
||||
/* The {x,y} are not used by newer window managers; older ones need them */
|
||||
/* The {x,y} are not used by newer window managers; older ones need them
|
||||
*/
|
||||
XtRealizeWidget(w);
|
||||
hints = XAllocSizeHints();
|
||||
hints->flags = USPosition;
|
||||
|
||||
+98
-107
@@ -1,4 +1,4 @@
|
||||
/* $NHDT-Date: 1430640199 2015/05/03 08:03:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.3 $ */
|
||||
/* $NHDT-Date: 1431192774 2015/05/09 17:32:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
|
||||
/* $Date: 2002/03/17 20:02:47 $ $Revision: 1.2 $ */
|
||||
|
||||
/*
|
||||
@@ -9,47 +9,44 @@
|
||||
* + Two dimensional byte arrays are in row order and are not padded
|
||||
* between rows (x11_colormap[][]).
|
||||
*/
|
||||
#include "hack.h" /* for MAX_GLYPH */
|
||||
#include "hack.h" /* for MAX_GLYPH */
|
||||
#include "tile.h"
|
||||
#include "tile2x11.h" /* x11 output file header structure */
|
||||
#include "tile2x11.h" /* x11 output file header structure */
|
||||
|
||||
#define OUTNAME "x11tiles" /* output file name */
|
||||
/* #define PRINT_COLORMAP */ /* define to print the colormap */
|
||||
|
||||
|
||||
x11_header header;
|
||||
unsigned char tile_bytes[TILE_X*TILE_Y*(MAX_GLYPH+TILES_PER_ROW)];
|
||||
unsigned char *curr_tb = tile_bytes;
|
||||
unsigned char x11_colormap[MAXCOLORMAPSIZE][3];
|
||||
#define OUTNAME "x11tiles" /* output file name */
|
||||
/* #define PRINT_COLORMAP */ /* define to print the colormap */
|
||||
|
||||
x11_header header;
|
||||
unsigned char tile_bytes[TILE_X * TILE_Y * (MAX_GLYPH + TILES_PER_ROW)];
|
||||
unsigned char *curr_tb = tile_bytes;
|
||||
unsigned char x11_colormap[MAXCOLORMAPSIZE][3];
|
||||
|
||||
/* Look up the given pixel and return its colormap index. */
|
||||
static unsigned char
|
||||
pix_to_colormap(pix)
|
||||
pixel pix;
|
||||
pixel pix;
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < header.ncolors; i++) {
|
||||
if (pix.r == ColorMap[CM_RED][i] &&
|
||||
pix.g == ColorMap[CM_GREEN][i] &&
|
||||
pix.b == ColorMap[CM_BLUE][i])
|
||||
break;
|
||||
if (pix.r == ColorMap[CM_RED][i] && pix.g == ColorMap[CM_GREEN][i]
|
||||
&& pix.b == ColorMap[CM_BLUE][i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == header.ncolors) {
|
||||
Fprintf(stderr, "can't find color: [%u,%u,%u]\n", pix.r, pix.g, pix.b);
|
||||
exit(1);
|
||||
Fprintf(stderr, "can't find color: [%u,%u,%u]\n", pix.r, pix.g,
|
||||
pix.b);
|
||||
exit(1);
|
||||
}
|
||||
return (unsigned char) (i & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
/* Convert the tiles in the file to our format of bytes. */
|
||||
static unsigned long
|
||||
convert_tiles(tb_ptr, total)
|
||||
unsigned char **tb_ptr; /* pointer to a tile byte pointer */
|
||||
unsigned long total; /* total tiles so far */
|
||||
unsigned char **tb_ptr; /* pointer to a tile byte pointer */
|
||||
unsigned long total; /* total tiles so far */
|
||||
{
|
||||
unsigned char *tb = *tb_ptr;
|
||||
unsigned long count = 0;
|
||||
@@ -57,69 +54,67 @@ convert_tiles(tb_ptr, total)
|
||||
int x, y;
|
||||
|
||||
while (read_text_tile(tile)) {
|
||||
count++;
|
||||
total++;
|
||||
for (y = 0; y < TILE_Y; y++) {
|
||||
for (x = 0; x < TILE_X; x++)
|
||||
tb[x] = pix_to_colormap(tile[y][x]);
|
||||
tb += TILE_X * header.per_row;
|
||||
}
|
||||
count++;
|
||||
total++;
|
||||
for (y = 0; y < TILE_Y; y++) {
|
||||
for (x = 0; x < TILE_X; x++)
|
||||
tb[x] = pix_to_colormap(tile[y][x]);
|
||||
tb += TILE_X * header.per_row;
|
||||
}
|
||||
|
||||
/* repoint at the upper-left corner of the next tile */
|
||||
*tb_ptr += TILE_X;
|
||||
if (header.per_row == 1 || (total % header.per_row) == 0)
|
||||
*tb_ptr += TILE_X * (TILE_Y - 1) * header.per_row;
|
||||
tb = *tb_ptr;
|
||||
/* repoint at the upper-left corner of the next tile */
|
||||
*tb_ptr += TILE_X;
|
||||
if (header.per_row == 1 || (total % header.per_row) == 0)
|
||||
*tb_ptr += TILE_X * (TILE_Y - 1) * header.per_row;
|
||||
tb = *tb_ptr;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Merge the current text colormap (ColorMap) with ours (x11_colormap). */
|
||||
static void
|
||||
merge_text_colormap()
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < (unsigned)colorsinmap; i++) {
|
||||
for (j = 0; j < header.ncolors; j++)
|
||||
if (x11_colormap[j][CM_RED] == ColorMap[CM_RED][i] &&
|
||||
x11_colormap[j][CM_GREEN] == ColorMap[CM_GREEN][i] &&
|
||||
x11_colormap[j][CM_BLUE] == ColorMap[CM_BLUE][i])
|
||||
break;
|
||||
for (i = 0; i < (unsigned) colorsinmap; i++) {
|
||||
for (j = 0; j < header.ncolors; j++)
|
||||
if (x11_colormap[j][CM_RED] == ColorMap[CM_RED][i]
|
||||
&& x11_colormap[j][CM_GREEN] == ColorMap[CM_GREEN][i]
|
||||
&& x11_colormap[j][CM_BLUE] == ColorMap[CM_BLUE][i])
|
||||
break;
|
||||
|
||||
if (j >= MAXCOLORMAPSIZE) {
|
||||
Fprintf(stderr, "colormap overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
if (j >= MAXCOLORMAPSIZE) {
|
||||
Fprintf(stderr, "colormap overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (j == header.ncolors) { /* couldn't find it */
|
||||
if (j == header.ncolors) { /* couldn't find it */
|
||||
#ifdef PRINT_COLORMAP
|
||||
printf("color %2d: %3d %3d %3d\n", header.ncolors,
|
||||
ColorMap[CM_RED][i], ColorMap[CM_GREEN][i],
|
||||
ColorMap[CM_BLUE][i]);
|
||||
printf("color %2d: %3d %3d %3d\n", header.ncolors,
|
||||
ColorMap[CM_RED][i], ColorMap[CM_GREEN][i],
|
||||
ColorMap[CM_BLUE][i]);
|
||||
#endif
|
||||
|
||||
x11_colormap[j][CM_RED] = ColorMap[CM_RED][i];
|
||||
x11_colormap[j][CM_GREEN] = ColorMap[CM_GREEN][i];
|
||||
x11_colormap[j][CM_BLUE] = ColorMap[CM_BLUE][i];
|
||||
header.ncolors++;
|
||||
}
|
||||
x11_colormap[j][CM_RED] = ColorMap[CM_RED][i];
|
||||
x11_colormap[j][CM_GREEN] = ColorMap[CM_GREEN][i];
|
||||
x11_colormap[j][CM_BLUE] = ColorMap[CM_BLUE][i];
|
||||
header.ncolors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Open the given file, read & merge the colormap, convert the tiles. */
|
||||
static void
|
||||
process_file(fname)
|
||||
char *fname;
|
||||
char *fname;
|
||||
{
|
||||
unsigned long count;
|
||||
|
||||
if (!fopen_text_file(fname, RDTMODE)) {
|
||||
Fprintf(stderr, "can't open file \"%s\"\n", fname);
|
||||
exit(1);
|
||||
Fprintf(stderr, "can't open file \"%s\"\n", fname);
|
||||
exit(1);
|
||||
}
|
||||
merge_text_colormap();
|
||||
count = convert_tiles(&curr_tb, header.ntiles);
|
||||
@@ -128,7 +123,6 @@ process_file(fname)
|
||||
fclose_text_file();
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_XPM
|
||||
static int
|
||||
xpm_write(fp)
|
||||
@@ -137,99 +131,96 @@ FILE *fp;
|
||||
int i, j, n;
|
||||
|
||||
if (header.ncolors > 64) {
|
||||
Fprintf(stderr, "Sorry, only configured for up to 64 colors\n");
|
||||
exit(1);
|
||||
/* All you need to do is add more char per color - below */
|
||||
Fprintf(stderr, "Sorry, only configured for up to 64 colors\n");
|
||||
exit(1);
|
||||
/* All you need to do is add more char per color - below */
|
||||
}
|
||||
|
||||
Fprintf(fp, "/* XPM */\n");
|
||||
Fprintf(fp, "static char* nhtiles[] = {\n");
|
||||
Fprintf(fp, "\"%lu %lu %lu %d\",\n",
|
||||
header.tile_width*header.per_row,
|
||||
(header.tile_height*header.ntiles)/header.per_row,
|
||||
header.ncolors,
|
||||
1 /* char per color */);
|
||||
Fprintf(fp, "\"%lu %lu %lu %d\",\n", header.tile_width * header.per_row,
|
||||
(header.tile_height * header.ntiles) / header.per_row,
|
||||
header.ncolors, 1 /* char per color */);
|
||||
for (i = 0; i < header.ncolors; i++)
|
||||
Fprintf(fp, "\"%c c #%02x%02x%02x\",\n",
|
||||
i+'0', /* just one char per color */
|
||||
x11_colormap[i][0],
|
||||
x11_colormap[i][1],
|
||||
x11_colormap[i][2]);
|
||||
Fprintf(fp, "\"%c c #%02x%02x%02x\",\n",
|
||||
i + '0', /* just one char per color */
|
||||
x11_colormap[i][0], x11_colormap[i][1], x11_colormap[i][2]);
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < (header.tile_height*header.ntiles)/header.per_row; i++) {
|
||||
Fprintf(fp, "\"");
|
||||
for (j = 0; j < header.tile_width*header.per_row; j++) {
|
||||
/* just one char per color */
|
||||
fputc(tile_bytes[n++]+'0', fp);
|
||||
}
|
||||
for (i = 0; i < (header.tile_height * header.ntiles) / header.per_row;
|
||||
i++) {
|
||||
Fprintf(fp, "\"");
|
||||
for (j = 0; j < header.tile_width * header.per_row; j++) {
|
||||
/* just one char per color */
|
||||
fputc(tile_bytes[n++] + '0', fp);
|
||||
}
|
||||
|
||||
Fprintf(fp, "\",\n");
|
||||
Fprintf(fp, "\",\n");
|
||||
}
|
||||
|
||||
return fprintf(fp, "};\n") >= 0;
|
||||
}
|
||||
#endif /* USE_XPM */
|
||||
#endif /* USE_XPM */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
header.version = 2; /* version 1 had no per_row field */
|
||||
header.ncolors = 0;
|
||||
header.tile_width = TILE_X;
|
||||
header.tile_height = TILE_Y;
|
||||
header.ntiles = 0; /* updated as we read in files */
|
||||
header.per_row = TILES_PER_ROW;
|
||||
header.version = 2; /* version 1 had no per_row field */
|
||||
header.ncolors = 0;
|
||||
header.tile_width = TILE_X;
|
||||
header.tile_height = TILE_Y;
|
||||
header.ntiles = 0; /* updated as we read in files */
|
||||
header.per_row = TILES_PER_ROW;
|
||||
|
||||
if (argc == 1) {
|
||||
Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...]\n", argv[0]);
|
||||
exit(1);
|
||||
Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fp = fopen(OUTNAME, "w");
|
||||
if (!fp) {
|
||||
Fprintf(stderr, "can't open output file\n");
|
||||
exit(1);
|
||||
Fprintf(stderr, "can't open output file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* don't leave garbage at end of partial row */
|
||||
(void) memset((genericptr_t)tile_bytes, 0, sizeof(tile_bytes));
|
||||
(void) memset((genericptr_t) tile_bytes, 0, sizeof(tile_bytes));
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
process_file(argv[i]);
|
||||
process_file(argv[i]);
|
||||
Fprintf(stderr, "Total tiles: %ld\n", header.ntiles);
|
||||
|
||||
/* round size up to the end of the row */
|
||||
if ((header.ntiles % header.per_row) != 0) {
|
||||
header.ntiles += header.per_row - (header.ntiles % header.per_row);
|
||||
header.ntiles += header.per_row - (header.ntiles % header.per_row);
|
||||
}
|
||||
|
||||
#ifdef USE_XPM
|
||||
if (xpm_write(fp) == 0) {
|
||||
Fprintf(stderr, "can't write XPM file\n");
|
||||
exit(1);
|
||||
Fprintf(stderr, "can't write XPM file\n");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
if (fwrite((char *)&header, sizeof(x11_header), 1, fp) == 0) {
|
||||
Fprintf(stderr, "can't open output header\n");
|
||||
exit(1);
|
||||
if (fwrite((char *) &header, sizeof(x11_header), 1, fp) == 0) {
|
||||
Fprintf(stderr, "can't open output header\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fwrite((char *)x11_colormap, 1, header.ncolors*3, fp) == 0) {
|
||||
Fprintf(stderr, "can't write output colormap\n");
|
||||
exit(1);
|
||||
if (fwrite((char *) x11_colormap, 1, header.ncolors * 3, fp) == 0) {
|
||||
Fprintf(stderr, "can't write output colormap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fwrite((char *)tile_bytes, 1,
|
||||
(int) header.ntiles*header.tile_width*header.tile_height, fp) == 0) {
|
||||
|
||||
Fprintf(stderr, "can't write tile bytes\n");
|
||||
exit(1);
|
||||
if (fwrite((char *) tile_bytes, 1,
|
||||
(int) header.ntiles * header.tile_width * header.tile_height,
|
||||
fp) == 0) {
|
||||
Fprintf(stderr, "can't write tile bytes\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1039
-994
File diff suppressed because it is too large
Load Diff
+827
-805
File diff suppressed because it is too large
Load Diff
+665
-593
File diff suppressed because it is too large
Load Diff
+242
-239
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 winmesg.c $NHDT-Date: 1430899136 2015/05/06 07:58:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
|
||||
/* NetHack 3.6 winmesg.c $NHDT-Date: 1431192773 2015/05/09 17:32:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 winmesg.c $Date: 2009/05/06 10:55:57 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)winmesg.c 3.5 1996/04/05 */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#ifndef SYSV
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
@@ -26,36 +26,35 @@
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
# ifdef SYSV
|
||||
# undef SYSV
|
||||
# endif
|
||||
# undef PRESERVE_NO_SYSV
|
||||
#ifdef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "xwindow.h" /* Window widget declarations */
|
||||
#include "xwindow.h" /* Window widget declarations */
|
||||
|
||||
#include "hack.h"
|
||||
#include "winX.h"
|
||||
|
||||
static struct line_element *FDECL(get_previous, (struct line_element *));
|
||||
static void FDECL(set_circle_buf, (struct mesg_info_t *,int));
|
||||
static char *FDECL(split, (char *,XFontStruct *,DIMENSION_P));
|
||||
static void FDECL(add_line, (struct mesg_info_t *,const char *));
|
||||
static void FDECL(set_circle_buf, (struct mesg_info_t *, int));
|
||||
static char *FDECL(split, (char *, XFontStruct *, DIMENSION_P));
|
||||
static void FDECL(add_line, (struct mesg_info_t *, const char *));
|
||||
static void FDECL(redraw_message_window, (struct xwindow *));
|
||||
static void FDECL(mesg_check_size_change, (struct xwindow *));
|
||||
static void FDECL(mesg_exposed, (Widget,XtPointer,XtPointer));
|
||||
static void FDECL(get_gc, (Widget,struct mesg_info_t *));
|
||||
static void FDECL(mesg_resized, (Widget,XtPointer,XtPointer));
|
||||
static void FDECL(mesg_exposed, (Widget, XtPointer, XtPointer));
|
||||
static void FDECL(get_gc, (Widget, struct mesg_info_t *));
|
||||
static void FDECL(mesg_resized, (Widget, XtPointer, XtPointer));
|
||||
|
||||
static char mesg_translations[] =
|
||||
"#override\n\
|
||||
static char mesg_translations[] = "#override\n\
|
||||
<Key>: input() \
|
||||
";
|
||||
|
||||
/* Move the message window's vertical scrollbar's slider to the bottom. */
|
||||
void
|
||||
set_message_slider(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
Widget scrollbar;
|
||||
float top;
|
||||
@@ -63,17 +62,16 @@ set_message_slider(wp)
|
||||
scrollbar = XtNameToWidget(XtParent(wp->w), "vertical");
|
||||
|
||||
if (scrollbar) {
|
||||
top = 1.0;
|
||||
XtCallCallbacks(scrollbar, XtNjumpProc, &top);
|
||||
top = 1.0;
|
||||
XtCallCallbacks(scrollbar, XtNjumpProc, &top);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
create_message_window(wp, create_popup, parent)
|
||||
struct xwindow *wp; /* window pointer */
|
||||
boolean create_popup;
|
||||
Widget parent;
|
||||
struct xwindow *wp; /* window pointer */
|
||||
boolean create_popup;
|
||||
Widget parent;
|
||||
{
|
||||
Arg args[8];
|
||||
Cardinal num_args;
|
||||
@@ -83,34 +81,35 @@ create_message_window(wp, create_popup, parent)
|
||||
wp->type = NHW_MESSAGE;
|
||||
|
||||
wp->mesg_information = mesg_info =
|
||||
(struct mesg_info_t *) alloc(sizeof(struct mesg_info_t));
|
||||
(struct mesg_info_t *) alloc(sizeof(struct mesg_info_t));
|
||||
|
||||
mesg_info->fs = 0;
|
||||
mesg_info->num_lines = 0;
|
||||
mesg_info->head = mesg_info->line_here = mesg_info->last_pause =
|
||||
mesg_info->last_pause_head = (struct line_element *) 0;
|
||||
mesg_info->last_pause_head = (struct line_element *) 0;
|
||||
mesg_info->dirty = False;
|
||||
mesg_info->viewport_width = mesg_info->viewport_height = 0;
|
||||
|
||||
if (iflags.msg_history < (unsigned) appResources.message_lines)
|
||||
iflags.msg_history = (unsigned) appResources.message_lines;
|
||||
if (iflags.msg_history > MAX_HISTORY) /* a sanity check */
|
||||
iflags.msg_history = MAX_HISTORY;
|
||||
iflags.msg_history = (unsigned) appResources.message_lines;
|
||||
if (iflags.msg_history > MAX_HISTORY) /* a sanity check */
|
||||
iflags.msg_history = MAX_HISTORY;
|
||||
|
||||
set_circle_buf(mesg_info, (int) iflags.msg_history);
|
||||
|
||||
/* Create a popup that becomes the parent. */
|
||||
if (create_popup) {
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True); num_args++;
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True);
|
||||
num_args++;
|
||||
|
||||
wp->popup = parent = XtCreatePopupShell("message_popup",
|
||||
topLevelShellWidgetClass,
|
||||
toplevel, args, num_args);
|
||||
/*
|
||||
* If we're here, then this is an auxiliary message window. If we're
|
||||
* cancelled via a delete window message, we should just pop down.
|
||||
*/
|
||||
wp->popup = parent =
|
||||
XtCreatePopupShell("message_popup", topLevelShellWidgetClass,
|
||||
toplevel, args, num_args);
|
||||
/*
|
||||
* If we're here, then this is an auxiliary message window. If we're
|
||||
* cancelled via a delete window message, we should just pop down.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -119,13 +118,14 @@ create_message_window(wp, create_popup, parent)
|
||||
* always be visible, due to the stupid way the Athena viewport operates.
|
||||
*/
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNallowVert, True); num_args++;
|
||||
XtSetArg(args[num_args], XtNallowVert, True);
|
||||
num_args++;
|
||||
viewport = XtCreateManagedWidget(
|
||||
"mesg_viewport", /* name */
|
||||
viewportWidgetClass, /* widget class from Window.h */
|
||||
parent, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
"mesg_viewport", /* name */
|
||||
viewportWidgetClass, /* widget class from Window.h */
|
||||
parent, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
|
||||
/*
|
||||
* Create a message window. We will change the width and height once
|
||||
@@ -133,15 +133,16 @@ create_message_window(wp, create_popup, parent)
|
||||
*/
|
||||
num_args = 0;
|
||||
if (!create_popup) {
|
||||
XtSetArg(args[num_args], XtNtranslations,
|
||||
XtParseTranslationTable(mesg_translations)); num_args++;
|
||||
XtSetArg(args[num_args], XtNtranslations,
|
||||
XtParseTranslationTable(mesg_translations));
|
||||
num_args++;
|
||||
}
|
||||
wp->w = XtCreateManagedWidget(
|
||||
"message", /* name */
|
||||
windowWidgetClass, /* widget class from Window.h */
|
||||
viewport, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
"message", /* name */
|
||||
windowWidgetClass, /* widget class from Window.h */
|
||||
viewport, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
|
||||
XtAddCallback(wp->w, XtNexposeCallback, mesg_exposed, (XtPointer) 0);
|
||||
|
||||
@@ -152,39 +153,43 @@ create_message_window(wp, create_popup, parent)
|
||||
|
||||
/* Get the font information. */
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNfont, &mesg_info->fs); num_args++;
|
||||
XtSetArg(args[num_args], XtNfont, &mesg_info->fs);
|
||||
num_args++;
|
||||
XtGetValues(wp->w, args, num_args);
|
||||
|
||||
/* Save character information for fast use later. */
|
||||
mesg_info->char_width = mesg_info->fs->max_bounds.width;
|
||||
mesg_info->char_height = mesg_info->fs->max_bounds.ascent +
|
||||
mesg_info->fs->max_bounds.descent;
|
||||
mesg_info->char_ascent = mesg_info->fs->max_bounds.ascent;
|
||||
mesg_info->char_width = mesg_info->fs->max_bounds.width;
|
||||
mesg_info->char_height =
|
||||
mesg_info->fs->max_bounds.ascent + mesg_info->fs->max_bounds.descent;
|
||||
mesg_info->char_ascent = mesg_info->fs->max_bounds.ascent;
|
||||
mesg_info->char_lbearing = -mesg_info->fs->min_bounds.lbearing;
|
||||
|
||||
get_gc(wp->w, mesg_info);
|
||||
|
||||
wp->pixel_height = ((int)iflags.msg_history) * mesg_info->char_height;
|
||||
wp->pixel_height = ((int) iflags.msg_history) * mesg_info->char_height;
|
||||
|
||||
/* If a variable spaced font, only use 2/3 of the default size */
|
||||
if (mesg_info->fs->min_bounds.width != mesg_info->fs->max_bounds.width) {
|
||||
wp->pixel_width = ((2*DEFAULT_MESSAGE_WIDTH)/3) *
|
||||
mesg_info->fs->max_bounds.width;
|
||||
wp->pixel_width = ((2 * DEFAULT_MESSAGE_WIDTH) / 3)
|
||||
* mesg_info->fs->max_bounds.width;
|
||||
} else
|
||||
wp->pixel_width = (DEFAULT_MESSAGE_WIDTH *
|
||||
mesg_info->fs->max_bounds.width);
|
||||
wp->pixel_width =
|
||||
(DEFAULT_MESSAGE_WIDTH * mesg_info->fs->max_bounds.width);
|
||||
|
||||
/* Set the new width and height. */
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNwidth, wp->pixel_width); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, wp->pixel_height); num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, wp->pixel_width);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, wp->pixel_height);
|
||||
num_args++;
|
||||
XtSetValues(wp->w, args, num_args);
|
||||
|
||||
/* make sure viewport height makes sense before realizing it */
|
||||
num_args = 0;
|
||||
mesg_info->viewport_height =
|
||||
appResources.message_lines * mesg_info->char_height;
|
||||
XtSetArg(args[num_args], XtNheight, mesg_info->viewport_height);num_args++;
|
||||
appResources.message_lines * mesg_info->char_height;
|
||||
XtSetArg(args[num_args], XtNheight, mesg_info->viewport_height);
|
||||
num_args++;
|
||||
XtSetValues(viewport, args, num_args);
|
||||
|
||||
XtAddCallback(wp->w, XtNresizeCallback, mesg_resized, (XtPointer) 0);
|
||||
@@ -194,66 +199,67 @@ create_message_window(wp, create_popup, parent)
|
||||
* viewport is also realized.
|
||||
*/
|
||||
if (create_popup) {
|
||||
XtRealizeWidget(wp->popup);
|
||||
XSetWMProtocols(XtDisplay(wp->popup), XtWindow(wp->popup),
|
||||
&wm_delete_window, 1);
|
||||
XtRealizeWidget(wp->popup);
|
||||
XSetWMProtocols(XtDisplay(wp->popup), XtWindow(wp->popup),
|
||||
&wm_delete_window, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
destroy_message_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
if (wp->popup) {
|
||||
nh_XtPopdown(wp->popup);
|
||||
if (!wp->keep_window)
|
||||
XtDestroyWidget(wp->popup), wp->popup = (Widget)0;
|
||||
nh_XtPopdown(wp->popup);
|
||||
if (!wp->keep_window)
|
||||
XtDestroyWidget(wp->popup), wp->popup = (Widget) 0;
|
||||
}
|
||||
if (wp->mesg_information) {
|
||||
set_circle_buf(wp->mesg_information, 0); /* free buffer list */
|
||||
free((genericptr_t)wp->mesg_information), wp->mesg_information = 0;
|
||||
set_circle_buf(wp->mesg_information, 0); /* free buffer list */
|
||||
free((genericptr_t) wp->mesg_information), wp->mesg_information = 0;
|
||||
}
|
||||
if (wp->keep_window)
|
||||
XtRemoveCallback(wp->w, XtNexposeCallback, mesg_exposed, (XtPointer)0);
|
||||
XtRemoveCallback(wp->w, XtNexposeCallback, mesg_exposed,
|
||||
(XtPointer) 0);
|
||||
else
|
||||
wp->type = NHW_NONE;
|
||||
wp->type = NHW_NONE;
|
||||
}
|
||||
|
||||
|
||||
/* Redraw message window if new lines have been added. */
|
||||
void
|
||||
display_message_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
if (wp->mesg_information->dirty) redraw_message_window(wp);
|
||||
if (wp->mesg_information->dirty)
|
||||
redraw_message_window(wp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Append a line of text to the message window. Split the line if the
|
||||
* rendering of the text is too long for the window.
|
||||
*/
|
||||
void
|
||||
append_message(wp, str)
|
||||
struct xwindow *wp;
|
||||
const char *str;
|
||||
struct xwindow *wp;
|
||||
const char *str;
|
||||
{
|
||||
char *mark, *remainder, buf[BUFSZ];
|
||||
|
||||
if (!str) return;
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
Strcpy(buf, str); /* we might mark it up */
|
||||
Strcpy(buf, str); /* we might mark it up */
|
||||
|
||||
remainder = buf;
|
||||
do {
|
||||
mark = remainder;
|
||||
remainder = split(mark, wp->mesg_information->fs, wp->pixel_width);
|
||||
add_line(wp->mesg_information, mark);
|
||||
mark = remainder;
|
||||
remainder = split(mark, wp->mesg_information->fs, wp->pixel_width);
|
||||
add_line(wp->mesg_information, mark);
|
||||
} while (remainder);
|
||||
}
|
||||
|
||||
/* private functions ======================================================= */
|
||||
/* private functions =======================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* Return the element in the circular linked list just before the given
|
||||
@@ -261,18 +267,18 @@ append_message(wp, str)
|
||||
*/
|
||||
static struct line_element *
|
||||
get_previous(mark)
|
||||
struct line_element *mark;
|
||||
struct line_element *mark;
|
||||
{
|
||||
struct line_element *curr;
|
||||
|
||||
if (!mark) return (struct line_element *) 0;
|
||||
if (!mark)
|
||||
return (struct line_element *) 0;
|
||||
|
||||
for (curr = mark; curr->next != mark; curr = curr->next)
|
||||
;
|
||||
;
|
||||
return curr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the information buffer size to count lines. We do this by creating
|
||||
* a circular linked list of elements, each of which represents a line of
|
||||
@@ -281,67 +287,70 @@ get_previous(mark)
|
||||
*/
|
||||
static void
|
||||
set_circle_buf(mesg_info, count)
|
||||
struct mesg_info_t *mesg_info;
|
||||
int count;
|
||||
struct mesg_info_t *mesg_info;
|
||||
int count;
|
||||
{
|
||||
int i;
|
||||
struct line_element *tail, *curr, *head;
|
||||
|
||||
if (count < 0) panic("set_circle_buf: bad count [= %d]", count);
|
||||
if (count == mesg_info->num_lines) return; /* no change in size */
|
||||
if (count < 0)
|
||||
panic("set_circle_buf: bad count [= %d]", count);
|
||||
if (count == mesg_info->num_lines)
|
||||
return; /* no change in size */
|
||||
|
||||
if (count < mesg_info->num_lines) {
|
||||
/*
|
||||
* Toss num_lines - count line entries from our circular list.
|
||||
*
|
||||
* We lose lines from the front (top) of the list. We _know_
|
||||
* the list is non_empty.
|
||||
*/
|
||||
tail = get_previous(mesg_info->head);
|
||||
for (i = mesg_info->num_lines - count; i > 0; i--) {
|
||||
curr = mesg_info->head;
|
||||
mesg_info->head = curr->next;
|
||||
if (curr->line) free((genericptr_t)curr->line);
|
||||
free((genericptr_t)curr);
|
||||
}
|
||||
if (count == 0) {
|
||||
/* make sure we don't have a dangling pointer */
|
||||
mesg_info->head = (struct line_element *) 0;
|
||||
} else {
|
||||
tail->next = mesg_info->head; /* link the tail to the head */
|
||||
}
|
||||
/*
|
||||
* Toss num_lines - count line entries from our circular list.
|
||||
*
|
||||
* We lose lines from the front (top) of the list. We _know_
|
||||
* the list is non_empty.
|
||||
*/
|
||||
tail = get_previous(mesg_info->head);
|
||||
for (i = mesg_info->num_lines - count; i > 0; i--) {
|
||||
curr = mesg_info->head;
|
||||
mesg_info->head = curr->next;
|
||||
if (curr->line)
|
||||
free((genericptr_t) curr->line);
|
||||
free((genericptr_t) curr);
|
||||
}
|
||||
if (count == 0) {
|
||||
/* make sure we don't have a dangling pointer */
|
||||
mesg_info->head = (struct line_element *) 0;
|
||||
} else {
|
||||
tail->next = mesg_info->head; /* link the tail to the head */
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Add count - num_lines blank lines to the head of the list.
|
||||
*
|
||||
* Create a separate list, keeping track of the tail.
|
||||
*/
|
||||
for (head = tail = 0, i = 0; i < count - mesg_info->num_lines; i++) {
|
||||
curr = (struct line_element *) alloc(sizeof(struct line_element));
|
||||
curr->line = 0;
|
||||
curr->buf_length = 0;
|
||||
curr->str_length = 0;
|
||||
if (tail) {
|
||||
tail->next = curr;
|
||||
tail = curr;
|
||||
} else {
|
||||
head = tail = curr;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Complete the circle by making the new tail point to the old head
|
||||
* and the old tail point to the new head. If our line count was
|
||||
* zero, then make the new list circular.
|
||||
*/
|
||||
if (mesg_info->num_lines) {
|
||||
curr = get_previous(mesg_info->head);/* get end of old list */
|
||||
/*
|
||||
* Add count - num_lines blank lines to the head of the list.
|
||||
*
|
||||
* Create a separate list, keeping track of the tail.
|
||||
*/
|
||||
for (head = tail = 0, i = 0; i < count - mesg_info->num_lines; i++) {
|
||||
curr = (struct line_element *) alloc(sizeof(struct line_element));
|
||||
curr->line = 0;
|
||||
curr->buf_length = 0;
|
||||
curr->str_length = 0;
|
||||
if (tail) {
|
||||
tail->next = curr;
|
||||
tail = curr;
|
||||
} else {
|
||||
head = tail = curr;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Complete the circle by making the new tail point to the old head
|
||||
* and the old tail point to the new head. If our line count was
|
||||
* zero, then make the new list circular.
|
||||
*/
|
||||
if (mesg_info->num_lines) {
|
||||
curr = get_previous(mesg_info->head); /* get end of old list */
|
||||
|
||||
tail->next = mesg_info->head; /* new tail -> old head */
|
||||
curr->next = head; /* old tail -> new head */
|
||||
} else {
|
||||
tail->next = head;
|
||||
}
|
||||
mesg_info->head = head;
|
||||
tail->next = mesg_info->head; /* new tail -> old head */
|
||||
curr->next = head; /* old tail -> new head */
|
||||
} else {
|
||||
tail->next = head;
|
||||
}
|
||||
mesg_info->head = head;
|
||||
}
|
||||
|
||||
mesg_info->num_lines = count;
|
||||
@@ -349,33 +358,33 @@ set_circle_buf(mesg_info, count)
|
||||
mesg_info->last_pause = (struct line_element *) 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make sure the given string is shorter than the given pixel width. If
|
||||
* not, back up from the end by words until we find a place to split.
|
||||
*/
|
||||
static char *
|
||||
split(s, fs, pixel_width)
|
||||
char *s;
|
||||
XFontStruct *fs; /* Font for the window. */
|
||||
Dimension pixel_width;
|
||||
char *s;
|
||||
XFontStruct *fs; /* Font for the window. */
|
||||
Dimension pixel_width;
|
||||
{
|
||||
char save, *end, *remainder;
|
||||
|
||||
save = '\0';
|
||||
remainder = 0;
|
||||
end = eos(s); /* point to null at end of string */
|
||||
end = eos(s); /* point to null at end of string */
|
||||
|
||||
/* assume that if end == s, XXXXXX returns 0) */
|
||||
while ((Dimension) XTextWidth(fs, s, (int) strlen(s)) > pixel_width) {
|
||||
*end-- = save;
|
||||
while (*end != ' ') {
|
||||
if (end == s) panic("split: eos!");
|
||||
--end;
|
||||
}
|
||||
save = *end;
|
||||
*end = '\0';
|
||||
remainder = end + 1;
|
||||
*end-- = save;
|
||||
while (*end != ' ') {
|
||||
if (end == s)
|
||||
panic("split: eos!");
|
||||
--end;
|
||||
}
|
||||
save = *end;
|
||||
*end = '\0';
|
||||
remainder = end + 1;
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
@@ -388,27 +397,27 @@ split(s, fs, pixel_width)
|
||||
*/
|
||||
static void
|
||||
add_line(mesg_info, s)
|
||||
struct mesg_info_t *mesg_info;
|
||||
const char *s;
|
||||
struct mesg_info_t *mesg_info;
|
||||
const char *s;
|
||||
{
|
||||
register struct line_element *curr = mesg_info->head;
|
||||
register int new_line_length = strlen(s);
|
||||
|
||||
if (new_line_length + 1 > curr->buf_length) {
|
||||
if (curr->line) free(curr->line); /* free old line */
|
||||
if (curr->line)
|
||||
free(curr->line); /* free old line */
|
||||
|
||||
curr->buf_length = new_line_length + 1;
|
||||
curr->line = (char *) alloc((unsigned)curr->buf_length);
|
||||
curr->buf_length = new_line_length + 1;
|
||||
curr->line = (char *) alloc((unsigned) curr->buf_length);
|
||||
}
|
||||
|
||||
Strcpy(curr->line, s); /* copy info */
|
||||
curr->str_length = new_line_length; /* save string length */
|
||||
Strcpy(curr->line, s); /* copy info */
|
||||
curr->str_length = new_line_length; /* save string length */
|
||||
|
||||
mesg_info->head = mesg_info->head->next; /* move head to next line */
|
||||
mesg_info->dirty = True; /* we have undrawn lines */
|
||||
mesg_info->head = mesg_info->head->next; /* move head to next line */
|
||||
mesg_info->dirty = True; /* we have undrawn lines */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save a position in the text buffer so we can draw a line to seperate
|
||||
* text from the last time this function was called.
|
||||
@@ -419,7 +428,7 @@ add_line(mesg_info, s)
|
||||
*/
|
||||
void
|
||||
set_last_pause(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
register struct mesg_info_t *mesg_info = wp->mesg_information;
|
||||
|
||||
@@ -429,26 +438,25 @@ set_last_pause(wp)
|
||||
* don't try to erase the line again.
|
||||
*/
|
||||
if (!mesg_info->last_pause
|
||||
&& mesg_info->last_pause_head == mesg_info->head)
|
||||
return;
|
||||
&& mesg_info->last_pause_head == mesg_info->head)
|
||||
return;
|
||||
|
||||
if (mesg_info->last_pause == mesg_info->head) {
|
||||
/* No new messages in last turn. Redraw window to erase line. */
|
||||
mesg_info->last_pause = (struct line_element *) 0;
|
||||
mesg_info->last_pause_head = mesg_info->head;
|
||||
redraw_message_window(wp);
|
||||
/* No new messages in last turn. Redraw window to erase line. */
|
||||
mesg_info->last_pause = (struct line_element *) 0;
|
||||
mesg_info->last_pause_head = mesg_info->head;
|
||||
redraw_message_window(wp);
|
||||
} else {
|
||||
#endif
|
||||
mesg_info->last_pause = mesg_info->head;
|
||||
mesg_info->last_pause = mesg_info->head;
|
||||
#ifdef ERASE_LINE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
redraw_message_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
struct mesg_info_t *mesg_info = wp->mesg_information;
|
||||
register struct line_element *curr;
|
||||
@@ -464,43 +472,36 @@ redraw_message_window(wp)
|
||||
* Only need to clear if window has new text.
|
||||
*/
|
||||
if (mesg_info->dirty) {
|
||||
XClearWindow(XtDisplay(wp->w), XtWindow(wp->w));
|
||||
mesg_info->line_here = mesg_info->last_pause;
|
||||
XClearWindow(XtDisplay(wp->w), XtWindow(wp->w));
|
||||
mesg_info->line_here = mesg_info->last_pause;
|
||||
}
|
||||
|
||||
/* For now, just update the whole shootn' match. */
|
||||
for (y_base = row = 0, curr = mesg_info->head;
|
||||
row < mesg_info->num_lines;
|
||||
row++, y_base += mesg_info->char_height, curr = curr->next) {
|
||||
|
||||
XDrawString(XtDisplay(wp->w), XtWindow(wp->w),
|
||||
mesg_info->gc,
|
||||
mesg_info->char_lbearing,
|
||||
mesg_info->char_ascent + y_base,
|
||||
curr->line,
|
||||
curr->str_length);
|
||||
/*
|
||||
* This draws a line at the _top_ of the line of text pointed to by
|
||||
* mesg_info->last_pause.
|
||||
*/
|
||||
if (appResources.message_line && curr == mesg_info->line_here) {
|
||||
XDrawLine(XtDisplay(wp->w), XtWindow(wp->w),
|
||||
mesg_info->gc,
|
||||
0, y_base, wp->pixel_width, y_base);
|
||||
}
|
||||
for (y_base = row = 0, curr = mesg_info->head; row < mesg_info->num_lines;
|
||||
row++, y_base += mesg_info->char_height, curr = curr->next) {
|
||||
XDrawString(XtDisplay(wp->w), XtWindow(wp->w), mesg_info->gc,
|
||||
mesg_info->char_lbearing, mesg_info->char_ascent + y_base,
|
||||
curr->line, curr->str_length);
|
||||
/*
|
||||
* This draws a line at the _top_ of the line of text pointed to by
|
||||
* mesg_info->last_pause.
|
||||
*/
|
||||
if (appResources.message_line && curr == mesg_info->line_here) {
|
||||
XDrawLine(XtDisplay(wp->w), XtWindow(wp->w), mesg_info->gc, 0,
|
||||
y_base, wp->pixel_width, y_base);
|
||||
}
|
||||
}
|
||||
|
||||
mesg_info->dirty = False;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check the size of the viewport. If it has shrunk, then we want to
|
||||
* move the vertical slider to the bottom.
|
||||
*/
|
||||
static void
|
||||
mesg_check_size_change(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
struct mesg_info_t *mesg_info = wp->mesg_information;
|
||||
Arg arg[2];
|
||||
@@ -509,59 +510,59 @@ mesg_check_size_change(wp)
|
||||
|
||||
viewport = XtParent(wp->w);
|
||||
|
||||
XtSetArg(arg[0], XtNwidth, &new_width);
|
||||
XtSetArg(arg[0], XtNwidth, &new_width);
|
||||
XtSetArg(arg[1], XtNheight, &new_height);
|
||||
XtGetValues(viewport, arg, TWO);
|
||||
|
||||
/* Only move slider to bottom if new size is smaller. */
|
||||
if (new_width < mesg_info->viewport_width
|
||||
|| new_height < mesg_info->viewport_height) {
|
||||
set_message_slider(wp);
|
||||
|| new_height < mesg_info->viewport_height) {
|
||||
set_message_slider(wp);
|
||||
}
|
||||
|
||||
mesg_info->viewport_width = new_width;
|
||||
mesg_info->viewport_height = new_height;
|
||||
}
|
||||
|
||||
|
||||
/* Event handler for message window expose events. */
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
mesg_exposed(w, client_data, widget_data)
|
||||
Widget w;
|
||||
XtPointer client_data; /* unused */
|
||||
XtPointer widget_data; /* expose event from Window widget */
|
||||
Widget w;
|
||||
XtPointer client_data; /* unused */
|
||||
XtPointer widget_data; /* expose event from Window widget */
|
||||
{
|
||||
XExposeEvent *event = (XExposeEvent *) widget_data;
|
||||
|
||||
nhUse(client_data);
|
||||
|
||||
if (XtIsRealized(w) && event->count == 0) {
|
||||
struct xwindow *wp;
|
||||
Display *dpy;
|
||||
Window win;
|
||||
XEvent evt;
|
||||
struct xwindow *wp;
|
||||
Display *dpy;
|
||||
Window win;
|
||||
XEvent evt;
|
||||
|
||||
/*
|
||||
* Drain all pending expose events for the message window;
|
||||
* we'll redraw the whole thing at once.
|
||||
*/
|
||||
dpy = XtDisplay(w);
|
||||
win = XtWindow(w);
|
||||
while (XCheckTypedWindowEvent(dpy, win, Expose, &evt)) continue;
|
||||
/*
|
||||
* Drain all pending expose events for the message window;
|
||||
* we'll redraw the whole thing at once.
|
||||
*/
|
||||
dpy = XtDisplay(w);
|
||||
win = XtWindow(w);
|
||||
while (XCheckTypedWindowEvent(dpy, win, Expose, &evt))
|
||||
continue;
|
||||
|
||||
wp = find_widget(w);
|
||||
if (wp->keep_window && !wp->mesg_information) return;
|
||||
mesg_check_size_change(wp);
|
||||
redraw_message_window(wp);
|
||||
wp = find_widget(w);
|
||||
if (wp->keep_window && !wp->mesg_information)
|
||||
return;
|
||||
mesg_check_size_change(wp);
|
||||
redraw_message_window(wp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_gc(w, mesg_info)
|
||||
Widget w;
|
||||
struct mesg_info_t *mesg_info;
|
||||
Widget w;
|
||||
struct mesg_info_t *mesg_info;
|
||||
{
|
||||
XGCValues values;
|
||||
XtGCMask mask = GCFunction | GCForeground | GCBackground | GCFont;
|
||||
@@ -574,8 +575,8 @@ get_gc(w, mesg_info)
|
||||
|
||||
values.foreground = fgpixel;
|
||||
values.background = bgpixel;
|
||||
values.function = GXcopy;
|
||||
values.font = WindowFont(w);
|
||||
values.function = GXcopy;
|
||||
values.font = WindowFont(w);
|
||||
mesg_info->gc = XtGetGC(w, mask, &values);
|
||||
}
|
||||
|
||||
@@ -592,8 +593,8 @@ get_gc(w, mesg_info)
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
mesg_resized(w, client_data, call_data)
|
||||
Widget w;
|
||||
XtPointer call_data, client_data;
|
||||
Widget w;
|
||||
XtPointer call_data, client_data;
|
||||
{
|
||||
Arg args[4];
|
||||
Cardinal num_args;
|
||||
@@ -602,30 +603,32 @@ mesg_resized(w, client_data, call_data)
|
||||
#ifdef VERBOSE
|
||||
int old_lines;
|
||||
|
||||
old_lines = wp->mesg_information->num_lines;;
|
||||
old_lines = wp->mesg_information->num_lines;
|
||||
;
|
||||
#endif
|
||||
|
||||
nhUse(call_data);
|
||||
nhUse(client_data);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNwidth, &pixel_width); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, &pixel_height); num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, &pixel_width);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, &pixel_height);
|
||||
num_args++;
|
||||
XtGetValues(w, args, num_args);
|
||||
|
||||
wp = find_widget(w);
|
||||
wp->pixel_width = pixel_width;
|
||||
wp->pixel_width = pixel_width;
|
||||
wp->pixel_height = pixel_height;
|
||||
|
||||
set_circle_buf(wp->mesg_information,
|
||||
(int) pixel_height / wp->mesg_information->char_height);
|
||||
(int) pixel_height / wp->mesg_information->char_height);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Message resize. Pixel: width = %d, height = %d; Lines: old = %d, new = %d\n",
|
||||
pixel_width,
|
||||
pixel_height,
|
||||
old_lines,
|
||||
wp->mesg_information->num_lines);
|
||||
printf("Message resize. Pixel: width = %d, height = %d; Lines: old = "
|
||||
"%d, new = %d\n",
|
||||
pixel_width, pixel_height, old_lines,
|
||||
wp->mesg_information->num_lines);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+534
-513
File diff suppressed because it is too large
Load Diff
+634
-547
File diff suppressed because it is too large
Load Diff
+260
-244
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintext.c $NHDT-Date: 1430899138 2015/05/06 07:58:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
|
||||
/* NetHack 3.6 wintext.c $NHDT-Date: 1431192773 2015/05/09 17:32:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.13 $ */
|
||||
/* NetHack 3.6 wintext.c $Date: 2012/01/24 04:26:27 $ $Revision: 1.7 $ */
|
||||
/* SCCS Id: @(#)wintext.c 3.5 1996/04/05 */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
#ifndef SYSV
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
@@ -24,10 +24,10 @@
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
# ifdef SYSV
|
||||
# undef SYSV
|
||||
# endif
|
||||
# undef PRESERVE_NO_SYSV
|
||||
#ifdef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "hack.h"
|
||||
@@ -38,17 +38,15 @@
|
||||
#include <X11/xpm.h>
|
||||
#endif
|
||||
|
||||
#define TRANSIENT_TEXT /* text window is a transient window (no positioning) \
|
||||
*/
|
||||
|
||||
#define TRANSIENT_TEXT /* text window is a transient window (no positioning) */
|
||||
|
||||
static const char text_translations[] =
|
||||
"#override\n\
|
||||
static const char text_translations[] = "#override\n\
|
||||
<BtnDown>: dismiss_text()\n\
|
||||
<Key>: key_dismiss_text()";
|
||||
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
static const char rip_translations[] =
|
||||
"#override\n\
|
||||
static const char rip_translations[] = "#override\n\
|
||||
<BtnDown>: rip_dismiss_text()\n\
|
||||
<Key>: rip_dismiss_text()";
|
||||
|
||||
@@ -58,10 +56,10 @@ static Widget FDECL(create_ripout_widget, (Widget));
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
delete_text(w, event, params, num_params)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
{
|
||||
struct xwindow *wp;
|
||||
struct text_info_t *text_info;
|
||||
@@ -76,9 +74,9 @@ delete_text(w, event, params, num_params)
|
||||
nh_XtPopdown(wp->popup);
|
||||
|
||||
if (text_info->blocked) {
|
||||
exit_x_event = TRUE;
|
||||
exit_x_event = TRUE;
|
||||
} else if (text_info->destroy_on_ack) {
|
||||
destroy_text_window(wp);
|
||||
destroy_text_window(wp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,10 +88,10 @@ delete_text(w, event, params, num_params)
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
dismiss_text(w, event, params, num_params)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
{
|
||||
struct xwindow *wp;
|
||||
struct text_info_t *text_info;
|
||||
@@ -108,44 +106,44 @@ dismiss_text(w, event, params, num_params)
|
||||
nh_XtPopdown(wp->popup);
|
||||
|
||||
if (text_info->blocked) {
|
||||
exit_x_event = TRUE;
|
||||
exit_x_event = TRUE;
|
||||
} else if (text_info->destroy_on_ack) {
|
||||
destroy_text_window(wp);
|
||||
destroy_text_window(wp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dismiss when a non-modifier key pressed. */
|
||||
void
|
||||
key_dismiss_text(w, event, params, num_params)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
{
|
||||
char ch = key_event_to_char((XKeyEvent *) event);
|
||||
if (ch) dismiss_text(w, event, params, num_params);
|
||||
if (ch)
|
||||
dismiss_text(w, event, params, num_params);
|
||||
}
|
||||
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
/* Dismiss from clicking on rip image. */
|
||||
void
|
||||
rip_dismiss_text(w, event, params, num_params)
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
Widget w;
|
||||
XEvent *event;
|
||||
String *params;
|
||||
Cardinal *num_params;
|
||||
{
|
||||
dismiss_text(XtParent(w), event, params, num_params);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
add_to_text_window(wp, attr, str)
|
||||
struct xwindow *wp;
|
||||
int attr; /* currently unused */
|
||||
const char *str;
|
||||
struct xwindow *wp;
|
||||
int attr; /* currently unused */
|
||||
const char *str;
|
||||
{
|
||||
struct text_info_t *text_info = wp->text_information;
|
||||
int width;
|
||||
@@ -157,13 +155,13 @@ add_to_text_window(wp, attr, str)
|
||||
/* Calculate text width and save longest line */
|
||||
width = XTextWidth(text_info->fs, str, (int) strlen(str));
|
||||
if (width > text_info->max_width)
|
||||
text_info->max_width = width;
|
||||
text_info->max_width = width;
|
||||
}
|
||||
|
||||
void
|
||||
display_text_window(wp, blocking)
|
||||
struct xwindow *wp;
|
||||
boolean blocking;
|
||||
struct xwindow *wp;
|
||||
boolean blocking;
|
||||
{
|
||||
struct text_info_t *text_info;
|
||||
Arg args[8];
|
||||
@@ -172,7 +170,7 @@ display_text_window(wp, blocking)
|
||||
int nlines;
|
||||
|
||||
text_info = wp->text_information;
|
||||
width = text_info->max_width + text_info->extra_width;
|
||||
width = text_info->max_width + text_info->extra_width;
|
||||
text_info->blocked = blocking;
|
||||
text_info->destroy_on_ack = FALSE;
|
||||
font_height = nhFontHeight(wp->w);
|
||||
@@ -185,74 +183,83 @@ display_text_window(wp, blocking)
|
||||
* _some_ lines. Finally, use the number of lines in the text if
|
||||
* there are fewer than the max.
|
||||
*/
|
||||
nlines = (XtScreen(wp->w)->height - text_info->extra_height) / font_height;
|
||||
nlines =
|
||||
(XtScreen(wp->w)->height - text_info->extra_height) / font_height;
|
||||
nlines -= 4;
|
||||
|
||||
if (nlines > text_info->text.num_lines)
|
||||
nlines = text_info->text.num_lines;
|
||||
if (nlines <= 0) nlines = 1;
|
||||
nlines = text_info->text.num_lines;
|
||||
if (nlines <= 0)
|
||||
nlines = 1;
|
||||
|
||||
height = nlines * font_height + text_info->extra_height;
|
||||
|
||||
num_args = 0;
|
||||
|
||||
if (nlines < text_info->text.num_lines) {
|
||||
/* add on width of scrollbar. Really should look this up,
|
||||
* but can't until the window is realized. Chicken-and-egg problem.
|
||||
*/
|
||||
width += 20;
|
||||
/* add on width of scrollbar. Really should look this up,
|
||||
* but can't until the window is realized. Chicken-and-egg problem.
|
||||
*/
|
||||
width += 20;
|
||||
}
|
||||
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
if (text_info->is_rip) {
|
||||
Widget rip = create_ripout_widget(XtParent(wp->w));
|
||||
XtSetArg(args[num_args], XtNfromVert, rip); num_args++;
|
||||
Widget rip = create_ripout_widget(XtParent(wp->w));
|
||||
XtSetArg(args[num_args], XtNfromVert, rip);
|
||||
num_args++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (width > (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */
|
||||
/* Back off some amount - we really need to back off the scrollbar */
|
||||
/* width plus some extra. */
|
||||
width = XtScreen(wp->w)->width - 20;
|
||||
if (width
|
||||
> (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */
|
||||
/* Back off some amount - we really need to back off the scrollbar */
|
||||
/* width plus some extra. */
|
||||
width = XtScreen(wp->w)->width - 20;
|
||||
}
|
||||
XtSetArg(args[num_args], XtNstring, text_info->text.text); num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, width); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, height); num_args++;
|
||||
XtSetArg(args[num_args], XtNstring, text_info->text.text);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, width);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, height);
|
||||
num_args++;
|
||||
XtSetValues(wp->w, args, num_args);
|
||||
|
||||
#ifdef TRANSIENT_TEXT
|
||||
XtRealizeWidget(wp->popup);
|
||||
XSetWMProtocols(XtDisplay(wp->popup), XtWindow(wp->popup),
|
||||
&wm_delete_window, 1);
|
||||
&wm_delete_window, 1);
|
||||
positionpopup(wp->popup, FALSE);
|
||||
#endif
|
||||
|
||||
nh_XtPopup(wp->popup, (int)XtGrabNone, wp->w);
|
||||
nh_XtPopup(wp->popup, (int) XtGrabNone, wp->w);
|
||||
|
||||
/* Kludge alert. Scrollbars are not sized correctly by the Text widget */
|
||||
/* if added before the window is displayed, so do it afterward. */
|
||||
num_args = 0;
|
||||
if (nlines < text_info->text.num_lines) { /* add vert scrollbar */
|
||||
XtSetArg(args[num_args], nhStr(XtNscrollVertical),
|
||||
XawtextScrollAlways); num_args++;
|
||||
if (nlines < text_info->text.num_lines) { /* add vert scrollbar */
|
||||
XtSetArg(args[num_args], nhStr(XtNscrollVertical),
|
||||
XawtextScrollAlways);
|
||||
num_args++;
|
||||
}
|
||||
if (width >= (Dimension) (XtScreen(wp->w)->width-20)) { /* too wide */
|
||||
XtSetArg(args[num_args], nhStr(XtNscrollHorizontal),
|
||||
XawtextScrollAlways); num_args++;
|
||||
if (width >= (Dimension)(XtScreen(wp->w)->width - 20)) { /* too wide */
|
||||
XtSetArg(args[num_args], nhStr(XtNscrollHorizontal),
|
||||
XawtextScrollAlways);
|
||||
num_args++;
|
||||
}
|
||||
if (num_args) XtSetValues(wp->w, args, num_args);
|
||||
if (num_args)
|
||||
XtSetValues(wp->w, args, num_args);
|
||||
|
||||
/* We want the user to acknowlege. */
|
||||
if (blocking) {
|
||||
(void) x_event(EXIT_ON_EXIT);
|
||||
nh_XtPopdown(wp->popup);
|
||||
(void) x_event(EXIT_ON_EXIT);
|
||||
nh_XtPopdown(wp->popup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
create_text_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
struct text_info_t *text_info;
|
||||
Arg args[8];
|
||||
@@ -263,72 +270,80 @@ create_text_window(wp)
|
||||
wp->type = NHW_TEXT;
|
||||
|
||||
wp->text_information = text_info =
|
||||
(struct text_info_t *) alloc(sizeof(struct text_info_t));
|
||||
(struct text_info_t *) alloc(sizeof(struct text_info_t));
|
||||
|
||||
init_text_buffer(&text_info->text);
|
||||
text_info->max_width = 0;
|
||||
text_info->extra_width = 0;
|
||||
text_info->extra_height = 0;
|
||||
text_info->blocked = FALSE;
|
||||
text_info->destroy_on_ack = TRUE; /* Ok to destroy before display */
|
||||
text_info->max_width = 0;
|
||||
text_info->extra_width = 0;
|
||||
text_info->extra_height = 0;
|
||||
text_info->blocked = FALSE;
|
||||
text_info->destroy_on_ack = TRUE; /* Ok to destroy before display */
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
text_info->is_rip = FALSE;
|
||||
text_info->is_rip = FALSE;
|
||||
#endif
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True); num_args++;
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNtranslations,
|
||||
XtParseTranslationTable(text_translations)); num_args++;
|
||||
XtParseTranslationTable(text_translations));
|
||||
num_args++;
|
||||
|
||||
#ifdef TRANSIENT_TEXT
|
||||
wp->popup = XtCreatePopupShell("text", transientShellWidgetClass,
|
||||
toplevel, args, num_args);
|
||||
toplevel, args, num_args);
|
||||
#else
|
||||
wp->popup = XtCreatePopupShell("text", topLevelShellWidgetClass,
|
||||
toplevel, args, num_args);
|
||||
wp->popup = XtCreatePopupShell("text", topLevelShellWidgetClass, toplevel,
|
||||
args, num_args);
|
||||
#endif
|
||||
XtOverrideTranslations(wp->popup,
|
||||
XtParseTranslationTable("<Message>WM_PROTOCOLS: delete_text()"));
|
||||
XtOverrideTranslations(
|
||||
wp->popup,
|
||||
XtParseTranslationTable("<Message>WM_PROTOCOLS: delete_text()"));
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True); num_args++;
|
||||
form = XtCreateManagedWidget("form", formWidgetClass, wp->popup,
|
||||
args, num_args);
|
||||
XtSetArg(args[num_args], XtNallowShellResize, True);
|
||||
num_args++;
|
||||
form = XtCreateManagedWidget("form", formWidgetClass, wp->popup, args,
|
||||
num_args);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNdisplayCaret), False); num_args++;
|
||||
XtSetArg(args[num_args], XtNresize, XawtextResizeBoth); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNdisplayCaret), False);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNresize, XawtextResizeBoth);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNtranslations,
|
||||
XtParseTranslationTable(text_translations)); num_args++;
|
||||
XtParseTranslationTable(text_translations));
|
||||
num_args++;
|
||||
|
||||
wp->w = XtCreateManagedWidget(
|
||||
killer.name[0] && WIN_MAP == WIN_ERR ?
|
||||
"tombstone" : "text_text", /* name */
|
||||
asciiTextWidgetClass,
|
||||
form, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
wp->w = XtCreateManagedWidget(killer.name[0] && WIN_MAP == WIN_ERR
|
||||
? "tombstone"
|
||||
: "text_text", /* name */
|
||||
asciiTextWidgetClass,
|
||||
form, /* parent widget */
|
||||
args, /* set some values */
|
||||
num_args); /* number of values to set */
|
||||
|
||||
/* Get the font and margin information. */
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNfont, &text_info->fs); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtopMargin),
|
||||
&top_margin); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottomMargin),
|
||||
&bottom_margin); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleftMargin),
|
||||
&left_margin); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNrightMargin),
|
||||
&right_margin); num_args++;
|
||||
XtSetArg(args[num_args], XtNfont, &text_info->fs);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtopMargin), &top_margin);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottomMargin), &bottom_margin);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleftMargin), &left_margin);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNrightMargin), &right_margin);
|
||||
num_args++;
|
||||
XtGetValues(wp->w, args, num_args);
|
||||
|
||||
text_info->extra_width = left_margin + right_margin;
|
||||
text_info->extra_width = left_margin + right_margin;
|
||||
text_info->extra_height = top_margin + bottom_margin;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_text_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
/* Don't need to pop down, this only called from dismiss_text(). */
|
||||
|
||||
@@ -341,78 +356,81 @@ destroy_text_window(wp)
|
||||
* press.
|
||||
*/
|
||||
if (text_info->blocked || text_info->destroy_on_ack) {
|
||||
XtDestroyWidget(wp->popup);
|
||||
free_text_buffer(&text_info->text);
|
||||
free((genericptr_t)text_info), wp->text_information = 0;
|
||||
wp->type = NHW_NONE; /* allow reuse */
|
||||
XtDestroyWidget(wp->popup);
|
||||
free_text_buffer(&text_info->text);
|
||||
free((genericptr_t) text_info), wp->text_information = 0;
|
||||
wp->type = NHW_NONE; /* allow reuse */
|
||||
} else {
|
||||
text_info->destroy_on_ack = TRUE; /* destroy on next ACK */
|
||||
text_info->destroy_on_ack = TRUE; /* destroy on next ACK */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clear_text_window(wp)
|
||||
struct xwindow *wp;
|
||||
struct xwindow *wp;
|
||||
{
|
||||
clear_text_buffer(&wp->text_information->text);
|
||||
}
|
||||
|
||||
|
||||
/* text buffer routines ---------------------------------------------------- */
|
||||
/* text buffer routines ----------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Append a line to the text buffer. */
|
||||
void
|
||||
append_text_buffer(tb, str, concat)
|
||||
struct text_buffer *tb;
|
||||
const char *str;
|
||||
boolean concat;
|
||||
struct text_buffer *tb;
|
||||
const char *str;
|
||||
boolean concat;
|
||||
{
|
||||
char *copy;
|
||||
int length;
|
||||
|
||||
if (!tb->text) panic("append_text_buffer: null text buffer");
|
||||
if (!tb->text)
|
||||
panic("append_text_buffer: null text buffer");
|
||||
|
||||
if (str) {
|
||||
length = strlen(str);
|
||||
length = strlen(str);
|
||||
} else {
|
||||
length = 0;
|
||||
length = 0;
|
||||
}
|
||||
|
||||
if (length + tb->text_last + 1 >= tb->text_size) {
|
||||
/* we need to go to a bigger buffer! */
|
||||
/* we need to go to a bigger buffer! */
|
||||
#ifdef VERBOSE
|
||||
printf("append_text_buffer: text buffer growing from %d to %d bytes\n",
|
||||
tb->text_size, 2*tb->text_size);
|
||||
printf(
|
||||
"append_text_buffer: text buffer growing from %d to %d bytes\n",
|
||||
tb->text_size, 2 * tb->text_size);
|
||||
#endif
|
||||
copy = (char *) alloc((unsigned)tb->text_size*2);
|
||||
(void) memcpy(copy, tb->text, tb->text_last);
|
||||
free(tb->text);
|
||||
tb->text = copy;
|
||||
tb->text_size *= 2;
|
||||
copy = (char *) alloc((unsigned) tb->text_size * 2);
|
||||
(void) memcpy(copy, tb->text, tb->text_last);
|
||||
free(tb->text);
|
||||
tb->text = copy;
|
||||
tb->text_size *= 2;
|
||||
}
|
||||
|
||||
if (tb->num_lines) { /* not first --- append a newline */
|
||||
char appchar = '\n';
|
||||
if (tb->num_lines) { /* not first --- append a newline */
|
||||
char appchar = '\n';
|
||||
|
||||
if(concat && !index("!.?'\")", tb->text[tb->text_last-1])) {
|
||||
appchar = ' ';
|
||||
tb->num_lines--; /* offset increment at end of function */
|
||||
}
|
||||
if (concat && !index("!.?'\")", tb->text[tb->text_last - 1])) {
|
||||
appchar = ' ';
|
||||
tb->num_lines--; /* offset increment at end of function */
|
||||
}
|
||||
|
||||
*(tb->text + tb->text_last) = appchar;
|
||||
tb->text_last++;
|
||||
*(tb->text + tb->text_last) = appchar;
|
||||
tb->text_last++;
|
||||
}
|
||||
|
||||
if (str) {
|
||||
(void) memcpy((tb->text+tb->text_last), str, length+1);
|
||||
if(length) {
|
||||
/* Remove all newlines. Otherwise we have a confused line count. */
|
||||
copy = (tb->text+tb->text_last);
|
||||
while ((copy = index(copy, '\n')) != (char*)0)
|
||||
*copy = ' ';
|
||||
}
|
||||
(void) memcpy((tb->text + tb->text_last), str, length + 1);
|
||||
if (length) {
|
||||
/* Remove all newlines. Otherwise we have a confused line count.
|
||||
*/
|
||||
copy = (tb->text + tb->text_last);
|
||||
while ((copy = index(copy, '\n')) != (char *) 0)
|
||||
*copy = ' ';
|
||||
}
|
||||
|
||||
tb->text_last += length;
|
||||
tb->text_last += length;
|
||||
}
|
||||
tb->text[tb->text_last] = '\0';
|
||||
tb->num_lines++;
|
||||
@@ -421,10 +439,10 @@ append_text_buffer(tb, str, concat)
|
||||
/* Initialize text buffer. */
|
||||
void
|
||||
init_text_buffer(tb)
|
||||
struct text_buffer *tb;
|
||||
struct text_buffer *tb;
|
||||
{
|
||||
tb->text = (char *) alloc(START_SIZE);
|
||||
tb->text[0] = '\0';
|
||||
tb->text = (char *) alloc(START_SIZE);
|
||||
tb->text[0] = '\0';
|
||||
tb->text_size = START_SIZE;
|
||||
tb->text_last = 0;
|
||||
tb->num_lines = 0;
|
||||
@@ -433,17 +451,17 @@ init_text_buffer(tb)
|
||||
/* Empty the text buffer */
|
||||
void
|
||||
clear_text_buffer(tb)
|
||||
struct text_buffer *tb;
|
||||
struct text_buffer *tb;
|
||||
{
|
||||
tb->text_last = 0;
|
||||
tb->text[0] = '\0';
|
||||
tb->text[0] = '\0';
|
||||
tb->num_lines = 0;
|
||||
}
|
||||
|
||||
/* Free up allocated memory. */
|
||||
void
|
||||
free_text_buffer(tb)
|
||||
struct text_buffer *tb;
|
||||
struct text_buffer *tb;
|
||||
{
|
||||
free(tb->text);
|
||||
tb->text = (char *) 0;
|
||||
@@ -452,100 +470,95 @@ free_text_buffer(tb)
|
||||
tb->num_lines = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
|
||||
static void FDECL(rip_exposed, (Widget,XtPointer,XtPointer));
|
||||
static void FDECL(rip_exposed, (Widget, XtPointer, XtPointer));
|
||||
|
||||
static XImage* rip_image=0;
|
||||
static XImage *rip_image = 0;
|
||||
|
||||
#define STONE_LINE_LEN 16 /* # chars that fit on one line */
|
||||
#define NAME_LINE 0 /* line # for player name */
|
||||
#define GOLD_LINE 1 /* line # for amount of gold */
|
||||
#define DEATH_LINE 2 /* line # for death description */
|
||||
#define YEAR_LINE 6 /* line # for year */
|
||||
|
||||
#define STONE_LINE_LEN 16 /* # chars that fit on one line */
|
||||
#define NAME_LINE 0 /* line # for player name */
|
||||
#define GOLD_LINE 1 /* line # for amount of gold */
|
||||
#define DEATH_LINE 2 /* line # for death description */
|
||||
#define YEAR_LINE 6 /* line # for year */
|
||||
|
||||
static char rip_line[YEAR_LINE+1][STONE_LINE_LEN+1];
|
||||
static char rip_line[YEAR_LINE + 1][STONE_LINE_LEN + 1];
|
||||
|
||||
void
|
||||
calculate_rip_text(int how, time_t when)
|
||||
{
|
||||
/* Follows same algorithm as genl_outrip() */
|
||||
/* Follows same algorithm as genl_outrip() */
|
||||
|
||||
char buf[BUFSZ];
|
||||
char *dpx;
|
||||
int line;
|
||||
long year;
|
||||
char buf[BUFSZ];
|
||||
char *dpx;
|
||||
int line;
|
||||
long year;
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(rip_line[NAME_LINE], "%s", plname);
|
||||
/* Put name on stone */
|
||||
Sprintf(rip_line[NAME_LINE], "%s", plname);
|
||||
|
||||
/* Put $ on stone */
|
||||
Sprintf(rip_line[GOLD_LINE], "%ld Au",
|
||||
done_money);
|
||||
/* Put together death description */
|
||||
formatkiller(buf, sizeof buf, how);
|
||||
/* Put $ on stone */
|
||||
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
|
||||
/* Put together death description */
|
||||
formatkiller(buf, sizeof buf, how);
|
||||
|
||||
/* Put death type on stone */
|
||||
for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
|
||||
register int i,i0;
|
||||
char tmpchar;
|
||||
/* Put death type on stone */
|
||||
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
|
||||
register int i, i0;
|
||||
char tmpchar;
|
||||
|
||||
if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
|
||||
for(i = STONE_LINE_LEN;
|
||||
((i0 > STONE_LINE_LEN) && i); i--)
|
||||
if(dpx[i] == ' ') i0 = i;
|
||||
if(!i) i0 = STONE_LINE_LEN;
|
||||
}
|
||||
tmpchar = dpx[i0];
|
||||
dpx[i0] = 0;
|
||||
strcpy(rip_line[line], dpx);
|
||||
if (tmpchar != ' ') {
|
||||
dpx[i0] = tmpchar;
|
||||
dpx= &dpx[i0];
|
||||
} else dpx= &dpx[i0+1];
|
||||
}
|
||||
if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
|
||||
for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
|
||||
if (dpx[i] == ' ')
|
||||
i0 = i;
|
||||
if (!i)
|
||||
i0 = STONE_LINE_LEN;
|
||||
}
|
||||
tmpchar = dpx[i0];
|
||||
dpx[i0] = 0;
|
||||
strcpy(rip_line[line], dpx);
|
||||
if (tmpchar != ' ') {
|
||||
dpx[i0] = tmpchar;
|
||||
dpx = &dpx[i0];
|
||||
} else
|
||||
dpx = &dpx[i0 + 1];
|
||||
}
|
||||
|
||||
/* Put year on stone */
|
||||
year = yyyymmdd(when) / 10000L;
|
||||
Sprintf(rip_line[YEAR_LINE], "%4ld", year);
|
||||
/* Put year on stone */
|
||||
year = yyyymmdd(when) / 10000L;
|
||||
Sprintf(rip_line[YEAR_LINE], "%4ld", year);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* RIP image expose callback.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
rip_exposed(w, client_data, widget_data)
|
||||
Widget w;
|
||||
XtPointer client_data; /* unused */
|
||||
XtPointer widget_data; /* expose event from Window widget */
|
||||
Widget w;
|
||||
XtPointer client_data; /* unused */
|
||||
XtPointer widget_data; /* expose event from Window widget */
|
||||
{
|
||||
XExposeEvent *event = (XExposeEvent *) widget_data;
|
||||
Display* dpy=XtDisplay(w);
|
||||
Display *dpy = XtDisplay(w);
|
||||
Arg args[8];
|
||||
XGCValues values;
|
||||
XtGCMask mask;
|
||||
GC gc;
|
||||
static Pixmap rip_pixmap=None;
|
||||
static Pixmap rip_pixmap = None;
|
||||
int i, x, y;
|
||||
|
||||
if (!XtIsRealized(w) || event->count > 0) return;
|
||||
if (!XtIsRealized(w) || event->count > 0)
|
||||
return;
|
||||
|
||||
if (rip_pixmap == None && rip_image) {
|
||||
rip_pixmap = XCreatePixmap(dpy, XtWindow(w),
|
||||
rip_image->width,
|
||||
rip_image->height,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)));
|
||||
XPutImage(dpy, rip_pixmap,
|
||||
DefaultGC(dpy, DefaultScreen(dpy)),
|
||||
rip_image,
|
||||
0,0, 0,0, /* src, dest top left */
|
||||
rip_image->width,
|
||||
rip_image->height);
|
||||
XDestroyImage(rip_image); /* data bytes free'd also */
|
||||
rip_pixmap = XCreatePixmap(dpy, XtWindow(w), rip_image->width,
|
||||
rip_image->height,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)));
|
||||
XPutImage(dpy, rip_pixmap, DefaultGC(dpy, DefaultScreen(dpy)),
|
||||
rip_image, 0, 0, 0, 0, /* src, dest top left */
|
||||
rip_image->width, rip_image->height);
|
||||
XDestroyImage(rip_image); /* data bytes free'd also */
|
||||
}
|
||||
|
||||
mask = GCFunction | GCForeground | GCGraphicsExposures | GCFont;
|
||||
@@ -557,21 +570,19 @@ rip_exposed(w, client_data, widget_data)
|
||||
gc = XtGetGC(w, mask, &values);
|
||||
|
||||
if (rip_pixmap != None) {
|
||||
XCopyArea(dpy, rip_pixmap, XtWindow(w), gc,
|
||||
event->x, event->y, event->width, event->height,
|
||||
event->x, event->y);
|
||||
XCopyArea(dpy, rip_pixmap, XtWindow(w), gc, event->x, event->y,
|
||||
event->width, event->height, event->x, event->y);
|
||||
}
|
||||
|
||||
x=appResources.tombtext_x;
|
||||
y=appResources.tombtext_y;
|
||||
for (i=0; i<=YEAR_LINE; i++) {
|
||||
int len=strlen(rip_line[i]);
|
||||
XFontStruct* font=WindowFontStruct(w);
|
||||
int width=XTextWidth(font, rip_line[i], len);
|
||||
XDrawString(dpy, XtWindow(w), gc,
|
||||
x-width/2, y, rip_line[i], len);
|
||||
x+=appResources.tombtext_dx;
|
||||
y+=appResources.tombtext_dy;
|
||||
x = appResources.tombtext_x;
|
||||
y = appResources.tombtext_y;
|
||||
for (i = 0; i <= YEAR_LINE; i++) {
|
||||
int len = strlen(rip_line[i]);
|
||||
XFontStruct *font = WindowFontStruct(w);
|
||||
int width = XTextWidth(font, rip_line[i], len);
|
||||
XDrawString(dpy, XtWindow(w), gc, x - width / 2, y, rip_line[i], len);
|
||||
x += appResources.tombtext_dx;
|
||||
y += appResources.tombtext_dy;
|
||||
}
|
||||
|
||||
XtReleaseGC(w, gc);
|
||||
@@ -590,30 +601,35 @@ create_ripout_widget(Widget parent)
|
||||
static int rip_width, rip_height;
|
||||
|
||||
if (!rip_image) {
|
||||
XpmAttributes attributes;
|
||||
int errorcode;
|
||||
XpmAttributes attributes;
|
||||
int errorcode;
|
||||
|
||||
attributes.valuemask = XpmCloseness;
|
||||
attributes.closeness = 65535; /* Try anything */
|
||||
errorcode = XpmReadFileToImage(XtDisplay(parent), appResources.tombstone, &rip_image, 0, &attributes);
|
||||
if (errorcode != XpmSuccess) {
|
||||
char buf[BUFSZ];
|
||||
Sprintf(buf, "Failed to load %s: %s", appResources.tombstone,
|
||||
XpmGetErrorString(errorcode));
|
||||
X11_raw_print(buf);
|
||||
}
|
||||
rip_width = rip_image->width;
|
||||
rip_height = rip_image->height;
|
||||
attributes.valuemask = XpmCloseness;
|
||||
attributes.closeness = 65535; /* Try anything */
|
||||
errorcode =
|
||||
XpmReadFileToImage(XtDisplay(parent), appResources.tombstone,
|
||||
&rip_image, 0, &attributes);
|
||||
if (errorcode != XpmSuccess) {
|
||||
char buf[BUFSZ];
|
||||
Sprintf(buf, "Failed to load %s: %s", appResources.tombstone,
|
||||
XpmGetErrorString(errorcode));
|
||||
X11_raw_print(buf);
|
||||
}
|
||||
rip_width = rip_image->width;
|
||||
rip_height = rip_image->height;
|
||||
}
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNwidth, rip_width); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, rip_height); num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, rip_width);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, rip_height);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNtranslations,
|
||||
XtParseTranslationTable(rip_translations)); num_args++;
|
||||
XtParseTranslationTable(rip_translations));
|
||||
num_args++;
|
||||
|
||||
imageport = XtCreateManagedWidget("rip", windowWidgetClass,
|
||||
parent, args, num_args);
|
||||
imageport = XtCreateManagedWidget("rip", windowWidgetClass, parent, args,
|
||||
num_args);
|
||||
|
||||
XtAddCallback(imageport, XtNexposeCallback, rip_exposed, (XtPointer) 0);
|
||||
|
||||
|
||||
+47
-43
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 winval.c $NHDT-Date: 1430899139 2015/05/06 07:58:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
|
||||
/* NetHack 3.6 winval.c $NHDT-Date: 1431192774 2015/05/09 17:32:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 winval.c $Date: 2009/05/06 10:56:06 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)winval.c 3.5 1992/3/7 */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef SYSV
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
@@ -21,59 +21,65 @@
|
||||
#include <X11/Xaw/Cardinals.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
# ifdef SYSV
|
||||
# undef SYSV
|
||||
# endif
|
||||
# undef PRESERVE_NO_SYSV
|
||||
#ifdef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "hack.h" /* #define for const for non __STDC__ compilers */
|
||||
#include "hack.h" /* #define for const for non __STDC__ compilers */
|
||||
#include "winX.h"
|
||||
|
||||
#define WNAME "name"
|
||||
#define WVALUE "value"
|
||||
|
||||
|
||||
Widget
|
||||
create_value(parent, name_value)
|
||||
Widget parent;
|
||||
const char *name_value;
|
||||
Widget parent;
|
||||
const char *name_value;
|
||||
{
|
||||
Widget form, name;
|
||||
Arg args[8];
|
||||
Cardinal num_args;
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++;
|
||||
form = XtCreateManagedWidget(name_value,
|
||||
formWidgetClass,
|
||||
parent, args, num_args);
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0);
|
||||
num_args++;
|
||||
form = XtCreateManagedWidget(name_value, formWidgetClass, parent, args,
|
||||
num_args);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNjustify, XtJustifyRight); num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
|
||||
XtSetArg(args[num_args], XtNlabel, name_value); num_args++;
|
||||
XtSetArg(args[num_args], XtNinternalHeight, 0); num_args++;
|
||||
name = XtCreateManagedWidget(WNAME,
|
||||
labelWidgetClass,
|
||||
form, args, num_args);
|
||||
XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNlabel, name_value);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNinternalHeight, 0);
|
||||
num_args++;
|
||||
name =
|
||||
XtCreateManagedWidget(WNAME, labelWidgetClass, form, args, num_args);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNjustify, XtJustifyRight); num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), name); num_args++;
|
||||
XtSetArg(args[num_args], XtNinternalHeight, 0); num_args++;
|
||||
(void) XtCreateManagedWidget(WVALUE,
|
||||
labelWidgetClass,
|
||||
form, args, num_args);
|
||||
XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), name);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNinternalHeight, 0);
|
||||
num_args++;
|
||||
(void) XtCreateManagedWidget(WVALUE, labelWidgetClass, form, args,
|
||||
num_args);
|
||||
return form;
|
||||
}
|
||||
|
||||
void
|
||||
set_name(w, new_label)
|
||||
Widget w;
|
||||
const char *new_label;
|
||||
Widget w;
|
||||
const char *new_label;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget name;
|
||||
@@ -85,8 +91,8 @@ set_name(w, new_label)
|
||||
|
||||
void
|
||||
set_name_width(w, new_width)
|
||||
Widget w;
|
||||
int new_width;
|
||||
Widget w;
|
||||
int new_width;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget name;
|
||||
@@ -98,7 +104,7 @@ set_name_width(w, new_width)
|
||||
|
||||
int
|
||||
get_name_width(w)
|
||||
Widget w;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[1];
|
||||
Dimension width;
|
||||
@@ -110,11 +116,10 @@ get_name_width(w)
|
||||
return (int) width;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_value(w, new_value)
|
||||
Widget w;
|
||||
const char *new_value;
|
||||
Widget w;
|
||||
const char *new_value;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget val;
|
||||
@@ -126,8 +131,8 @@ set_value(w, new_value)
|
||||
|
||||
void
|
||||
set_value_width(w, new_width)
|
||||
Widget w;
|
||||
int new_width;
|
||||
Widget w;
|
||||
int new_width;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget val;
|
||||
@@ -139,7 +144,7 @@ set_value_width(w, new_width)
|
||||
|
||||
int
|
||||
get_value_width(w)
|
||||
Widget w;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[1];
|
||||
Widget val;
|
||||
@@ -155,7 +160,7 @@ get_value_width(w)
|
||||
/* a label widget, unless I can get some init hook in there). */
|
||||
void
|
||||
hilight_value(w)
|
||||
Widget w;
|
||||
Widget w;
|
||||
{
|
||||
swap_fg_bg(XtNameToWidget(w, WVALUE));
|
||||
}
|
||||
@@ -163,7 +168,7 @@ hilight_value(w)
|
||||
/* Swap the foreground and background colors of the given widget */
|
||||
void
|
||||
swap_fg_bg(w)
|
||||
Widget w;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[2];
|
||||
Pixel fg, bg;
|
||||
@@ -176,4 +181,3 @@ swap_fg_bg(w)
|
||||
XtSetArg(args[1], XtNbackground, fg);
|
||||
XtSetValues(w, args, TWO);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user