Add full compass coordinate mode for screen readers
This commit is contained in:
@@ -2698,6 +2698,7 @@ The possible settings are:
|
|||||||
.sd
|
.sd
|
||||||
.si
|
.si
|
||||||
.CC c "compass ('east' or '3s' or '2n,4w');"
|
.CC c "compass ('east' or '3s' or '2n,4w');"
|
||||||
|
.CC f "full compass ('east' or '3south' or '2north,4west');"
|
||||||
.CC m "map <x,y> (map column x=0 is not used);"
|
.CC m "map <x,y> (map column x=0 is not used);"
|
||||||
.CC s "screen [row,column] (row is offset to match tty usage);"
|
.CC s "screen [row,column] (row is offset to match tty usage);"
|
||||||
.CC n "none (no coordinates shown) [default]."
|
.CC n "none (no coordinates shown) [default]."
|
||||||
|
|||||||
@@ -3230,6 +3230,7 @@ The possible settings are:
|
|||||||
%.sd
|
%.sd
|
||||||
%.si
|
%.si
|
||||||
{\tt c} --- \verb#compass ('east' or '3s' or '2n,4w')#;\\
|
{\tt c} --- \verb#compass ('east' or '3s' or '2n,4w')#;\\
|
||||||
|
{\tt f} --- \verb#full compass ('east' or '3south' or '2north,4west')#;\\
|
||||||
{\tt m} --- \verb#map <x,y> (map column x=0 is not used)#;\\
|
{\tt m} --- \verb#map <x,y> (map column x=0 is not used)#;\\
|
||||||
{\tt s} --- \verb#screen [row,column] (row is offset to match tty usage)#;\\
|
{\tt s} --- \verb#screen [row,column] (row is offset to match tty usage)#;\\
|
||||||
{\tt n} --- \verb#none (no coordinates shown) [default]#.
|
{\tt n} --- \verb#none (no coordinates shown) [default]#.
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ struct sysflag {
|
|||||||
#define GPCOORDS_NONE 'n'
|
#define GPCOORDS_NONE 'n'
|
||||||
#define GPCOORDS_MAP 'm'
|
#define GPCOORDS_MAP 'm'
|
||||||
#define GPCOORDS_COMPASS 'c'
|
#define GPCOORDS_COMPASS 'c'
|
||||||
|
#define GPCOORDS_COMFULL 'f'
|
||||||
#define GPCOORDS_SCREEN 's'
|
#define GPCOORDS_SCREEN 's'
|
||||||
|
|
||||||
struct instance_flags {
|
struct instance_flags {
|
||||||
|
|||||||
@@ -232,11 +232,11 @@ int gloc;
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
dxdy_to_dist_descr(dx, dy)
|
dxdy_to_dist_descr(dx, dy, fulldir)
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
boolean fulldir;
|
||||||
{
|
{
|
||||||
/* [12] suffices, but guard against long translation for direction-name */
|
static char buf[30];
|
||||||
static char buf[20];
|
|
||||||
int dst;
|
int dst;
|
||||||
|
|
||||||
if (!dx && !dy) {
|
if (!dx && !dy) {
|
||||||
@@ -245,18 +245,23 @@ int dx, dy;
|
|||||||
/* explicit direction; 'one step' is implicit */
|
/* explicit direction; 'one step' is implicit */
|
||||||
Sprintf(buf, "%s", directionname(dst));
|
Sprintf(buf, "%s", directionname(dst));
|
||||||
} else {
|
} else {
|
||||||
|
const char *dirnames[4][2] = {
|
||||||
|
{ "n", "north" },
|
||||||
|
{ "s", "south" },
|
||||||
|
{ "w", "west" },
|
||||||
|
{ "e", "east" } };
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
/* 9999: protect buf[] against overflow caused by invalid values */
|
/* 9999: protect buf[] against overflow caused by invalid values */
|
||||||
if (dy) {
|
if (dy) {
|
||||||
if (abs(dy) > 9999)
|
if (abs(dy) > 9999)
|
||||||
dy = sgn(dy) * 9999;
|
dy = sgn(dy) * 9999;
|
||||||
Sprintf(eos(buf), "%d%c%s", abs(dy), (dy > 0) ? 's' : 'n',
|
Sprintf(eos(buf), "%d%s%s", abs(dy), dirnames[(dy > 0)][fulldir],
|
||||||
dx ? "," : "");
|
dx ? "," : "");
|
||||||
}
|
}
|
||||||
if (dx) {
|
if (dx) {
|
||||||
if (abs(dx) > 9999)
|
if (abs(dx) > 9999)
|
||||||
dx = sgn(dx) * 9999;
|
dx = sgn(dx) * 9999;
|
||||||
Sprintf(eos(buf), "%d%c", abs(dx), (dx > 0) ? 'e' : 'w');
|
Sprintf(eos(buf), "%d%s", abs(dx), dirnames[2 + (dx > 0)][fulldir]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
@@ -275,11 +280,13 @@ char *outbuf, cmode;
|
|||||||
switch (cmode) {
|
switch (cmode) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
case GPCOORDS_COMFULL:
|
||||||
case GPCOORDS_COMPASS:
|
case GPCOORDS_COMPASS:
|
||||||
/* "east", "3s", "2n,4w" */
|
/* "east", "3s", "2n,4w" */
|
||||||
dx = x - u.ux;
|
dx = x - u.ux;
|
||||||
dy = y - u.uy;
|
dy = y - u.uy;
|
||||||
Sprintf(outbuf, "(%s)", dxdy_to_dist_descr(dx, dy));
|
Sprintf(outbuf, "(%s)",
|
||||||
|
dxdy_to_dist_descr(dx, dy, cmode == GPCOORDS_COMFULL));
|
||||||
break;
|
break;
|
||||||
case GPCOORDS_MAP: /* x,y */
|
case GPCOORDS_MAP: /* x,y */
|
||||||
/* upper left corner of map is <1,0>;
|
/* upper left corner of map is <1,0>;
|
||||||
|
|||||||
@@ -2362,7 +2362,8 @@ boolean tinitial, tfrom_file;
|
|||||||
return;
|
return;
|
||||||
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
|
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
|
||||||
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
|
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
|
||||||
GPCOORDS_MAP, GPCOORDS_SCREEN, '\0' };
|
GPCOORDS_COMFULL, GPCOORDS_MAP,
|
||||||
|
GPCOORDS_SCREEN, '\0' };
|
||||||
char c = lowc(*op);
|
char c = lowc(*op);
|
||||||
|
|
||||||
if (c && index(gpcoords, c))
|
if (c && index(gpcoords, c))
|
||||||
@@ -4104,6 +4105,10 @@ boolean setinitial, setfromfile;
|
|||||||
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
|
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
|
||||||
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
|
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
|
||||||
(gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED);
|
(gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED);
|
||||||
|
any.a_char = GPCOORDS_COMFULL;
|
||||||
|
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMFULL,
|
||||||
|
0, ATR_NONE, "full compass ('east' or '3south' or '2north,4west')",
|
||||||
|
(gp == GPCOORDS_COMFULL) ? MENU_SELECTED : MENU_UNSELECTED);
|
||||||
any.a_char = GPCOORDS_MAP;
|
any.a_char = GPCOORDS_MAP;
|
||||||
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
|
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
|
||||||
0, ATR_NONE, "map <x,y>",
|
0, ATR_NONE, "map <x,y>",
|
||||||
@@ -4917,6 +4922,7 @@ char *buf;
|
|||||||
Sprintf(buf, "%s",
|
Sprintf(buf, "%s",
|
||||||
(iflags.getpos_coords == GPCOORDS_MAP) ? "map"
|
(iflags.getpos_coords == GPCOORDS_MAP) ? "map"
|
||||||
: (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass"
|
: (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass"
|
||||||
|
: (iflags.getpos_coords == GPCOORDS_COMFULL) ? "full compass"
|
||||||
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
|
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
|
||||||
: "none");
|
: "none");
|
||||||
} else if (!strcmp(optname, "scores")) {
|
} else if (!strcmp(optname, "scores")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user