Skip to content

Commit

Permalink
improv: show secondary labels only in multi-phase mode
Browse files Browse the repository at this point in the history
In that case the user has some time to recognize the type of label, but
in single-phase mode it seriously hurts the common case if one cannot
rely on the fact that any label is readily usable - having to process
two things simultaneously (the character and the highlighting style) is
simply too much friction.
  • Loading branch information
ggandor committed Jun 18, 2024
1 parent 24935d0 commit 2ec33f2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 41 deletions.
28 changes: 16 additions & 12 deletions fnl/leap/beacons.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@
" "
"")
label (or (. opts.substitute_chars target.label) target.label)
text (.. label pad)
relative-group (- target.group (or ?group-offset 0))
virttext
(if (= relative-group 1) [[text hl.group.label-primary]]
(= relative-group 2) [[text hl.group.label-secondary]]
(> relative-group 2)
(when (and ?phase (not opts.highlight_unlabeled_phase_one_targets))
; In this case, "no highlight" should unambiguously signal
; "no further keystrokes needed", so it is mandatory to
; show all labeled positions in some way. (Note: We're
; keeping this on even after phase one - sudden visual
; changes should be avoided as much as possible.)
[[(.. opts.concealed_label pad) hl.group.label-secondary]]))]
virttext (if (= relative-group 1)
[[(.. label pad) hl.group.label-primary]]

(= relative-group 2)
[[(if ?phase (.. label pad) (.. opts.concealed_label pad))
hl.group.label-secondary]]

(> relative-group 2)
(when (and ?phase (not opts.highlight_unlabeled_phase_one_targets))
; In this case, "no highlight" should unambiguously
; signal "no further keystrokes needed", so it is
; mandatory to show all labeled positions in some way.
; (Note: We're keeping this on even after phase one -
; sudden visual changes should be avoided as much as
; possible.)
[[(.. opts.concealed_label pad) hl.group.label-secondary]]))]
; Set nil too (= switching off a beacon).
(set target.beacon (when virttext [offset virttext]))))

Expand Down
63 changes: 34 additions & 29 deletions lua/leap/beacons.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ec33f2

Please sign in to comment.