Replace *just with pad_* calls and optimize around
This commit is contained in:
@@ -43,7 +43,7 @@ defmodule IO.ANSI.Docs do
|
||||
options = Keyword.merge(default_options, options)
|
||||
width = options[:width]
|
||||
padding = div(width + String.length(heading), 2)
|
||||
heading = heading |> String.rjust(padding) |> String.ljust(width)
|
||||
heading = heading |> String.pad_leading(padding) |> String.pad_trailing(width)
|
||||
write(:doc_title, heading, options)
|
||||
newline_after_block
|
||||
end
|
||||
|
||||
@@ -251,7 +251,7 @@ defmodule Kernel.ParallelCompiler do
|
||||
|> Enum.max
|
||||
|
||||
for {file, mod} <- deadlock do
|
||||
IO.puts " " <> String.rjust(file, max) <> " => " <> inspect(mod)
|
||||
IO.puts [" ", String.pad_leading(file, max), " => " | inspect(mod)]
|
||||
end
|
||||
|
||||
IO.puts ""
|
||||
|
||||
@@ -194,7 +194,7 @@ defmodule ExUnit.Formatter do
|
||||
defp format_label(:note, _formatter), do: ""
|
||||
|
||||
defp format_label(label, formatter) do
|
||||
formatter.(:extra_info, String.ljust("#{label}:", byte_size(@label_padding)))
|
||||
formatter.(:extra_info, String.pad_trailing("#{label}:", byte_size(@label_padding)))
|
||||
end
|
||||
|
||||
defp format_banner(value, formatter) do
|
||||
|
||||
+1
-1
@@ -335,7 +335,7 @@ defmodule IEx do
|
||||
nil ->
|
||||
string
|
||||
ansi ->
|
||||
IO.iodata_to_binary([IO.ANSI.format_fragment(ansi, true), string | IO.ANSI.reset])
|
||||
[ansi | string] |> IO.ANSI.format(true) |> IO.iodata_to_binary()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ defmodule IEx.Evaluator do
|
||||
end
|
||||
|
||||
defp format_entry({app, info}, width) do
|
||||
app = String.rjust(app, width)
|
||||
app = String.pad_leading(app, width)
|
||||
IEx.color(:stack_app, app) <> IEx.color(:stack_info, info)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -501,7 +501,7 @@ defmodule IEx.Helpers do
|
||||
else
|
||||
len
|
||||
end
|
||||
IO.write format_item(Path.join(path, item), String.ljust(item, width))
|
||||
IO.write format_item(Path.join(path, item), String.pad_leading(item, width))
|
||||
len + width
|
||||
end)
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ defmodule Mix.Tasks.Help do
|
||||
end
|
||||
|
||||
defp format_task(task, max, doc) do
|
||||
String.ljust(task, max) <> " # " <> doc
|
||||
String.pad_trailing(task, max) <> " # " <> doc
|
||||
end
|
||||
|
||||
defp where_is_file(module) do
|
||||
|
||||
Reference in New Issue
Block a user