zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.97k stars 2.7k forks source link

Create seperate setting for terminal background & terminal background ansi color #17313

Open AlbertMarashi opened 1 week ago

AlbertMarashi commented 1 week ago

Check for existing issues

Describe the feature

When using a transparent or blurred theme, I wish to have a terminal that is transparent.

Unfortunately, text using the "background" color in my terminal gets turned invisible.

image

The correct behavior should look like this

image

However, our terminal is turned dark and we can no longer see the blurred background effect in the theme

If applicable, add mockups / screenshots to help present your vision of the feature

No response

AlbertMarashi commented 1 week ago

The ideal approach would be to expose some kind of terminal.ansi.background color's for the background color, such that text rendered with it appears in that color instead of terminal.background

AlbertMarashi commented 1 week ago

I have been able to debug the issue, it appears that vitest is using a specific ansi color code

echo -e "\033[7m\033[1m\033[36m RUN \033[39m\033[22m\033[27m"

This command will output:

I think it has something to do with the reverse video - it's putting terminal.background (#0000) as the terminal.foreground equivalent - so when it prints, its appearing as invisible text inside of Zed's terminal

Is this a bug?

AlbertMarashi commented 1 week ago

Additionally, pasted text into the terminal appears as white, presumably for the same "video reversal" reason

image

What is the right approach here?

AlbertMarashi commented 1 week ago
#!/bin/bash

# Function to print colored text with reverse video
print_reverse_color() {
    local color=$1
    local color_name=$2
    echo -e "\033[7m\033[1m\033[${color}m ${color_name} \033[39m\033[22m\033[27m"
}

# Print header
echo "Reverse Video ANSI Color Test"
echo "-----------------------------"

# Standard colors
print_reverse_color "30" "Black"
print_reverse_color "31" "Red"
print_reverse_color "32" "Green"
print_reverse_color "33" "Yellow"
print_reverse_color "34" "Blue"
print_reverse_color "35" "Magenta"
print_reverse_color "36" "Cyan"
print_reverse_color "37" "White"

echo

# Bright colors
print_reverse_color "90" "Bright Black"
print_reverse_color "91" "Bright Red"
print_reverse_color "92" "Bright Green"
print_reverse_color "93" "Bright Yellow"
print_reverse_color "94" "Bright Blue"
print_reverse_color "95" "Bright Magenta"
print_reverse_color "96" "Bright Cyan"
print_reverse_color "97" "Bright White"

echo

# Default color
echo -e "\033[7m\033[1m Default Color \033[22m\033[27m"

With terminal.background set to #0000

image

With terminal.background set to #000

image


After I spent some time thinking about it, I think the right approaches are either to:

  1. Mask background color text with what would be "under" it if the background color wasn't there (effectively displaying the blurred/transparent background behind the terminal)
  2. Create a new setting for specifying the ansi "background" color (not sure exactly what)
  3. Use the background color minus the opacity, ie: #0000 becomes #000 and #FFF0 becomes #FFF, but probably only in the context of "video reversal" mode?