Skip to content

Commit

Permalink
Merge pull request #336 from axelson/formatting
Browse files Browse the repository at this point in the history
Update formatting for Elixir 1.15
  • Loading branch information
crertel authored Dec 16, 2023
2 parents d3f1e6b + 8a8c2fa commit 39e4279
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
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

0 comments on commit 39e4279

Please sign in to comment.