From 345c2e1cb675ca456d3f2e85bd205b32110e9722 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 2 Dec 2022 01:40:54 -0800 Subject: [PATCH] farlook /[mMoO] feedback When /m or /M or /o or /O shows monsters or objects with locations displayed as map coordinates, make those line up by their commas. Old | <8,9> $ gold pieces | <10,10> * rocks | <9,12> % newt corpse New | <8, 9> $ gold pieces | <10,10> * rocks | <9,12> % newt corpse (The data is gathered by row so implicitly sorted by y.) If someone is crazy enough to set ROWNO to three digits, values will only line up by the comma when all values have row less than 100 or all are 100+. Setting COLNO to three digits isn't an issue unless the total witdh of "<" + xxx + "," + yy ">" is more than 8 (which would push object class letter and object description one or more extra columns to the right, messing up overall alignment but still showing accurate data). --- src/pager.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pager.c b/src/pager.c index 123f67e9b..aba563b5e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1719,11 +1719,21 @@ look_all( in a fixed-width font it if finds at least one */ putstr(win, 0, " "); /* separator */ } + (void) coord_desc(x, y, coordbuf, cmode); + /* this format wrinkle makes the commas of line up; + it isn't needed when all the y values have same number + of digits but looks better when there is a mixture of 1 + and 2 digit values; done unconditionally because we + would need two passes over the map to determine whether + y width is uniform or a mixture; x width is not a factor + because the result gets right-justified by %8s */ + if (cmode == GPCOORDS_MAP && y < 10) + (void) strsubst(coordbuf, ",", ", "); /* prefix: "coords C " where 'C' is mon or obj symbol */ Sprintf(outbuf, (cmode == GPCOORDS_SCREEN) ? "%s " : (cmode == GPCOORDS_MAP) ? "%8s " : "%12s ", - coord_desc(x, y, coordbuf, cmode)); + coordbuf); Sprintf(eos(outbuf), "%s ", encglyph(glyph)); /* guard against potential overflow */ lookbuf[sizeof lookbuf - 1 - strlen(outbuf)] = '\0';