From nobody Sat Mar 26 13:43:02 2022 X-Original-To: dev-commits-src-all@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 08DAB1A4656A; Sat, 26 Mar 2022 13:43:03 +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 4KQgBt6m4kz3KTt; Sat, 26 Mar 2022 13:43:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648302183; 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=0wRy4UUKr/CKGoeubqwVR+k4dkF4/zzRdfWugGjm/+Q=; b=Q+4oqTjygTRrHZPIGbJF0GOCSfnoh5GHU3jzs9qnwMbgVPGaz6qiJSkKTHYmZf0O/M3Fp4 N3VA+HuLBlnp2fmaIbwm4gi4srw588/J14dclvfpJSDpXN7lCrmlB5NPSoa4Gsb26PTndi VGHPN2TEKmHZmIIQ1ijyMnkqAVKiesWlY2SxdMWJx05ZNFdYIKHDMzXBm1Dftm/K7+yuYD n/hsxKKYgkOQxt4NKjZr8omi/CmHQqeIv8ZcpXVn/ncEVFGdDcDRaLnQ5AjNdR75BpzesZ xoDbDF+0rFdgMZpU1rMRSuvZimqeVKrdavCk3fQUKZcV5yEDYYaT5nYQYemZPg== 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 C8002220F2; Sat, 26 Mar 2022 13:43:02 +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 22QDh2e5074543; Sat, 26 Mar 2022 13:43:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22QDh2Xu074542; Sat, 26 Mar 2022 13:43:02 GMT (envelope-from git) Date: Sat, 26 Mar 2022 13:43:02 GMT Message-Id: <202203261343.22QDh2Xu074542@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: f50cda551150 - stable/13 - ls(1): Allow LSCOLORS to specify an underline List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f50cda551150dd1292548be2e0b2b052ec24613a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648302183; 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=0wRy4UUKr/CKGoeubqwVR+k4dkF4/zzRdfWugGjm/+Q=; b=rokDWLsQa1/6kjslUVI2F4295C9maTcgMrPTuRPZoSuRs1fgOQapkY6KLvbmiB+xzEZVBM pqdUC0Zc+H5scV+JeJpZgjJJ+M4mPzM8jweA3/iMKixnfTu/4LjKoFgCEADo6Ydn3qW44E GtY5mXBavcgFFNvkTgoEsqPQGKT7NZrOOCiftFN5O40kxfoU09V/tvP4wr/gZpjnq11AXN G2TbLFqK4g3ZaKSSayPXaeShX5Z/ClBDA4NajITr0Wwu4DrH7Ui2yaiSL6GMS+4YPqMS1v Yay47gWfcoO2mgaBnbkbLT1nod3iQNMw60hyw2PK8hQs3xsnf8/1tHEQVMLrpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648302183; a=rsa-sha256; cv=none; b=enVQFRjeJj7SO56hGVu7K9MZFXkNdYltrKgJG+iQTy6yUzZ4biuWxeeSmFO0ZvbIHeitwF crTJOZ3ITZB6zhDvARoUdr5MunSydhfSMVcYBod/bNQ8eKTIItJTX1DjaqpB/apSwJMld9 j0O7lxI777wNonQgm+uVyi8TkaLTxKzAdNtCX1Zr35vH9TwmbZFiSViJBv40zvAD7N+Fok E2gJOuYgt0CxJXcLQCuNZjZ2CHS5I0MUPXiFwLi1R3SOyZEyfXeIjmLybSoGibvT3QFodo 2t50Fz7OndrD2NWWvnRjkUFGwC03LnxsoqWcLNkh3sQOSI+HRho4YVeMr416pQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=f50cda551150dd1292548be2e0b2b052ec24613a commit f50cda551150dd1292548be2e0b2b052ec24613a Author: Cameron Katri AuthorDate: 2021-09-19 11:36:41 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2022-03-26 13:18:19 +0000 ls(1): Allow LSCOLORS to specify an underline Allows capitalizing the background color character to enable an underline instead of bold, capitalizing the foreground color char will still do bold. Differential Revision: https://reviews.freebsd.org/D30547 (cherry picked from commit 97c31821eb0b1180778ad2da660a1778c2cb4b62) --- bin/ls/extern.h | 1 + bin/ls/ls.1 | 19 +++++++++++-------- bin/ls/ls.c | 2 ++ bin/ls/print.c | 21 ++++++++++++++++----- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/bin/ls/extern.h b/bin/ls/extern.h index 8dab2bcc9d8c..247c2c4a1d5b 100644 --- a/bin/ls/extern.h +++ b/bin/ls/extern.h @@ -66,6 +66,7 @@ extern char *ansi_bgcol; extern char *ansi_coloff; extern char *attrs_off; extern char *enter_bold; +extern char *enter_underline; extern int colorflag; extern bool explicitansi; diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index 8510ca609cda..ef412dd2927d 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -740,6 +740,7 @@ where is the foreground color and .Ar b is the background color. +When the background color is capitalized, the text will underlined. .Pp The color designators are as follows: .Pp @@ -761,23 +762,25 @@ cyan .It Sy h light grey .It Sy A -bold black, usually shows up as dark grey +bold or underlined black, usually shows up as dark grey .It Sy B -bold red +bold or underlined red .It Sy C -bold green +bold or underlined green .It Sy D -bold brown, usually shows up as yellow +bold or underlined brown, usually shows up as yellow .It Sy E -bold blue +bold or underlined blue .It Sy F -bold magenta +bold or underlined magenta .It Sy G -bold cyan +bold or underlined cyan .It Sy H -bold light grey; looks like bright white +bold or underlined light grey; looks like bright white .It Sy x default foreground or background +.It Sy X +default foreground or background, with an underline or bold .El .Pp Note that the above are standard diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 92575711251d..8a30dd326b4e 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -159,6 +159,7 @@ char *ansi_fgcol; /* ANSI sequence to set foreground colour */ char *ansi_coloff; /* ANSI sequence to reset colours */ char *attrs_off; /* ANSI sequence to turn off attributes */ char *enter_bold; /* ANSI sequence to set color to bold mode */ +char *enter_underline; /* ANSI sequence to enter underline mode */ #endif static int rval; @@ -485,6 +486,7 @@ main(int argc, char *argv[]) ansi_bgcol = tgetstr("AB", &bp); attrs_off = tgetstr("me", &bp); enter_bold = tgetstr("md", &bp); + enter_underline = tgetstr("us", &bp); /* To switch colours off use 'op' if * available, otherwise use 'oc', or diff --git a/bin/ls/print.c b/bin/ls/print.c index 9a537418f7b9..bbe5c6f8a6f6 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -106,7 +106,8 @@ static const char *defcolors = "exfxcxdxbxegedabagacad"; /* colors for file types */ static struct { int num[2]; - int bold; + bool bold; + bool underline; } colors[C_NUMCOLORS]; #endif @@ -548,6 +549,8 @@ printcolor_termcap(Colors c) if (colors[c].bold) tputs(enter_bold, 1, putch); + if (colors[c].underline) + tputs(enter_underline, 1, putch); if (colors[c].num[0] != -1) { ansiseq = tgoto(ansi_fgcol, 0, colors[c].num[0]); @@ -569,6 +572,8 @@ printcolor_ansi(Colors c) if (colors[c].bold) printf("1"); + if (colors[c].underline) + printf(";4"); if (colors[c].num[0] != -1) printf(";3%d", colors[c].num[0]); if (colors[c].num[1] != -1) @@ -666,7 +671,8 @@ parsecolors(const char *cs) cs = ""; /* LSCOLORS not set */ len = strlen(cs); for (i = 0; i < (int)C_NUMCOLORS; i++) { - colors[i].bold = 0; + colors[i].bold = false; + colors[i].underline = false; if (len <= 2 * (size_t)i) { c[0] = defcolors[2 * i]; @@ -689,10 +695,15 @@ parsecolors(const char *cs) colors[i].num[j] = c[j] - 'a'; else if (c[j] >= 'A' && c[j] <= 'H') { colors[i].num[j] = c[j] - 'A'; - colors[i].bold = 1; - } else if (tolower((unsigned char)c[j]) == 'x') + if (j == 1) + colors[i].underline = true; + else + colors[i].bold = true; + } else if (tolower((unsigned char)c[j]) == 'x') { + if (j == 1 && c[j] == 'X') + colors[i].underline = true; colors[i].num[j] = -1; - else { + } else { warnx("invalid character '%c' in LSCOLORS" " env var", c[j]); colors[i].num[j] = -1;