tFunction added to display a centred string. This uses the actual width of the display window (rather than using a hard-coded value of 80) and deals properly with the case where the string is longer than the width (previously this would result in a negative x-coordinate, and curses would refuse to display the string at all, causing problems with the nn translation). - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit b4c9032023e7a52edd98b6223ed1fabc91210514
 (DIR) parent 2b187d1cd09162f12318d323d308ab1f54e9a6ca
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Mon, 24 Jun 2002 11:04:47 +0000
       
       Function added to display a centred string. This uses the actual width of
       tthe display window (rather than using a hard-coded value of 80) and deals
       properly with the case where the string is longer than the width (previously
       tthis would result in a negative x-coordinate, and curses would refuse to
       display the string at all, causing problems with the nn translation).
       
       
       Diffstat:
         M src/curses_client/curses_client.c   |      20 ++++++++++++++++----
       
       1 file changed, 16 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_client.c
       t@@ -181,6 +181,18 @@ static void LogMessage(const gchar *log_domain, GLogLevelFlags log_level,
          clear_bottom();
        }
        
       +/*
       + * Displays a string, horizontally centred on the given row
       + */
       +static void mvaddcentstr(const int row, const gchar *str)
       +{
       +  int col;
       +
       +  col = (Width - strlen(str)) / 2;
       +  col = MAX(col, 0);
       +  mvaddstr(row, col, str);
       +}
       +
        /* 
         * Displays a dopewars introduction screen.
         */
       t@@ -1306,7 +1318,7 @@ void GunShop(Player *Play)
            text = _("Will you B>uy, S>ell, or L>eave? ");
            attrset(PromptAttr);
            clear_line(22);
       -    mvaddstr(22, 40 - strlen(text) / 2, text);
       +    mvaddcentstr(22, text);
            attrset(TextAttr);
        
            /* Translate these three keys in line with the above options, keeping
       t@@ -2140,7 +2152,7 @@ static void Curses_DoGame(Player *Play)
                g_string_append(text, _(", J>et"));
              }
              g_string_append(text, _(", or Q>uit? "));
       -      mvaddstr(22, 40 - strlen(text->str) / 2, text->str);
       +      mvaddcentstr(22, text->str);
              attrset(TextAttr);
              curs_set(1);
              break;
       t@@ -2162,7 +2174,7 @@ static void Curses_DoGame(Player *Play)
                /* (%tde = "drugs" by default here) */
                dpg_string_sprintfa(text, _("D>eal %tde, "), Names.Drugs);
              g_string_append(text, _("or Q>uit? "));
       -      mvaddstr(22, 40 - strlen(text->str) / 2, text->str);
       +      mvaddcentstr(22, text->str);
              attrset(TextAttr);
              curs_set(1);
              break;
       t@@ -2175,7 +2187,7 @@ static void Curses_DoGame(Player *Play)
              g_string_append(text, Names.Drugs);
              g_string_append(text, ", or Q>uit? ");
              attrset(PromptAttr);
       -      mvaddstr(22, 40 - strlen(text->str) / 2, text->str);
       +      mvaddcentstr(22, text->str);
              attrset(TextAttr);
              curs_set(1);
              break;