Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed windows terminal icon colors cut off on overhanging icons #1776

Closed
wants to merge 2 commits into from

Conversation

BPplays
Copy link

@BPplays BPplays commented Jul 14, 2024

on windows terminal for some reason icon colors are cut off if the icon overhangs this happens on other terminal programs too. the fix is to print a space after the icon with the same style

before:
before

after:
after

Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the following effect on Windows Terminal by mixing bold and regular styles:

colors file:

di	01;34

icons file:

di	󰷏	31

Also I was able to reproduce this outside of lf using a minimal tcell program:

package main

import (
	"github.com/gdamore/tcell/v2"
)

func main() {
	screen, err := tcell.NewScreen()
	if err != nil {
		panic(err)
	}

	if err := screen.Init(); err != nil {
		panic(err)
	}
	defer screen.Fini()

	red_bold := tcell.StyleDefault.Foreground(tcell.ColorRed).Bold(true)
	green := tcell.StyleDefault.Foreground(tcell.ColorGreen)

	screen.Clear()
	screen.SetContent(0, 0, 986575, nil, red_bold) // icon
	screen.SetContent(1, 0, 32, nil, red_bold)     // space
	screen.SetContent(2, 0, 97, nil, red_bold)     // a
	screen.SetContent(3, 0, 98, nil, red_bold)     // b
	screen.SetContent(4, 0, 99, nil, red_bold)     // c
	screen.SetContent(0, 0, 986575, nil, green)    // icon
	screen.Show()

	for {
		ev := screen.PollEvent()

		switch ev.(type) {
		case *tcell.EventKey:
			return
		}
	}
}

I'm uninclined to accept the change as it currently is, since it looks like a band-aid fix that doesn't properly address the root problem. Instead I would suggest either:

a) Change your configs to use bold only or regular only
b) Report this issue to tcell (and they can likely forward the issue to Windows Terminal)
c) I can also accept the PR if you rewrite the code so that it prints the icons separately instead of on top of the existing filename. To do this you would have to store the tag, icon and filename separately and then:

  • If it is the currently focused file, combine them and apply the cursor style
  • Otherwise, print the components separately.

@joelim-work
Copy link
Collaborator

@BPplays I ended up fixing this myself in #1777, can you try it out to see if it works?

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