]> granicus.if.org Git - nethack/commitdiff
Add full compass coordinate mode for screen readers
authorPasi Kallinen <paxed@alt.org>
Tue, 20 Sep 2016 15:36:03 +0000 (18:36 +0300)
committerPasi Kallinen <paxed@alt.org>
Tue, 20 Sep 2016 15:36:06 +0000 (18:36 +0300)
doc/Guidebook.mn
doc/Guidebook.tex
include/flag.h
src/do_name.c
src/options.c

index eef8ccc6a4184384cbfa67737e85719c4ffcf4c6..7e9340869fcc126f06d8c68744123e05c335c043 100644 (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]."
index 98218165e3227678520bfbed4d928a3f8a87dd2b..272e9e758abcc3d8bfef81ef19faf1df902a5f8e 100644 (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]#.
index 1f79f07dd6b178ce042b25dddada691d0d460e02..47139d3551b48b7bccf8e9514f83ee441f67f055 100644 (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 {
index 594cab44db56e7686731d4fa1d0eff29405dc9ec..11d9127c246ba19ecc9b0a977d69ae6de24206f8 100644 (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>;
index 225c4aa85803f508b7151a62d25b9b8811537d7a..6a0a0d10c5189ae5ab687243de8847c9c5a20293 100644 (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")) {