Skip to content
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

Update formatting for Elixir 1.15 #336

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
run: mix deps.compile
- name: Compile
run: mix compile --warnings-as-errors
- name: Check formatting
run: mix format --check-formatted
if: startsWith(matrix.elixir, '1.15')
- name: Run Tests
run: mix test
- name: Run credo
Expand Down
5 changes: 4 additions & 1 deletion lib/scenic/assets/static.ex
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ defmodule Scenic.Assets.Static do
assign(lib, :aliases, new_alias, hash)

_ ->
Logger.warning("Attempted to alias #{inspect(new_alias)} to unknown asset: #{inspect(to)}")
Logger.warning(
"Attempted to alias #{inspect(new_alias)} to unknown asset: #{inspect(to)}"
)

lib
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/assets/stream/bitmap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule Scenic.Assets.Stream.Bitmap do
:ok =
@app
|> :code.priv_dir()
|> :filename.join('bitmap')
|> :filename.join(~c"bitmap")
|> :erlang.load_nif(0)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/scenic/component/input/checkbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule Scenic.Component.Input.Checkbox do
{:ok, {Static.Font, fm}} = Static.meta(@default_font)
ascent = FontMetrics.ascent(@default_font_size, fm)
fm_width = FontMetrics.width(text, @default_font_size, fm)
space_width = FontMetrics.width(' ', @default_font_size, fm)
space_width = FontMetrics.width(~c" ", @default_font_size, fm)
# box_width = fm_width + ascent + space_width * 2 + @border_width

box_height = ascent
Expand Down Expand Up @@ -174,7 +174,7 @@ defmodule Scenic.Component.Input.Checkbox do
ascent = FontMetrics.ascent(@default_font_size, fm)
descent = FontMetrics.descent(@default_font_size, fm)
fm_width = FontMetrics.width(text, @default_font_size, fm)
space_width = FontMetrics.width(' ', @default_font_size, fm)
space_width = FontMetrics.width(~c" ", @default_font_size, fm)
box_width = fm_width + ascent + space_width + @border_width
{0, 0, box_width, ascent - descent}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/scenic/component/input/radio_button.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ defmodule Scenic.Component.Input.RadioButton do
{:ok, {Static.Font, fm}} = Static.meta(@default_font)
ascent = FontMetrics.ascent(@default_font_size, fm)
fm_width = FontMetrics.width(text, @default_font_size, fm)
space_width = FontMetrics.width(' ', @default_font_size, fm)
space_width = FontMetrics.width(~c" ", @default_font_size, fm)
outer_radius = ascent * 0.5
inner_radius = ascent * 0.3125

Expand Down Expand Up @@ -140,7 +140,7 @@ defmodule Scenic.Component.Input.RadioButton do
ascent = FontMetrics.ascent(@default_font_size, fm)
descent = FontMetrics.descent(@default_font_size, fm)
fm_width = FontMetrics.width(text, @default_font_size, fm)
space_width = FontMetrics.width(' ', @default_font_size, fm)
space_width = FontMetrics.width(~c" ", @default_font_size, fm)
box_width = fm_width + ascent + space_width + @border_width
{0, 0, box_width, ascent - descent}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/component/input/radio_group.ex
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ defmodule Scenic.Component.Input.RadioGroup do
end
end)

space_width = FontMetrics.width(' ', @default_font_size, fm)
space_width = FontMetrics.width(~c" ", @default_font_size, fm)
box_width = fm_width + ascent + space_width + @border_width
{0, 0, box_width, @line_height * Enum.count(items)}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/component/input/text_field.ex
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ defmodule Scenic.Component.Input.TextField do

@input_capture [:cursor_button, :codepoint, :key]

@password_char '*'
@password_char ~c"*"

# --------------------------------------------------------
@impl Scenic.Component
Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/math/line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Scenic.Math.Line do
:ok =
@app
|> :code.priv_dir()
|> :filename.join('line')
|> :filename.join(~c"line")
|> :erlang.load_nif(0)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/math/matrix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Scenic.Math.Matrix do
:ok =
@app
|> :code.priv_dir()
|> :filename.join('matrix')
|> :filename.join(~c"matrix")
|> :erlang.load_nif(0)
end

Expand Down
3 changes: 2 additions & 1 deletion test/scenic/scene_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ defmodule Scenic.SceneTest do

:ok = Scene.request_input(scene, :cursor_pos)

assert Scene.fetch_requests(scene) ~> {:ok, sorted_list([:cursor_pos, :cursor_button, :codepoint])}
assert Scene.fetch_requests(scene)
~> {:ok, sorted_list([:cursor_pos, :cursor_button, :codepoint])}
end

test "unrequest_input works", %{scene: scene} do
Expand Down
Loading