From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 7F2C91F4B4 for ; Fri, 18 Dec 2020 13:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727153AbgLRNBz (ORCPT ); Fri, 18 Dec 2020 08:01:55 -0500 Received: from dd36226.kasserver.com ([85.13.153.21]:37516 "EHLO dd36226.kasserver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727149AbgLRNBz (ORCPT ); Fri, 18 Dec 2020 08:01:55 -0500 Received: from client3368.fritz.box (i5C747512.versanet.de [92.116.117.18]) by dd36226.kasserver.com (Postfix) with ESMTPSA id A39F73C01D9; Fri, 18 Dec 2020 14:01:11 +0100 (CET) Subject: Re: [PATCH v2] git-gui: use gray background for inactive text widgets To: Pratyush Yadav Cc: serg.partizan@gmail.com, git@vger.kernel.org References: <55348fbb-95bb-1dd2-4e17-4fc622ae7603@haller-berlin.de> <20201124212333.80040-1-stefan@haller-berlin.de> <20201217214912.ycp7bidcyqwzslxy@yadavpratyush.com> <63356203-8af0-64e5-4694-f47d31bcdee6@haller-berlin.de> <20201218125025.gj277jwxrblqp45b@yadavpratyush.com> From: Stefan Haller Message-ID: <90975583-17ad-0d53-5919-fe1c8400291c@haller-berlin.de> Date: Fri, 18 Dec 2020 14:01:11 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20201218125025.gj277jwxrblqp45b@yadavpratyush.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 18.12.20 13:50, Pratyush Yadav wrote: > On 17/12/20 11:14PM, Stefan Haller wrote: >> On 17.12.20 22:49, Pratyush Yadav wrote: >>> Hi, >>> >>> On 24/11/20 10:23PM, Stefan Haller wrote>>>> +proc convert_rgb_to_gray {rgb} { >>>> + # Simply take the average of red, green and blue. This wouldn't be good >>>> + # enough for, say, converting a photo to grayscale, but for this simple >>>> + # purpose of approximating the brightness of a color it's good enough. >>>> + lassign [winfo rgb . $rgb] r g b >>> >>> Is there no simpler way to extract r, g, and b? This is a little cryptic >>> to be honest. >> >> Actually, I find this pretty elegant, and from what I have seen, it's >> idiomatic Tcl. A less cryptic way would be (untested): >> >> set components [winfo rgb . $rgb] >> set r [lindex $components 0] >> set g [lindex $components 1] >> set b [lindex $components 2] >> >> But I much prefer the one-line version. > > I agree. Using lassign is much neater. But that is not my point. I am > talking about the "[winfo rgb . $rgb]". This call generates the list > that is then assigned to the 3 variables. This part is a little cryptic. > Is there no simpler way to separate out the r, g, and b values? According to the winfo man page this is the only way to do this; see [1]. Instead of the lassign, you can also do foreach {r g b} [winfo rgb . $rgb] {} but I don't think that's better. -Stefan [1] https://www.tcl.tk/man/tcl8.6/TkCmd/winfo.htm