Repository: xonsh/xonsh

Issue:
Poor choice of text colors on welcome screen
I just tried starting up xonsh on a whim, and got this:

![foo](https://user-images.githubusercontent.com/609896/27001031-d7939176-4d74-11e7-866e-d671282d1e4d.png)

I think there might be some text there? That I might want to read? It's hard to say. I'm guessing the vibe you were going for was like... "welcoming"? but it landed on "eyestrain".

(Possibly this is my fault for using an almost-but-not-quite-white background for my terminal.)


Discussion:
Hey @njsmith -- thanks for reporting! And sorry about the eyestrain. 

Yeah, there's definitely text there, and it's definitely white. We should change that.
Ooooh, there might be a few issues here, actually. Do you have either/both of `prompt_toolkit` and `pygments` installed in your virtualenv? If you do, xonsh will use your terminal colors which should hopefully avoid the problem above.  

But we should fix the defaults in any case to be kinder to a range of terminal background colors.
I do have both pygments and prompt_toolkit installed in that same
virtualenv, yeah. Are you saying that should have prevented the problem? Or
that it's their defaults that are (de)faulty?

On Jun 10, 2017 6:21 AM, "Gil Forsyth" <notifications@github.com> wrote:

> Ooooh, there might be a few issues here, actually. Do you have either/both
> of prompt_toolkit and pygments installed in your virtualenv? If you do,
> xonsh will use your terminal colors which should hopefully avoid the
> problem above.
>
> But we should fix the defaults in any case to be kinder to a range of
> terminal background colors.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/xonsh/xonsh/issues/2401#issuecomment-307564715>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAlOaKK5OLw3BEuYHj7DqDDWimrI2Xucks5sCphNgaJpZM4N2CuG>
> .
>

I thought that would've prevented the problem. With pygments >= 2.2.0 xonsh should use ansicolors and grab the scheme that your terminal is using, so it's strange that it would print out white on slightly-off-white
Not sure what "scheme" means here; IIRC basically a stock gnome terminal where I went to the config panel and customized the background color. Is there an assumption that all the basic ANSI colors should have good contrast with the background? Are light colored terminal configurations supposed to make the "white" color be, like, black or something?

I won't be shocked if it turns out there's some piece of code that avoids using a foreground color that exactly matches the background, and I broke it by being lazy (?) and not making ANSI white = my slightly off white. But if that's what's happening then I still vote that the check be updated to check for similarity rather than exact equality :-)
I was sloppy with language there (and I don't like when I do that). I did mean that with pygments and prompt_toolkit, xonsh defaults to using the colors set by the terminal emulator. 

A quick perusal of some of the color styles available in xonsh leads me to believe that in the light-colored terminal configs that "white" does become... not white... which is weird. 

And I don't think that we have code to check even exact matches of foreground and background colors, much less a fuzzy match to avoid the problem you ran in to. We should definitely handle this better.
Yeah, from a quick look at the built-in schemes in gnome-terminal, it looks like many of them make "white" be something that's not quite white. But... I flipped through a bunch of the built-in styles that have light-colored-background and different ansi-color-palettes, and the xonsh welcome screen was still pretty much unreadable in all of them.
The place of the code to fix this:

https://github.com/xonsh/xonsh/blob/c4e7843598201236307352b1db77e53c14ae9ade/xonsh/xonfig.py#L856-L876

PR is welcome!

Resolving patch:
diff --git a/xonsh/xonfig.py b/xonsh/xonfig.py
--- a/xonsh/xonfig.py
+++ b/xonsh/xonfig.py
@@ -827,7 +827,6 @@ def TAGLINES():
         "Piggy glanced nervously into hell and cradled the xonsh",
         "The xonsh is a symbol",
         "It is pronounced conch",
-        "The shell, bourne again",
         "Snailed it",
         "Starfish loves you",
         "Come snail away",
@@ -848,21 +847,20 @@ def TAGLINES():
         "Python-powered, cross-platform, Unix-gazing shell",
         "Tab completion in Alderaan places",
         "This fix was trickier than expected",
-        "The unholy cross of Bash/Python",
     ]
 
 
 # list of strings or tuples (string, align, fill)
 WELCOME_MSG = [
     "",
-    ("{{INTENSE_WHITE}}Welcome to the xonsh shell ({version}){{RESET}}", "^", " "),
+    ("Welcome to the xonsh shell {version}", "^", " "),
     "",
     ("{{INTENSE_RED}}~{{RESET}} {tagline} {{INTENSE_RED}}~{{RESET}}", "^", " "),
     "",
     ("{{INTENSE_BLACK}}", "<", "-"),
     "",
     (
-        "{{INTENSE_BLACK}}Create ~/.xonshrc file manually or use xonfig to suppress the welcome screen",
+        "{{INTENSE_BLACK}}Create ~/.xonshrc file manually or use xonfig to suppress the welcome message",
         "^",
         " ",
     ),
@@ -870,6 +868,7 @@ def TAGLINES():
     "{{INTENSE_BLACK}}Start from commands:",
     "  {{GREEN}}xonfig{{RESET}} web         {{INTENSE_BLACK}}# Run the configuration tool in the browser to create ~/.xonshrc {{RESET}}",
     "  {{GREEN}}xonfig{{RESET}} tutorial    {{INTENSE_BLACK}}# Open the xonsh tutorial in the browser{{RESET}}",
+    "[SHELL_TYPE_WARNING]",
     "",
     ("{{INTENSE_BLACK}}", "<", "-"),
     "",
@@ -877,11 +876,21 @@ def TAGLINES():
 
 
 def print_welcome_screen():
+    shell_type = builtins.__xonsh__.env.get("SHELL_TYPE")
     subst = dict(tagline=random.choice(list(TAGLINES)), version=XONSH_VERSION)
     for elem in WELCOME_MSG:
+        if elem == "[SHELL_TYPE_WARNING]":
+            if shell_type != "prompt_toolkit":
+                print_color(
+                    f"\n{{INTENSE_BLACK}}You are currently using the {shell_type} backend. "
+                    f"For interactive tab-completion, on-the-fly syntax highlighting, and more, install prompt_toolkit by running:\n\n"
+                    f"  {{GREEN}}xpip{{RESET}} install -U 'xonsh[full]'"
+                )
+            continue
         if isinstance(elem, str):
             elem = (elem, "", "")
         line = elem[0].format(**subst)
         termwidth = os.get_terminal_size().columns
         line = _align_string(line, elem[1], elem[2], width=termwidth)
         print_color(line)
+    print_color("{RESET}", end="")


Test patch: