From nobody Mon Dec 13 08:10:41 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B7CD018DE02F; Mon, 13 Dec 2021 08:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JCDhx2dyzz3lwd; Mon, 13 Dec 2021 08:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2DDA710D6E; Mon, 13 Dec 2021 08:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BD8Afx3083892; Mon, 13 Dec 2021 08:10:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BD8Afo4083891; Mon, 13 Dec 2021 08:10:41 GMT (envelope-from git) Date: Mon, 13 Dec 2021 08:10:41 GMT Message-Id: <202112130810.1BD8Afo4083891@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 0a7e19b30fc0 - main - tzsetup: adapt for libbsddialog 0.0.1 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a7e19b30fc0e34e7f3536df0fa64aff23955772 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639383041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=COeyjj63vzYc5AUlL1JQsFHNuZgDU2NjsJPSnVwMIAQ=; b=PFo3XN2nFUfXQew1P1E2mgEKjSzb0xuRh6A+yNETOY1WboqFubcZzFxeOcOOKkJRaRwcub BHkCaSRIcSdscBMzFZ9eiYTNWd7gKami3uK8KWKW19gX7sK+tCRnSGuHM62XN2TsR83eCc /UKN4ytWVANsxPZNEFjZh+PML6Xwgkvf9AZnwvxFNLPBbuYR3eqNcI/3ylZqDBr10I/+xE GmKMau+mXMvWiRn2nCTQz16S7adEm2Apal+AqCfBORYmtYpMcXN+yp+0VYoUWaq+Rztnde Jaoo6A9lGIgysD6lqIuIGzlhyKuclus+Sf5Z4kifDdngQL4s3qcItZhK6MglQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639383041; a=rsa-sha256; cv=none; b=e5060XtgbslKbPaUUf5J1l6IV3obSBBjCWcoouJHVLwy7pRvxXh53bfTxKwgMmmR7hJdNY mHmMFivelxSGZQRd7B2L1NjFnkEmAKiv1iTXvAxoBUOFVhMmJFKZ49FUNgwUX7kt5TZ+ff +packvieN+vjk5B5O+ih3vkghL/R+jbkP1ykuHhfyrvWwI/SlqUPpKBVCMrl5KSz5aiom7 J+9vGRhP3exPk8Gscj+64ZpPuATDC1H+q6S53rgVbjesOjymPXm/VK61quZEumqN+T5E45 DQ28ja48w3woooDi6/tkyniE8g/4VxYDqbJOFAkKHEyT/ALg1cNzq54X+SSGTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=0a7e19b30fc0e34e7f3536df0fa64aff23955772 commit 0a7e19b30fc0e34e7f3536df0fa64aff23955772 Author: Alfonso Siciliano AuthorDate: 2021-12-13 08:03:40 +0000 Commit: Baptiste Daroussin CommitDate: 2021-12-13 08:07:47 +0000 tzsetup: adapt for libbsddialog 0.0.1 libbsdialog 0.0.1 provides: * bsddialog_conf.auto_minwidth: * menurows is variable with autosize (properly defines max menurows) Then tzsetup can use BSDDIALOG_AUTOSIZE keeping the dialog behavior: min 24 cols, max 16 menurows Differential revision: https://reviews.freebsd.org/D33397 --- usr.sbin/tzsetup/tzsetup.c | 63 +++++----------------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index 89623293e5ea..d271d6377347 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -97,38 +97,6 @@ typedef struct dialogMenuItem { void *data; } dialogMenuItem; -static int -xdialog_count_rows(const char *p) -{ - int rows = 0; - - while ((p = strchr(p, '\n')) != NULL) { - p++; - if (*p == '\0') - break; - rows++; - } - - return (rows ? rows : 1); -} - -static int -xdialog_count_columns(const char *p) -{ - int len; - int max_len = 0; - const char *q; - - for (; (q = strchr(p, '\n')) != NULL; p = q + 1) { - len = q - p; - max_len = MAX(max_len, len); - } - - len = strlen(p); - max_len = MAX(max_len, len); - return (max_len); -} - static int xdialog_menu(char *title, char *cprompt, int height, int width, int menu_height, int item_no, dialogMenuItem *ditems) @@ -149,32 +117,13 @@ xdialog_menu(char *title, char *cprompt, int height, int width, listitems[i].desc = ditems[i].title; } - /* calculate height */ if (height < 0) - height = xdialog_count_rows(cprompt) + menu_height + 4 + 2; - if (height > bsddialog_terminalheight()) - height = bsddialog_terminalheight() - 2; + height = BSDDIALOG_AUTOSIZE; - /* calculate width */ if (width < 0) { - int tag_x = 0; - - for (i = 0; i < item_no; i++) { - int j, l; - - l = strlen(listitems[i].name); - for (j = 0; j < item_no; j++) { - int k = strlen(listitems[j].desc); - tag_x = MAX(tag_x, l + k + 2); - } - } - width = MAX(xdialog_count_columns(cprompt), title != NULL ? - xdialog_count_columns(title) : 0); - width = MAX(width, tag_x + 4) + 4; + width = BSDDIALOG_AUTOSIZE; + conf.auto_minwidth = 24; } - width = MAX(width, 24); - if (width > bsddialog_terminalwidth()) - width = bsddialog_terminalwidth() - 3; again: conf.menu.default_item = listitems[choice].name; @@ -188,7 +137,7 @@ again: case BSDDIALOG_ESC: result = -1; break; - case BSDDIALOG_YESOK: + case BSDDIALOG_OK: if (ditems[choice].fire != NULL) { int status; @@ -199,7 +148,7 @@ again: } result = 0; break; - case BSDDIALOG_NOCANCEL: + case BSDDIALOG_CANCEL: default: result = 1; break; @@ -1028,7 +977,7 @@ main(int argc, char **argv) "If it is set to local time,\n" "or you don't know, please choose NO here!"); - conf.button.defaultno = false; + conf.button.default_cancel = false; conf.title = "Select local or UTC (Greenwich Mean Time) clock"; yesno = bsddialog_yesno(&conf, prompt, 7, 73); if (!yesno) {