-
-
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
make print_with_color not default to bold take 2 #18628
Conversation
let | ||
old_have_color = Base.have_color | ||
try | ||
eval(Base, :(have_color = true)) |
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.
Is this acceptable?
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.
isn't something similar done in a withenv in a different test?
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.
this was fine for now, better to test things. we can think about making color not a global elsewhere.
hopefully can restore these from reflog or old commits?
|
||
# Print input and answer in bold. | ||
input_color() = text_colors[:bold] * text_colors[repl_color("JULIA_INPUT_COLOR", default_color_input)] | ||
answer_color() = text_colors[:bold] * text_colors[repl_color("JULIA_ANSWER_COLOR", default_color_answer)] |
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.
should we consider moving these functions to the REPL
module instead of Base
?
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.
Perhaps. On the other hand it makes sense to have all the ENV color stuff in the same place.
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.
how much of it is more general-purpose beyond REPL usage?
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.
IJulia uses colors for infos, errors and warnings now and thus indirectly uses the corresponding ENV vars.
a keyword argument `bold::Bool` which determines whether to print in bold or not. | ||
On some terminals, printing a color in non bold results in slightly darker colors being printed than when printing in bold. | ||
Therefore, light versions of the colors are now supported. | ||
For the available colors see the help entry on `print_with_color. |
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.
missing closing backtick
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.
still missing
:magenta => "\033[35m", | ||
:cyan => "\033[36m", | ||
:white => "\033[37m", | ||
:light_black => "\033[90m", |
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.
how does that work?
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.
I could either call it gray or keep the light_COLOR
pattern like I did here.
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.
I don't think I've ever heard gray called light black, but I guess it works. throw a comment in?
@@ -138,7 +138,7 @@ type Broken <: Result | |||
orig_expr | |||
end | |||
function Base.show(io::IO, t::Broken) | |||
print_with_color(:yellow, io, "Test Broken\n") | |||
print_with_color(:yellow, io, "Test Broken\n"; bold = true) |
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.
the other PR that changes warnings to yellow should think about making these use the configurable warning color
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.
Yes
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.
was that merged before this? lost track
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.
answering my own question: not yet #18453
change the colors for the help and shell prompts and input and answer text by setting the | ||
appropriate field of ``repl`` in the ``customize_colors`` function above (respectively, ``help_color``, ``shell_color``, | ||
``input_color``, and ``answer_color``). For the latter two, be sure that the ``envcolors`` field | ||
is also set to false. | ||
|
||
You can also customize the color used to render warning and informational messages by | ||
You can also customize the color used to render error, warning and informational messages by | ||
setting the appropriate environment variable. For instance, to render warning messages in yellow and | ||
informational messages in cyan you can add the following to your ``juliarc.jl`` file:: |
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.
... and error messages in magenta
This seems to just need a quick rebase and merge. |
4088cd8
to
e16e7c1
Compare
for (n,crc) in [(0,0x00000000),(1,0xa016d052),(2,0x03f89f52),(3,0xf130f21e),(4,0x29308cf4),(5,0x53518fab),(6,0x4f4dfbab),(7,0xbd3a64dc),(8,0x46891f81),(9,0x5a14b9f9),(10,0xb219db69),(11,0xd232a91f),(12,0x51a15563),(13,0x9f92de41),(14,0x4d8ae017),(15,0xc8b74611),(16,0xa0de6714),(17,0x672c992a),(18,0xe8206eb6),(19,0xc52fd285),(20,0x327b0397),(21,0x318263dd),(22,0x08485ccd),(23,0xea44d29e),(24,0xf6c0cb13),(25,0x3969bba2),(26,0x6a8810ec),(27,0x75b3d0df),(28,0x82d535b1),(29,0xbdf7fc12),(30,0x1f836b7d),(31,0xd29f33af),(32,0x8e4acb3e),(33,0x1cbee2d1),(34,0xb25f7132),(35,0xb0fa484c),(36,0xb9d262b4),(37,0x3207fe27),(38,0xa024d7ac),(39,0x49a2e7c5),(40,0x0e2c157f),(41,0x25f7427f),(42,0x368c6adc),(43,0x75efd4a5),(44,0xa84c5c31),(45,0x0fc817b2),(46,0x8d99a881),(47,0x5cc3c078),(48,0x9983d5e2),(49,0x9267c2db),(50,0xc96d4745),(51,0x058d8df3),(52,0x453f9cf3),(53,0xb714ade1),(54,0x55d3c2bc),(55,0x495710d0),(56,0x3bddf494),(57,0x4f2577d0),(58,0xdae0f604),(59,0x3c57c632),(60,0xfe39bbb0),(61,0x6f5d1d41),(62,0x7d996665),(63,0x68c738dc),(64,0x8dfea7ae)] | ||
@test Base.crc32c(UInt8[1:n;]) == crc | ||
end | ||
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.
bad rebase
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.
yeah, git lied to me :P
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.
e16e7c1
to
9ecb48a
Compare
made minor edits to address my own review
wasn't this previously adding some new tests at the end of test/misc.jl? @KristofferC did you intend to remove those, or was it a rebase issue again? |
2cb5cc8
to
9329ab7
Compare
Rebased and added test |
Need to convert the doc additions to markdown |
Thanks, forgot about that. |
The available color keys in `Base.text_colors` are `:black`, `:red`, `:green`, `:yellow`, `:blue`, | ||
`:magenta`, `:cyan`, `:white`, `:normal`, and `:bold` as well as the integers 0 to 255 for terminals | ||
with 256 color support. Similarly, you can change the colors for the help and shell prompts and | ||
The available color keys can be seen by typing ``Base.text_colors`` in the help mode of the REPL. |
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.
single backticks in markdown
@@ -324,4 +326,5 @@ messages in cyan you can add the following to your `juliarc.jl` file: | |||
```julia | |||
ENV["JULIA_WARN_COLOR"] = :yellow | |||
ENV["JULIA_INFO_COLOR"] = :cyan | |||
ENV["JULIA_ERROR_COLOR"] = :magenta |
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.
this undid 5a9b1d7
866edcd
to
6977a6d
Compare
Apologies, hopefully fixed. |
f12b7d9
to
6c8585d
Compare
Squashed a bit and rebased. |
default_color_warn = :red | ||
default_color_error = :red | ||
default_color_warn = :light_red | ||
default_color_error = :light_red |
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.
did the pr always include this change?
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.
Yes, see the second bullet in the first post for this PR.
@@ -527,7 +527,7 @@ function show_expr_type(io::IO, ty, emph) | |||
end | |||
end | |||
|
|||
emphasize(io, str::AbstractString) = have_color ? print_with_color(:red, io, str) : print(io, uppercase(str)) | |||
emphasize(io, str::AbstractString) = have_color ? print_with_color(Base.error_color(), io, str; bold = true) : print(io, uppercase(str)) |
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.
the bold kwarg doesn't exist yet if this is the first commit, right?
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.
You are right. I moved it to the second commit.
6c8585d
to
6d6265b
Compare
This is take 2 of #18480.
print_with_color
. Instead a kwargbold
is added which determines if the result should be printed in bold. For backwards compatability, the:bold
key is still left in thetext_colors
dict. This also sets the default color for errors and warnings tolight_red
instead ofred
because on most terminals this is the color it used to be when printingred
+bold
. This is also the reason for the first commit because for example Jupyter notebook does not support the light versions of the color soIJulia
can if it wants set the ENV variable to just bered
. Edit: However, 16 color support in notebook is merged, just not in release: Re-factor ANSI color handling jupyter/notebook#1230Note, this is not meant to change any input color / boldness, output color / boldness, repl color / boldness etc and not change any of the possible settings that are available now.