-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix some issues with color configuration #36689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Epic!
@@ -849,7 +855,7 @@ end | |||
|
|||
function reset(repl::LineEditREPL) | |||
raw!(repl.t, false) | |||
print(repl.t, Base.text_colors[:normal]) | |||
hascolor(repl) && print(repl.t, Base.text_colors[:normal]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible odd to return a Boolean?
opts.hascolor = hascolor | ||
if !hascolor | ||
opts.beep_colors = [""] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this logic belongs in the Options
constructor taking kwargs? e.g. in the body of that method, replace beep_colors
by hascolor ? beep_colors : [""]
(or change the default value by hascolor ? ["\e[90m"] : [""]
).
Ok, hascolor
is not passed to Options
... This is indeed quite annoying to have hascolor
both in LineEditREPL
and Options
. I'm not sure which should take precedence, and how they could be merged, but this belongs to another issue/PR.
stdlib/REPL/src/LineEdit.jl
Outdated
@@ -1259,21 +1259,21 @@ refresh_line(s, termbuf) = refresh_multi_line(termbuf, s) | |||
default_completion_cb(::IOBuffer) = [] | |||
default_enter_cb(_) = true | |||
|
|||
write_prompt(terminal, s::PromptState) = write_prompt(terminal, s.p) | |||
write_prompt(terminal, s::PromptState, hascolor::Bool) = write_prompt(terminal, s.p, hascolor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this just color
? It's typically only set if the terminal has color, but it could be called with anything. Also, maybe better as a keyword argument since otherwise it's hard to know what boolean args mean.
Modulo passing CI of course ;) |
bfd980a
to
109638e
Compare
With this PR now I get
🤔 |
As far as I can see, the problem is that the stream of the global logger doesn't have the
even though this stream should be julia/stdlib/Logging/src/Logging.jl Lines 58 to 60 in ad4b1ec
|
Codecov Report
@@ Coverage Diff @@
## master #36689 +/- ##
=======================================
Coverage 86.12% 86.12%
=======================================
Files 350 350
Lines 65917 65917
=======================================
Hits 56773 56773
Misses 9144 9144 Continue to review full report at Codecov.
|
109638e
to
182d616
Compare
Seems to finally work
🎉 |
🌈 |
182d616
to
463d810
Compare
The failure in macOS seems unrelated? Good to merge otherwise? |
- `--color=no` did not remove all color in the REPL - color was not fully disabled by default when stdout was a pipe - `--color=yes` did not enable color when stdout was a pipe (fixes #30703)
463d810
to
e3832af
Compare
- `--color=no` did not remove all color in the REPL - color was not fully disabled by default when stdout was a pipe - `--color=yes` did not enable color when stdout was a pipe (fixes JuliaLang#30703)
The issues here were truly surprising. Try running julia with
--color=no
(i guess I never do). Most color goes away, but all prompts are still bold, and while other prompts are un-colored, the Pkg prompt is still blue. I almost abandoned hope when I saw that. Then there is #30703, where redirecting to a pipe (julia | tee
) removes most color, except all prompts are colored and bold, and--color=yes
doesn't re-enable color. So this does the following:--color
is specified and stdout or stderr is not a TTY, wrap it in an IOContext with the color setting.get
on an io stream everywhere to determine whether to use color.write_prompt
to disable bold.hascolor=false
is passed to the REPL.Needs #36688 to work. Should fix or help #36671. Fixes #30703.