From 16281b0e8deb6b3bf86ac0b9381f3fdf89b22b58 Mon Sep 17 00:00:00 2001 From: Simponic Date: Mon, 2 Jan 2023 19:10:23 -0700 Subject: Now a simple logo draws in the center of the terminal, terminal size is limited, and resizing support --- lib/chessh/utils.ex | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/chessh/utils.ex') diff --git a/lib/chessh/utils.ex b/lib/chessh/utils.ex index 1a7f8cf..3e83d5e 100644 --- a/lib/chessh/utils.ex +++ b/lib/chessh/utils.ex @@ -6,4 +6,9 @@ defmodule Chessh.Utils do |> List.delete_at(-1) |> to_string() end + + def text_dim(text) do + split = String.split(text, "\n") + {Enum.reduce(split, 0, fn x, acc -> max(acc, String.length(x)) end), length(split)} + end end -- cgit v1.3