Re: [PATCH] git-gui: use gray selection background for inactive text widgets
- From
serg.partizan@gmail.com <serg.partizan@gmail.com>
- Date
- Nov 23, 2020, 20:08 UTC
- Message-ID
- <HLM9KQ.QZTOWNY8EICB1@gmail.com>
- In-Reply-To
- <23d6eb6c-4c7b-b9dd-d0df-fe0feaa0dc17@haller-berlin.de>
On Mon, Nov 23, 2020 at 20:03, Stefan Haller <stefan@haller-berlin.de> wrote:
Show 17 quoted lines
>>> + bind $i <FocusIn> {
>>> + foreach tag [list in_diff in_sel] {
>>> + %W tag conf $tag \
>>> + -background $color::select_bg \
>>> + -foreground $color::select_fg
>>> + }
>>> + }
>>> + bind $i <FocusOut> {
>>> + foreach tag [list in_diff in_sel] {
>>
>> This two `foreach` can be combined into one?
>
> I don't see how; any concrete suggestions? But I have other ideas how
> to
> simplify the code (by using one function set_selection_colors that
> takes
> a has_focus bool and is used for both bindings).I tried to do this, and now i understand why my suggestion was wrong, i was looking at this as "cycle inside cycle", but it's actually "cycle inside event handler".
Show 9 quoted lines
>
>>> + %W tag conf $tag \
>>
>> And this `%W`, probably should be `$i`?
>
> No, $i wouldn't work because we're inside curly braces, so $i wouldn't
> get expanded. It would be possible to work around this by using ""
> instead of {}, but why? Using %W seems to be the idiomatic way in
> bindings, we do this everywhere else too.Oh, now i see it's used in the same way in other places!
> %W The path name of the window to which the event was reported (the window field from the event).
Now I understand it.