Skip to content

Add FiraCode progress bars glyphs support - #236

Merged
cheggaaa merged 4 commits into
cheggaaa:masterfrom
asciimoth:master
Jul 14, 2026
Merged

Add FiraCode progress bars glyphs support#236
cheggaaa merged 4 commits into
cheggaaa:masterfrom
asciimoth:master

Conversation

@asciimoth

Copy link
Copy Markdown
Contributor

This adds support for progress bar glyph sets that need distinct empty/filled border characters, such as the Unicode progress bar glyphs provided by Fira Code.

Changes:

  • Extends the bar template element with optional 6th and 7th arguments:
    • 6th: empty-state left border
    • 7th: finished-state right border
  • Keeps existing 5-argument bar templates fully backward compatible.
  • Adds an opt-in UNICODE_PROGRESS_BAR=true gate (as suggested by FiraCode readme) for using the Unicode progress bar glyphs as the implicit default template.
  • Documents the new template arguments and environment variable.

@cheggaaa

Copy link
Copy Markdown
Owner

Thanks for the PR!

One thing I'd change: the env var currently swaps the whole default template, so it does nothing for Full, Simple, or a user's own template. Simpler and more complete — let it swap defaultBarEls instead:

var firaBarEls = [barElementCount]string{...}

func init() {
	if os.Getenv("UNICODE_PROGRESS_BAR") == "true" { / maybe also to check for "1", etc?
		defaultBarEls = firaBarEls
	}
}

@asciimoth

Copy link
Copy Markdown
Contributor Author

I choose to preserve only "UNICODE_PROGRESS_BAR=true" and not "1" or "yes" because it may lead to situation when some apps understand specific env value and other (more strict) ignore it.

@cheggaaa

Copy link
Copy Markdown
Owner

Had a small review with an llm and found one bug:

args 6/7 now fall back to defaultBarEls[i], so a fully-specified 5-arg bar still inherits the Fira extras. With UNICODE_PROGRESS_BAR=true:

{{bar . "<" "=" ">" "." ">"}}   →   "........>"

The user's < left border is replaced by U+EE00 whenever the bar is empty — so the env var breaks existing custom bars, including the colored form we document. TestUnicodeProgressBarEnvDoesNotOverrideExplicitBarArgs misses it because it passes all seven args with "" "", which is the one case that isn't at risk.

Fix: take the extras only when no bar args were passed at all.

case i < barLeftEmpty:
	arg = argsH.getNotEmptyOr(i, defaultBarEls[i])
case len(args) == 0:
	arg = defaultBarEls[i] // extras come with the default glyph set only
default:
	arg = argsH.getOr(i, "")

@cheggaaa
cheggaaa merged commit 993f802 into cheggaaa:master Jul 14, 2026
1 check passed
@cheggaaa

Copy link
Copy Markdown
Owner

Thank you! v3.2.0 is out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants