Skip to content

Commit 001a164

Browse files
jayschwaStefanKarpinski
authored andcommitted
Stop using bold text for input and answers (#11250)
Some hardcoded ANSI codes were also replaced with `text_colors`.
1 parent c1bce9d commit 001a164

File tree

4 files changed

+35
-48
lines changed

4 files changed

+35
-48
lines changed

NEWS.md

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,32 +151,25 @@ Library improvements
151151
without having to scrub away prompts and outputs.
152152
This can be disabled or enabled at will with `Base.REPL.enable_promptpaste(::Bool)`.
153153

154-
* The function `print_with_color` can now take a color represented by an
155-
integer between 0 and 255 inclusive as its first argument ([#18473]). For
156-
a number to color mapping please refer to [this
157-
chart](https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg).
158-
It is also possible to use numbers as colors in environment variables that
159-
customizes colors in the REPL. For example, to get orange warning
160-
messages, simply set `ENV["JULIA_WARN_COLOR"] = 208`. Please note that not
161-
all terminals support 256 colors.
162-
163-
* The function `print_with_color` no longer prints text in bold by default
164-
([#18628]). Instead, the function now take a keyword argument `bold::Bool`
165-
which determines whether to print in bold or not. On some terminals,
166-
printing a color in non bold results in slightly darker colors being
167-
printed than when printing in bold. Therefore, light versions of the
168-
colors are now supported. For the available colors see the help entry on
169-
`print_with_color`.
170-
171-
* The default color for info messages has been changed from blue to cyan and
172-
for warning messages from red to yellow. This can be changed back to the
173-
original colors by setting the environment variables `JULIA_INFO_COLOR` to
174-
`"blue"` and `JULIA_WARN_COLOR` to `"red"`. One way of doing this is by
175-
adding for example `ENV["JULIA_INFO_COLOR"] = :blue` and
176-
`ENV["JULIA_WARN_COLOR"] = :red` to the `.juliarc.jl` file. For more
177-
information regarding customizing colors in the REPL, see this [manual
178-
section](
179-
http://docs.julialang.org/en/latest/manual/interacting-with-julia/#customizing-colors).
154+
* The function `print_with_color` can now take a color represented by an integer between 0 and 255 inclusive as its first argument ([#18473]).
155+
For a number to color mapping please refer to [this chart](https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg).
156+
It is also possible to use numbers as colors in environment variables that customizes colors in the REPL.
157+
For example, to get orange warning messages, simply set `ENV["JULIA_WARN_COLOR"] = 208`.
158+
Please note that not all terminals support 256 colors.
159+
160+
* The function `print_with_color` no longer prints text in bold by default ([#18628]).
161+
Instead, the function now take a keyword argument `bold::Bool` which determines whether to print in bold or not.
162+
On some terminals, printing a color in non bold results in slightly darker colors being printed than when printing in bold.
163+
Therefore, light versions of the colors are now supported.
164+
For the available colors see the help entry on `print_with_color`.
165+
166+
* The default text style for REPL input and answers has been changed from bold to normal ([#11250]).
167+
They can be changed back to bold by setting the environment variables `JULIA_INPUT_COLOR` and `JULIA_ANSWER_COLOR` to `"bold"`.
168+
For example, one way of doing this is adding `ENV["JULIA_INPUT_COLOR"] = :bold` and `ENV["JULIA_ANSWER_COLOR"] = :bold` to the `.juliarc.jl` file.
169+
See the [manual section on customizing colors](http://docs.julialang.org/en/latest/manual/interacting-with-julia/#customizing-colors) for more information.
170+
171+
* The default color for info messages has been changed from blue to cyan, and for warning messages from red to yellow.
172+
This can be changed back to the original colors by setting the environment variables `JULIA_INFO_COLOR` to `"blue"` and `JULIA_WARN_COLOR` to `"red"`.
180173

181174
* Iteration utilities that wrap iterators and return other iterators (`enumerate`, `zip`, `rest`,
182175
`countfrom`, `take`, `drop`, `cycle`, `repeated`, `product`, `flatten`, `partition`) have been
@@ -768,6 +761,7 @@ Language tooling improvements
768761
[#10548]: https://github.com/JuliaLang/julia/issues/10548
769762
[#11196]: https://github.com/JuliaLang/julia/issues/11196
770763
[#11242]: https://github.com/JuliaLang/julia/issues/11242
764+
[#11250]: https://github.com/JuliaLang/julia/issues/11250
771765
[#11688]: https://github.com/JuliaLang/julia/issues/11688
772766
[#12231]: https://github.com/JuliaLang/julia/issues/12231
773767
[#12563]: https://github.com/JuliaLang/julia/issues/12563

base/REPL.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ terminal(r::LineEditREPL) = r.t
268268

269269
LineEditREPL(t::TextTerminal, envcolors = false) = LineEditREPL(t,
270270
true,
271-
julia_green,
271+
Base.text_colors[:light_green],
272272
Base.input_color(),
273273
Base.answer_color(),
274274
Base.text_colors[:red],
@@ -599,8 +599,6 @@ function history_reset_state(hist::REPLHistoryProvider)
599599
end
600600
LineEdit.reset_state(hist::REPLHistoryProvider) = history_reset_state(hist)
601601

602-
const julia_green = "\033[1m\033[32m"
603-
604602
function return_callback(s)
605603
ast = Base.syntax_deprecation_warnings(false) do
606604
Base.parse_input_line(String(LineEdit.buffer(s)))
@@ -959,7 +957,7 @@ type StreamREPL <: AbstractREPL
959957
waserror::Bool
960958
StreamREPL(stream,pc,ic,ac) = new(stream,pc,ic,ac,false)
961959
end
962-
StreamREPL(stream::IO) = StreamREPL(stream, julia_green, Base.input_color(), Base.answer_color())
960+
StreamREPL(stream::IO) = StreamREPL(stream, Base.text_colors[:light_green], Base.input_color(), Base.answer_color())
963961
run_repl(stream::IO) = run_repl(StreamREPL(stream))
964962

965963
outstream(s::StreamREPL) = s.stream

base/client.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@ have_color = false
6161
default_color_warn = :yellow
6262
default_color_error = :light_red
6363
default_color_info = :cyan
64-
if is_windows()
65-
default_color_input = :normal
66-
default_color_answer = :normal
67-
else
68-
default_color_input = :bold
69-
default_color_answer = :bold
70-
end
64+
default_color_input = :normal
65+
default_color_answer = :normal
7166
color_normal = text_colors[:normal]
7267

7368
function repl_color(key, default)
@@ -81,9 +76,8 @@ error_color() = repl_color("JULIA_ERROR_COLOR", default_color_error)
8176
warn_color() = repl_color("JULIA_WARN_COLOR" , default_color_warn)
8277
info_color() = repl_color("JULIA_INFO_COLOR" , default_color_info)
8378

84-
# Print input and answer in bold.
85-
input_color() = text_colors[:bold] * text_colors[repl_color("JULIA_INPUT_COLOR", default_color_input)]
86-
answer_color() = text_colors[:bold] * text_colors[repl_color("JULIA_ANSWER_COLOR", default_color_answer)]
79+
input_color() = text_colors[repl_color("JULIA_INPUT_COLOR", default_color_input)]
80+
answer_color() = text_colors[repl_color("JULIA_ANSWER_COLOR", default_color_answer)]
8781

8882
stackframe_lineinfo_color() = repl_color("JULIA_STACKFRAME_LINEINFO_COLOR", :bold)
8983
stackframe_function_color() = repl_color("JULIA_STACKFRAME_FUNCTION_COLOR", :bold)

base/version.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,15 @@ function banner(io::IO = STDOUT)
245245
commit_date = GIT_VERSION_INFO.date_string != "" ? " ($(GIT_VERSION_INFO.date_string))": ""
246246

247247
if have_color
248-
tx = "\033[0m\033[1m" # text
249-
jl = "\033[0m\033[1m" # julia
250-
d1 = "\033[34m" # first dot
251-
d2 = "\033[31m" # second dot
252-
d3 = "\033[32m" # third dot
253-
d4 = "\033[35m" # fourth dot
248+
c = text_colors
249+
tx = c[:normal] # text
250+
jl = c[:normal] # julia
251+
d1 = c[:bold] * c[:light_blue] # first dot
252+
d2 = c[:bold] * c[:light_red] # second dot
253+
d3 = c[:bold] * c[:light_green] # third dot
254+
d4 = c[:bold] * c[:light_magenta] # fourth dot
254255

255-
print(io,"""\033[1m $(d3)_$(tx)
256+
print(io,""" $(d3)_$(tx)
256257
$(d1)_$(tx) $(jl)_$(tx) $(d2)_$(d3)(_)$(d4)_$(tx) | A fresh approach to technical computing
257258
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | Documentation: http://docs.julialang.org
258259
$(jl)_ _ _| |_ __ _$(tx) | Type \"?help\" for help.
@@ -261,7 +262,7 @@ function banner(io::IO = STDOUT)
261262
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
262263
$(jl)|__/$(tx) | $(Sys.MACHINE)
263264
264-
\033[0m""")
265+
""")
265266
else
266267
print(io,"""
267268
_

0 commit comments

Comments
 (0)