On Mon, Nov 23, 2020 at 20:03, Stefan Haller <stefan@xxxxxxxxxxxxxxxx>
wrote:
+ 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".
+ %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.