Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst Fix display of timezone selection menu



details:   https://anonhg.NetBSD.org/src/rev/ffc4be7115ea
branches:  trunk
changeset: 1014629:ffc4be7115ea
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Sep 27 17:36:40 2020 +0000

description:
Fix display of timezone selection menu

diffstat:

 usr.sbin/sysinst/msg.mi.fr |   4 +-
 usr.sbin/sysinst/util.c    |  47 +++++++++++++++++++++++++++++++--------------
 2 files changed, 34 insertions(+), 17 deletions(-)

diffs (116 lines):

diff -r 016e03715a2e -r ffc4be7115ea usr.sbin/sysinst/msg.mi.fr
--- a/usr.sbin/sysinst/msg.mi.fr        Sun Sep 27 17:27:07 2020 +0000
+++ b/usr.sbin/sysinst/msg.mi.fr        Sun Sep 27 17:36:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.28 2020/05/26 15:20:45 snj Exp $ */
+/*     $NetBSD: msg.mi.fr,v 1.29 2020/09/27 17:36:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -999,7 +999,7 @@
 Appuyez sur "x" puis sur Entrée pour valider la sélection en cours.
 
  Par défaut :          %s
- Sélection actuelle : %s
+ Sélection actuelle :   %s
  Heure locale :                %s %s
 }
 
diff -r 016e03715a2e -r ffc4be7115ea usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Sun Sep 27 17:27:07 2020 +0000
+++ b/usr.sbin/sysinst/util.c   Sun Sep 27 17:36:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.46 2020/09/22 16:18:54 martin Exp $ */
+/*     $NetBSD: util.c,v 1.47 2020/09/27 17:36:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1343,6 +1343,26 @@
 const char *tz_default;                /* UTC, or whatever /etc/localtime points to */
 static char tz_env[STRSIZE];
 static int save_cursel, save_topline;
+static int time_menu = -1;
+
+static void
+update_time_display(void)
+{
+       time_t t;
+       struct tm *tm;
+       char cur_time[STRSIZE], *p;
+
+       t = time(NULL);
+       tm = localtime(&t);
+       strlcpy(cur_time, safectime(&t), sizeof cur_time);
+       p = strchr(cur_time, '\n');
+       if (p != NULL)
+               *p = 0;
+
+       msg_clear();
+       msg_fmt_table_add(MSG_choose_timezone, "%s%s%s%s",
+           tz_default, tz_selected, cur_time, tm ? tm->tm_zone : "?");
+}
 
 /*
  * Callback from timezone menu
@@ -1350,9 +1370,7 @@
 static int
 set_tz_select(menudesc *m, void *arg)
 {
-       time_t t;
        char *new;
-       struct tm *tm;
 
        if (m && strcmp(tz_selected, m->opts[m->cursel].opt_name) != 0) {
                /* Change the displayed timezone */
@@ -1369,12 +1387,14 @@
                /* Warp curser to 'Exit' line on menu */
                m->cursel = -1;
 
-       /* Update displayed time */
-       t = time(NULL);
-       tm = localtime(&t);
-       msg_fmt_display(MSG_choose_timezone, "%s%s%s%s",
-                   tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone :
-                   "?");
+       update_time_display();
+       if (time_menu >= 1) {
+               WINDOW *w = get_menudesc(time_menu)->mw;
+               if (w != NULL) {
+                       touchwin(w);
+                       wrefresh(w);
+               }
+       }
        return 0;
 }
 
@@ -1529,8 +1549,6 @@
 {
        char localtime_link[STRSIZE];
        char localtime_target[STRSIZE];
-       time_t t;
-       struct tm *tm;
        int menu_no;
 
        strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"),
@@ -1542,10 +1560,7 @@
        tz_selected = strdup(tz_default);
        snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected);
        setenv("TZ", tz_env, 1);
-       t = time(NULL);
-       tm = localtime(&t);
-       msg_fmt_display(MSG_choose_timezone, "%s%s%s%s",
-           tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone : "?");
+       update_time_display();
 
        signal(SIGALRM, timezone_sig);
        alarm(60);
@@ -1558,7 +1573,9 @@
        if (menu_no < 0)
                goto done;      /* error - skip timezone setting */
 
+       time_menu = menu_no;
        process_menu(menu_no, NULL);
+       time_menu = -1;
 
        free_menu(menu_no);
 



Home | Main Index | Thread Index | Old Index