X11 extcmd_height_delta resourse

Umpteenth revision of the X11 extended command menu.  Add a new
resource to NetHack.ad to control its initial size.

I still hope there's a better way to do this, but this is my last
shot at it.
This commit is contained in:
PatR
2016-03-04 00:13:23 -08:00
parent db9dddc535
commit ef9cd17942
5 changed files with 28 additions and 26 deletions

View File

@@ -251,6 +251,11 @@ unix: add CHECK_PLNAME-option to sysconf to make WIZARDS, EXPLORERS, and
X11: new NetHack*highlight_prompt resource to control whether the persistent
prompt line between the map and message windows for the NetHack*slow
configuration will be highlighted when it's expecting input
X11: NetHack*extcmd_height_delta resource can be used to adjust initial size
of the extended commands menu
X11: status display split into three columns to accomodate Stone/Deaf/Lev/&c;
NetHack*status_condition.foreground, .background, and .showGrip
resources replaced by status_condition[1-3].*
NetHack Community Patches (or Variation) Included

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 winX.h $NHDT-Date: 1454977916 2016/02/09 00:31:56 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.22 $ */
/* NetHack 3.6 winX.h $NHDT-Date: 1457079196 2016/03/04 08:13:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.23 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -252,6 +252,7 @@ typedef struct {
String tile_file; /* name of file to open for tiles */
String icon; /* name of desired icon */
int message_lines; /* number of lines to attempt to show */
int extcmd_height_delta; /* bottom margin for extended command menu */
String pet_mark_bitmap; /* X11 bitmap file used to mark pets */
Pixel pet_mark_color; /* color of pet mark */
String pilemark_bitmap; /* X11 bitmap file used to mark item piles */

View File

@@ -1,4 +1,4 @@
! $NHDT-Date: 1454977917 2016/02/09 00:31:57 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $
! $NHDT-Date: 1457079198 2016/03/04 08:13:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.11 $
! The display_file, tombstone, and menu windows are all formatted assuming
! a fixed width font. Text windows may or may not be formatted as above.
@@ -188,6 +188,15 @@ NetHack*extended_commands*help.accelerators: #override\n\
:<Key>?: set() notify() unset()
NetHack*extended_commands*dismiss.accelerators: #override\n\
<Key>Escape: set() notify() unset()
!
! The extended command menu may be too big to fit on the screen so need
! a vertical scroll bar. When truncated, its height will be as tall as
! possible unless height_delta is non-zero, in which case there will be
! that many pixels of margin left unused. On OSX, this can be used to
! avoid overlapping with the desktop docking tray to prevent that from
! obscuring the bottom of the menu.
NetHack*extcmd_height_delta: 75
!
!
! The following are the default 15 colors that the nethack map uses.

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 winX.c $NHDT-Date: 1455389907 2016/02/13 18:58:27 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.40 $ */
/* NetHack 3.6 winX.c $NHDT-Date: 1457079197 2016/03/04 08:13:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.41 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -1064,6 +1064,9 @@ static XtResource resources[] = {
XtOffset(AppResources *, icon), XtRString, nhStr("nh72") },
{ nhStr("message_lines"), nhStr("Message_lines"), XtRInt, sizeof(int),
XtOffset(AppResources *, message_lines), XtRString, nhStr("12") },
{ nhStr("extcmd_height_delta"), nhStr("Extcmd_height_delta"),
XtRInt, sizeof (int),
XtOffset(AppResources *, extcmd_height_delta), XtRString, nhStr("0") },
{ nhStr("pet_mark_bitmap"), nhStr("Pet_mark_bitmap"), XtRString,
sizeof(String), XtOffset(AppResources *, pet_mark_bitmap), XtRString,
nhStr("pet_mark.xbm") },

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 winmisc.c $NHDT-Date: 1455526714 2016/02/15 08:58:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.24 $ */
/* NetHack 3.6 winmisc.c $NHDT-Date: 1457079197 2016/03/04 08:13:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.25 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -1199,36 +1199,20 @@ Widget *formp; /* return */
else
free((char *) commands);
/*
* We actually want height of topmost background window, which
* may or may not be the root window.
*
* On OSX, screen height includes the space taken up by the
* desktop title bar, which isn't accessible to applications
* unless the preference settings for X11 are changed to force
* full-screen mode (so by default, this 'screen_height' value
* ends up being bigger than the available size...).
*/
screen_height = XHeightOfScreen(XtScreen(popup));
/*
* If the menu's complete height is too big for the display,
* forcing the height to be smaller will cause the vertical
* scroll bar (enabled but not forced above) to be included.
*/
screen_height = XHeightOfScreen(XtScreen(popup));
screen_height -= appResources.extcmd_height_delta; /* NetHack.ad */
if (cumulative_height >= screen_height) {
/* trial and error:
25 is a guesstimate for scrollbar width on width adjustment;
75 is for cumulative height of 3 title bars (desktop,
application, and popup) on height adjustment; that will be
bigger than needed if the popup can overlap the application's
title bar or if there is no desktop title bar; this ought to
be deriveable on the fly, or at least user-controlled by a
resource, but for now it's hardcoded--user can manually
resize if sufficiently motivated... */
/* 25 is a guesstimate for scrollbar width;
window manager might override the request for y==1 */
num_args = 0;
XtSetArg(args[num_args], XtNy, 1); num_args++;
XtSetArg(args[num_args], XtNwidth, max_width + 25); num_args++;
XtSetArg(args[num_args], XtNheight, screen_height - 75); num_args++;
XtSetArg(args[num_args], XtNheight, screen_height - 1); num_args++;
XtSetValues(popup, args, num_args);
}
XtRealizeWidget(popup);