Add full compass coordinate mode for screen readers

This commit is contained in:
Pasi Kallinen
2016-09-20 18:36:03 +03:00
parent 723edd9af9
commit 28e36b3136
5 changed files with 23 additions and 7 deletions

View File

@@ -2698,6 +2698,7 @@ The possible settings are:
.sd
.si
.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 s "screen [row,column] (row is offset to match tty usage);"
.CC n "none (no coordinates shown) [default]."

View File

@@ -3230,6 +3230,7 @@ The possible settings are:
%.sd
%.si
{\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 s} --- \verb#screen [row,column] (row is offset to match tty usage)#;\\
{\tt n} --- \verb#none (no coordinates shown) [default]#.

View File

@@ -173,6 +173,7 @@ struct sysflag {
#define GPCOORDS_NONE 'n'
#define GPCOORDS_MAP 'm'
#define GPCOORDS_COMPASS 'c'
#define GPCOORDS_COMFULL 'f'
#define GPCOORDS_SCREEN 's'
struct instance_flags {

View File

@@ -232,11 +232,11 @@ int gloc;
}
char *
dxdy_to_dist_descr(dx, dy)
dxdy_to_dist_descr(dx, dy, fulldir)
int dx, dy;
boolean fulldir;
{
/* [12] suffices, but guard against long translation for direction-name */
static char buf[20];
static char buf[30];
int dst;
if (!dx && !dy) {
@@ -245,18 +245,23 @@ int dx, dy;
/* explicit direction; 'one step' is implicit */
Sprintf(buf, "%s", directionname(dst));
} else {
const char *dirnames[4][2] = {
{ "n", "north" },
{ "s", "south" },
{ "w", "west" },
{ "e", "east" } };
buf[0] = '\0';
/* 9999: protect buf[] against overflow caused by invalid values */
if (dy) {
if (abs(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 ? "," : "");
}
if (dx) {
if (abs(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;
@@ -275,11 +280,13 @@ char *outbuf, cmode;
switch (cmode) {
default:
break;
case GPCOORDS_COMFULL:
case GPCOORDS_COMPASS:
/* "east", "3s", "2n,4w" */
dx = x - u.ux;
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;
case GPCOORDS_MAP: /* x,y */
/* upper left corner of map is <1,0>;

View File

@@ -2362,7 +2362,8 @@ boolean tinitial, tfrom_file;
return;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
GPCOORDS_MAP, GPCOORDS_SCREEN, '\0' };
GPCOORDS_COMFULL, GPCOORDS_MAP,
GPCOORDS_SCREEN, '\0' };
char c = lowc(*op);
if (c && index(gpcoords, c))
@@ -4104,6 +4105,10 @@ boolean setinitial, setfromfile;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
(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;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
0, ATR_NONE, "map <x,y>",
@@ -4917,6 +4922,7 @@ char *buf;
Sprintf(buf, "%s",
(iflags.getpos_coords == GPCOORDS_MAP) ? "map"
: (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass"
: (iflags.getpos_coords == GPCOORDS_COMFULL) ? "full compass"
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
: "none");
} else if (!strcmp(optname, "scores")) {