-module(string_width). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([mode_2027/1, mode_2027_ext/1, mode_wcwidth/1, ambiguous_as_wide/1, count_ansi_codes/1, with_tab_width/2, at_tab_offset/2, get_terminal_size/0, strip_ansi/1, is_ansi_component/2, inline_styles/1, fold_with/4, dimensions_with/2, line_with/2, fold_raw/4, limit_with/4, stack_horizontal_with/5, align_with/5, position_with/6, padding_with/7, scroll_with/6, stack_vertical_with/5, fold_raw_pieces/4, tabs_to_spaces_with/2, new/0, line/1, dimensions/1, limit/3, tabs_to_spaces/1, position/5, align/4, padding/6, scroll/5, stack_vertical/4, stack_horizontal/4, fold/3]). -export_type([options/0, mode/0, size/0, limit_state/0, alignment/0, placement/0, view_state/1, piece/0]). -opaque options() :: {options, boolean(), boolean(), mode(), integer(), integer()}. -type mode() :: mode_wcwidth | mode2027 | mode2027_ext. -type size() :: {size, integer(), integer()}. -type limit_state() :: {limit_state, binary(), integer(), integer(), binary(), integer(), binary(), integer(), binary(), integer()}. -type alignment() :: left | center | right. -type placement() :: top | middle | bottom. -type view_state(GKH) :: {view_state, GKH, binary(), integer(), integer()}. -type piece() :: {piece, binary(), integer(), integer(), integer()}. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 157). -spec mode_2027(options()) -> options(). mode_2027(Options) -> erlang:setelement(4, Options, mode2027). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 177). -spec mode_2027_ext(options()) -> options(). mode_2027_ext(Options) -> erlang:setelement(4, Options, mode2027_ext). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 194). -spec mode_wcwidth(options()) -> options(). mode_wcwidth(Options) -> erlang:setelement(4, Options, mode_wcwidth). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 210). -spec ambiguous_as_wide(options()) -> options(). ambiguous_as_wide(Options) -> erlang:setelement(3, Options, true). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 224). -spec count_ansi_codes(options()) -> options(). count_ansi_codes(Options) -> erlang:setelement(2, Options, true). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 238). -spec with_tab_width(options(), integer()) -> options(). with_tab_width(Options, Tab_width) -> erlang:setelement(5, Options, Tab_width). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 253). -spec at_tab_offset(options(), integer()) -> options(). at_tab_offset(Options, Tab_offset) -> erlang:setelement(6, Options, Tab_offset). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 275). -spec get_terminal_size() -> {ok, size()} | {error, nil}. get_terminal_size() -> case string_width_ffi:get_terminal_size() of {ok, {Rows, Columns}} -> {ok, {size, Rows, Columns}}; _ -> {error, nil} end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 409). -spec tab(options(), integer()) -> integer(). tab(Options, Col) -> (((case erlang:element(5, Options) of 0 -> 0; Gleam@denominator -> Col div Gleam@denominator end) + 1) * erlang:element(5, Options)) - Col. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 416). -spec prepare_measure(options(), binary()) -> {binary(), list({integer(), integer()}), integer()}. prepare_measure(Options, Str) -> Ansi_ranges = case erlang:element(2, Options) of true -> []; false -> string_width@internal@ansi:match(Str) end, {Str, Ansi_ranges, 0}. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 478). -spec limit_state_col(limit_state()) -> integer(). limit_state_col(State) -> ((erlang:element(4, State) + erlang:element(6, State)) + erlang:element( 8, State )) + erlang:element(10, State). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1456). -spec div_up(integer(), integer()) -> integer(). div_up(Numerator, Denom) -> case Denom of 0 -> 0; Gleam@denominator -> ((Numerator + Denom) - 1) div Gleam@denominator end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1461). -spec repeat(integer(), GKW, fun((GKW) -> GKW)) -> GKW. repeat(Times, State, Fun) -> case Times > 0 of true -> repeat(Times - 1, Fun(State), Fun); false -> State end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1481). -spec guard_list(list(GKY), GLA, fun((GKY, list(GKY)) -> GLA)) -> GLA. guard_list(List, Empty, Non_empty) -> case List of [] -> Empty; [Head | Tail] -> Non_empty(Head, Tail) end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1582). -spec strip_ansi(binary()) -> binary(). strip_ansi(Str) -> string_width@internal@ansi:strip(Str). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1594). -spec is_ansi_component(binary(), options()) -> boolean(). is_ansi_component(Str, Options) -> case erlang:element(2, Options) of true -> false; false -> case Str of <<"\x{1b}"/utf8, _/binary>> -> true; <<"\x{9b}"/utf8, _/binary>> -> true; <<"\x{9d}"/utf8, _/binary>> -> true; _ -> false end end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1792). -spec piece_reducer(GLG, options(), fun((GLG, piece()) -> GLG)) -> {{GLG, integer(), integer()}, fun(({GLG, integer(), integer()}, binary(), integer()) -> {GLG, integer(), integer()})}. piece_reducer(State, Options, Fun) -> Initial = {State, 0, erlang:element(6, Options)}, Fun@1 = fun(State@1, Piece, Width) -> {State@2, Row, Column} = State@1, Width@1 = case Piece of <<"\t"/utf8>> -> tab(Options, Column); _ -> Width end, State@3 = Fun(State@2, {piece, Piece, Row, Column, Width@1}), case Piece of <<"\n"/utf8>> -> {State@3, Row + 1, erlang:element(6, Options)}; _ -> {State@3, Row, Column + Width@1} end end, {Initial, Fun@1}. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 2019). -spec table_lookup(bitstring(), integer()) -> boolean(). table_lookup(Table, Value) -> Hi = erlang:'bsr'(Value, 8), Md = erlang:'bsr'(erlang:'band'(Value, 16#ff), 3), Lo = erlang:'band'(Value, 7), Lvl1_skip = Hi * 8, <<_:Lvl1_skip, Lvl1/integer, _/bitstring>> = case Table of <<_:Lvl1_skip, _/integer, _/bitstring>> -> Table; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"string_width"/utf8>>, function => <<"table_lookup"/utf8>>, line => 2025}) end, Lvl2_skip = ((Lvl1 * 32) + Md) * 8, <<_:Lvl2_skip, Lvl3/integer, _/bitstring>> = case Table of <<_:Lvl2_skip, _/integer, _/bitstring>> -> Table; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@1, module => <<"string_width"/utf8>>, function => <<"table_lookup"/utf8>>, line => 2028}) end, (erlang:'bsr'(Lvl3, Lo) rem 2) /= 0. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1977). -spec is_ignorable(integer()) -> boolean(). is_ignorable(Cp) -> case Cp =< 16#1ffff of true -> table_lookup( <<16, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 17, 33, 17, 17, 17, 34, 35, 36, 37, 38, 39, 40, 17, 17, 41, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 42, 43, 17, 17, 44, 45, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 46, 17, 47, 48, 49, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 51, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 52, 17, 17, 53, 54, 17, 55, 56, 57, 17, 17, 17, 17, 17, 17, 58, 17, 17, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 17, 73, 74, 75, 76, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 77, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 78, 17, 17, 17, 17, 17, 17, 17, 17, 79, 80, 17, 17, 17, 81, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 82, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 83, 17, 84, 85, 17, 17, 17, 17, 17, 17, 17, 86, 17, 17, 17, 17, 17, 87, 80, 88, 17, 89, 90, 17, 17, 91, 92, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 255, 255, 255, 255, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 191, 182, 0, 0, 0, 0, 0, 0, 0, 63, 0, 255, 23, 0, 0, 0, 0, 0, 248, 255, 255, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 191, 159, 61, 0, 0, 0, 128, 2, 0, 0, 0, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 255, 1, 0, 0, 0, 0, 0, 0, 248, 15, 32, 0, 0, 192, 251, 239, 62, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 131, 255, 0, 0, 0, 0, 0, 252, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 20, 254, 33, 254, 0, 12, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 16, 30, 32, 0, 0, 12, 0, 0, 64, 6, 0, 0, 0, 0, 0, 0, 16, 134, 57, 2, 0, 0, 0, 35, 0, 6, 0, 0, 0, 0, 0, 0, 16, 190, 33, 0, 0, 12, 0, 0, 252, 2, 0, 0, 0, 0, 0, 0, 144, 30, 32, 96, 0, 12, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 208, 193, 61, 96, 0, 12, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 144, 64, 48, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 24, 30, 32, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 4, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242, 7, 128, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242, 31, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 160, 2, 0, 0, 0, 0, 0, 0, 254, 127, 223, 224, 255, 254, 255, 255, 255, 31, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 253, 102, 0, 0, 0, 195, 1, 0, 30, 0, 100, 32, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 176, 63, 64, 254, 15, 32, 0, 0, 0, 0, 0, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, 1, 4, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 9, 0, 0, 0, 0, 0, 0, 64, 127, 229, 31, 248, 159, 0, 0, 0, 0, 0, 0, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 208, 23, 4, 0, 0, 0, 0, 248, 15, 0, 3, 0, 0, 0, 60, 59, 0, 0, 0, 0, 0, 0,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, 0, 240, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>, Cp ); false -> (Cp >= 16#e0000) andalso (Cp =< 16#e0fff) end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1984). -spec is_ambiguous(integer()) -> boolean(). is_ambiguous(Cp) -> case Cp =< 16#ffff of true -> table_lookup( <<8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, 13, 13, 13, 22, 13, 13, 13, 13, 13, 13, 23, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 13, 13, 13, 13, 13, 25, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 101, 223, 247, 64, 0, 129, 193, 67, 55, 141, 87, 2, 0, 10, 8, 192, 8, 14, 129, 23, 47, 12, 0, 192, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 85, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 46, 1, 175, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 254, 255, 251, 3, 254, 255, 251, 3, 0, 0, 0, 0, 0, 0, 2, 0, 255, 255, 255, 255, 255, 255, 255, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 51, 247, 0, 45, 72, 0, 0, 0, 0, 0, 0, 16, 128, 30, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 2, 72, 0, 70, 8, 0, 0, 0, 0, 24, 120, 255, 15, 255, 3, 0, 2, 255, 3, 0, 0, 0, 3, 0, 0, 20, 0, 128, 0, 0, 0, 141, 137, 34, 228, 169, 95, 240, 48, 0, 17, 4, 0, 243, 204, 0, 0, 204, 0, 32, 2, 32, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 255, 255, 255, 255, 15, 0, 255, 255, 60, 0, 251, 3, 204, 48, 195, 201, 3, 0, 60, 128, 0, 0, 96, 194, 0, 80, 0, 0, 0, 0, 5, 0, 0, 0, 187, 183, 0, 0, 0, 0, 0, 192, 0, 0, 0, 128, 192, 191, 239, 255, 11, 251, 211, 219, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 192, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32>>, Cp ); false -> (((((((((Cp >= 16#1f100) andalso (Cp =< 16#1f10a)) orelse ((Cp >= 16#1f110) andalso (Cp =< 16#1f12d))) orelse ((Cp >= 16#1f130) andalso (Cp =< 16#1f169))) orelse ((Cp >= 16#1f170) andalso (Cp =< 16#1f18d))) orelse ((Cp >= 16#1f18f) andalso (Cp =< 16#1f190))) orelse ((Cp >= 16#1f19b) andalso (Cp =< 16#1f1ac))) orelse ((Cp >= 16#e0100) andalso (Cp =< 16#e01ef))) orelse ((Cp >= 16#f0000) andalso (Cp =< 16#ffffd))) orelse ((Cp >= 16#100000) andalso (Cp =< 16#10FFFD)) end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 2001). -spec is_wide(integer()) -> boolean(). is_wide(Cp) -> case Cp =< 16#1ffff of true -> table_lookup( <<16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 16, 19, 20, 21, 16, 16, 16, 22, 16, 16, 23, 24, 25, 26, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 16, 16, 16, 16, 30, 16, 16, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 31, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 28, 28, 16, 16, 16, 32, 33, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 34, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 35, 28, 28, 28, 28, 36, 37, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 38, 28, 39, 40, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 41, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 42, 43, 44, 45, 46, 47, 48, 49, 16, 50, 51, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 48, 0, 0, 0, 255, 0, 0, 255, 15, 0, 0, 0, 0, 128, 0, 252, 8, 0, 2, 12, 0, 96, 48, 64, 16, 0, 0, 4, 44, 36, 32, 12, 0, 0, 0, 1, 0, 0, 0, 80, 184, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 1, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 224, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63, 128, 255, 255, 255, 255, 255, 127, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31, 255, 255, 255, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 3, 0, 0, 255, 255, 255, 255, 247, 255, 127, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 3, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63, 0, 0, 0, 0, 128, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 111, 255, 255, 255, 255, 7, 0, 4, 0, 0, 0, 39, 0, 240, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 0, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 254, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 255, 255, 255, 255, 255, 15, 255, 1, 3, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 1, 224, 191, 255, 255, 255, 255, 255, 255, 255, 255, 223, 255, 255, 15, 0, 255, 255, 255, 255, 255, 135, 15, 0, 255, 255, 17, 255, 255, 255, 255, 255, 255, 255, 255, 127, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 159, 255, 255, 255, 255, 255, 255, 255, 63, 0, 120, 255, 255, 255, 0, 0, 4, 0, 0, 96, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 63, 16, 231, 240, 0, 24, 240, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 15, 1, 0, 0, 240, 255, 255, 255, 255, 255, 247, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 31, 255, 131, 255, 255, 255, 255, 255, 255, 127, 192, 255, 159, 255, 3, 255, 1>>, Cp ); false -> (Cp >= 16#20000) andalso (Cp =< 16#40000) end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1952). -spec wcwidth(options(), integer()) -> integer(). wcwidth(Options, Cp) -> case Cp of _ when Cp =< 16#1f -> 0; _ when Cp =< 16#7e -> 1; _ -> case is_ignorable(Cp) of true -> 0; false -> case is_wide(Cp) orelse (erlang:element(3, Options) andalso is_ambiguous( Cp )) of true -> 2; false -> 1 end end end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 2008). -spec is_spacing_mark(integer()) -> boolean(). is_spacing_mark(Cp) -> case Cp =< 16#1ffff of true -> table_lookup( <<16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 19, 20, 21, 16, 22, 23, 16, 16, 16, 16, 16, 16, 24, 16, 25, 26, 27, 28, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 29, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 30, 31, 32, 33, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 16, 45, 46, 47, 48, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 49, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 50, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 51, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 200, 1, 222, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 224, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>, Cp ); false -> false end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 2033). -spec fold_graphemes(binary(), GLN, fun((GLN, binary()) -> GLN)) -> GLN. fold_graphemes(Str, State, Fun) -> case gleam@string:pop_grapheme(Str) of {ok, {Grapheme, Str@1}} -> fold_graphemes(Str@1, Fun(State, Grapheme), Fun); {error, nil} -> State end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1866). -spec fold_chars_wcwidth( options(), binary(), GLK, fun((GLK, binary(), integer()) -> GLK) ) -> GLK. fold_chars_wcwidth(Options, String, State, Fun) -> fold_graphemes( String, State, fun(State@1, Grapheme) -> Width = (string_width_ffi:fold_codepoints( Grapheme, 0, fun(Acc, Cp) -> Acc + wcwidth(Options, Cp) end )), Fun(State@1, Grapheme, Width) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1902). -spec measure_mode_2027(options(), binary()) -> integer(). measure_mode_2027(Options, String) -> string_width_ffi:fold_codepoints(String, 0, fun(Max, Cp) -> case Cp of 16#fe0f when Max > 0 -> 2; _ -> gleam@int:max(Max, wcwidth(Options, Cp)) end end). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1880). -spec fold_chars_2027( options(), binary(), GLL, fun((GLL, binary(), integer()) -> GLL) ) -> GLL. fold_chars_2027(Options, String, State, Fun) -> fold_graphemes( String, State, fun(State@1, Grapheme) -> Width = measure_mode_2027(Options, Grapheme), Fun(State@1, Grapheme, Width) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1911). -spec measure_mode_2027_ext(options(), binary()) -> integer(). measure_mode_2027_ext(Options, String) -> string_width_ffi:fold_codepoints( String, 0, fun(Max, Cp) -> case Max =:= 0 of true -> wcwidth(Options, Cp); false -> case Cp of 16#fe0f -> 2; _ -> case wcwidth(Options, Cp) of 0 -> Max; Width -> case is_spacing_mark(Cp) of true -> gleam@int:max(Max, Width); false -> 2 end end end end end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1891). -spec fold_chars_2027_ext( options(), binary(), GLM, fun((GLM, binary(), integer()) -> GLM) ) -> GLM. fold_chars_2027_ext(Options, String, State, Fun) -> fold_graphemes( String, State, fun(State@1, Grapheme) -> Width = measure_mode_2027_ext(Options, Grapheme), Fun(State@1, Grapheme, Width) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1819). -spec fold_parts( binary(), integer(), list({integer(), integer()}), GLI, fun((GLI, binary()) -> GLI), fun((GLI, binary(), integer()) -> GLI) ) -> GLI. fold_parts(String, Offset, Ranges, State, On_chars, On_range) -> case Ranges of [{Start, Length} | Ranges@1] when Start =:= Offset -> {Range_slice, String@1} = erlang:split_binary(String, Length), State@1 = On_range(State, Range_slice, Length), Offset@1 = Start + Length, fold_parts( String@1, Offset@1, Ranges@1, State@1, On_chars, On_range ); [{Start@1, Length@1} | Ranges@2] -> {Before, At_range} = erlang:split_binary(String, Start@1 - Offset), {Range_slice@1, String@2} = erlang:split_binary(At_range, Length@1), State@2 = begin _pipe = State, _pipe@1 = On_chars(_pipe, Before), On_range(_pipe@1, Range_slice@1, Length@1) end, Offset@2 = Start@1 + Length@1, fold_parts( String@2, Offset@2, Ranges@2, State@2, On_chars, On_range ); [] -> case String of <<""/utf8>> -> State; _ -> On_chars(State, String) end end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1516). -spec inline_styles(binary()) -> binary(). inline_styles(Str) -> Ansi_ranges = string_width@internal@ansi:match(Str), On_range = fun(State, Ansi, _) -> {Buf, Sgr} = State, case Ansi of <<"\x{1b}[0m"/utf8>> -> {<>, <<""/utf8>>}; <<"\x{1b}[m"/utf8>> -> {<>, <<""/utf8>>}; _ -> case gleam@string:ends_with(Ansi, <<"m"/utf8>>) of true -> {<>, <>}; false -> {<>, Sgr} end end end, On_chars = fun(State@1, Chars) -> case State@1 of {Buf@1, <<""/utf8>>} -> {<>, <<""/utf8>>}; {Buf@2, Sgr@1} -> {Rest, _, Buf@4} = (string_width_ffi:fold_bytes( Chars, {Chars, 0, Buf@2}, fun(_use0, Byte) -> {Ptr, Pos, Buf@3} = _use0, case Byte of 16#A -> _assert_subject = erlang:split_binary(Ptr, Pos), {Line, <<"\n"/utf8, Ptr@1/binary>>} = case _assert_subject of {_, <<"\n"/utf8, _/binary>>} -> _assert_subject; _assert_fail -> erlang:error( #{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"string_width"/utf8>>, function => <<"inline_styles"/utf8>>, line => 1539} ) end, {Ptr@1, 0, <<<<<>/binary, "\x{1b}[m\n"/utf8>>/binary, Sgr@1/binary>>}; _ -> {Ptr, Pos + 1, Buf@3} end end )), {<>, Sgr@1} end end, State@2 = fold_parts( Str, 0, Ansi_ranges, {<<""/utf8>>, <<""/utf8>>}, On_chars, On_range ), case State@2 of {Buf@5, <<""/utf8>>} -> Buf@5; {Buf@6, _} -> <> end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1653). -spec fold_with(binary(), options(), GLD, fun((GLD, piece()) -> GLD)) -> GLD. fold_with(Str, Options, State, Fun) -> {State@1, Fun@1} = piece_reducer(State, Options, Fun), On_chars = case erlang:element(4, Options) of mode_wcwidth -> fun(State@2, Str@1) -> fold_chars_wcwidth(Options, Str@1, State@2, Fun@1) end; mode2027 -> fun(State@3, Str@2) -> fold_chars_2027(Options, Str@2, State@3, Fun@1) end; mode2027_ext -> fun(State@4, Str@3) -> fold_chars_2027_ext(Options, Str@3, State@4, Fun@1) end end, Ansi_ranges = case erlang:element(2, Options) of true -> []; false -> string_width@internal@ansi:match(Str) end, On_range = fun(State@5, Ansi, _) -> Fun@1(State@5, Ansi, 0) end, {State@6, _, _} = fold_parts( Str, 0, Ansi_ranges, State@1, On_chars, On_range ), State@6. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 483). -spec limit_state_overflow(limit_state(), binary(), options()) -> {binary(), binary(), integer()}. limit_state_overflow(State, Piece, Options) -> Str = <<<<(erlang:element(7, State))/binary, (erlang:element(9, State))/binary>>/binary, Piece/binary>>, {Before@1, After@1, Width@1} = (fold_with( Str, Options, {<<""/utf8>>, <<""/utf8>>, 0}, fun(_use0, Piece@1) -> {Before, After, Width} = _use0, case (erlang:element(4, Piece@1) + erlang:element(5, Piece@1)) > erlang:element( 8, State ) of true -> {Before, <>, Width + erlang:element(5, Piece@1)}; false -> {<>, After, Width} end end )), case Before@1 =:= <<""/utf8>> of true -> {Before@1, After@1, Width@1}; false -> {<<(erlang:element(5, State))/binary, Before@1/binary>>, After@1, Width@1} end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1856). -spec fold_chars_raw( options(), binary(), GLJ, fun((GLJ, binary(), integer()) -> GLJ) ) -> GLJ. fold_chars_raw(Options, String, State, Fun) -> string_width_ffi:fold_codepoints( String, State, fun(State@1, Cp) -> Fun( State@1, string_width_ffi:utf_codepoint_to_string(Cp), wcwidth(Options, Cp) ) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 370). -spec dimensions_with(binary(), options()) -> size(). dimensions_with(Str, Options) -> {Str@1, Ranges, Range_width} = prepare_measure(Options, Str), Fun = fun(State, Chr, Width) -> {Rows, Cols_max, Cols_curr} = State, case Chr of <<"\n"/utf8>> -> {Rows + 1, gleam@int:max(Cols_max, Cols_curr), erlang:element(6, Options)}; <<"\t"/utf8>> -> {Rows, Cols_max, Cols_curr + tab(Options, Cols_curr)}; _ -> {Rows, Cols_max, Cols_curr + Width} end end, On_range = fun(State@1, Ansi, Length) -> Fun(State@1, Ansi, Range_width * Length) end, On_chars = case erlang:element(4, Options) of mode_wcwidth -> fun(State@2, Str@2) -> fold_chars_raw(Options, Str@2, State@2, Fun) end; mode2027 -> fun(State@3, Str@3) -> fold_chars_2027(Options, Str@3, State@3, Fun) end; mode2027_ext -> fun(State@4, Str@4) -> fold_chars_2027_ext(Options, Str@4, State@4, Fun) end end, Initial = {0, 0, erlang:element(6, Options)}, {Rows@1, Cols_max@1, Cols_curr@1} = fold_parts( Str@1, 0, Ranges, Initial, On_chars, On_range ), Cols_max@2 = gleam@int:max(Cols_max@1, Cols_curr@1) - erlang:element( 6, Options ), Rows@2 = case Cols_curr@1 > erlang:element(6, Options) of true -> Rows@1 + 1; false -> Rows@1 end, {size, Rows@2, Cols_max@2}. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 334). -spec line_with(binary(), options()) -> integer(). line_with(Str, Options) -> {size, _, Columns} = dimensions_with(Str, Options), Columns. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1469). -spec spacer_width(options(), binary()) -> integer(). spacer_width(Options, Str) -> case Str of <<""/utf8>> -> 0; <<" "/utf8>> -> 1; <<"..."/utf8>> -> 3; <<"…"/utf8>> -> 1; <<"0"/utf8>> -> 1; _ -> line_with(Str, Options) end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1722). -spec fold_raw(binary(), options(), GLE, fun((GLE, binary(), integer()) -> GLE)) -> GLE. fold_raw(String, Options, State, Fun) -> Ansi_ranges = case erlang:element(2, Options) of true -> []; false -> string_width@internal@ansi:match(String) end, On_chars = case erlang:element(4, Options) of mode_wcwidth -> fun(State@1, Str) -> fold_chars_raw(Options, Str, State@1, Fun) end; mode2027 -> fun(State@2, Str@1) -> fold_chars_2027(Options, Str@1, State@2, Fun) end; mode2027_ext -> fun(State@3, Str@2) -> fold_chars_2027_ext(Options, Str@2, State@3, Fun) end end, On_range = fun(State@4, Ansi, _) -> Fun(State@4, Ansi, 0) end, fold_parts(String, 0, Ansi_ranges, State, On_chars, On_range). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 511). -spec limit_with(binary(), size(), options(), binary()) -> binary(). limit_with(Str, Max_size, Options, Ellipsis) -> Ellipsis_width = spacer_width(Options, Ellipsis), Max_row = erlang:element(2, Max_size), Commit = fun(Max_col, State, Piece, Width) -> New_col = limit_state_col(State), Is_last_line = (erlang:element(3, State) + 1) >= Max_row, case (erlang:element(7, State) =:= <<""/utf8>>) andalso (erlang:element( 9, State ) =:= <<""/utf8>>) of true -> case erlang:element(2, State) of <<""/utf8>> -> State; _ -> {limit_state, erlang:element(2, State), erlang:element(3, State), erlang:element(4, State), <<(erlang:element(5, State))/binary, Piece/binary>>, erlang:element(6, State) + Width, erlang:element(7, State), erlang:element(8, State), erlang:element(9, State), erlang:element(10, State)} end; false -> case New_col =< Max_col of true -> Str@1 = <<<<<<(erlang:element(2, State))/binary, (erlang:element(5, State))/binary>>/binary, (erlang:element(7, State))/binary>>/binary, (erlang:element(9, State))/binary>>, {limit_state, Str@1, erlang:element(3, State), New_col, Piece, Width, <<""/utf8>>, 0, <<""/utf8>>, 0}; false -> case Is_last_line of true -> {Truncated, _, _} = limit_state_overflow( State, <<""/utf8>>, Options ), {limit_state, <<<<(erlang:element(2, State))/binary, Truncated/binary>>/binary, Ellipsis/binary>>, erlang:element(3, State) + 1, erlang:element(3, Max_size), <<""/utf8>>, 0, <<""/utf8>>, 0, <<""/utf8>>, 0}; false -> {limit_state, <<<<<<(erlang:element(2, State))/binary, "\n"/utf8>>/binary, (erlang:element(7, State))/binary>>/binary, (erlang:element(9, State))/binary>>, erlang:element(3, State) + 1, erlang:element(8, State) + erlang:element( 10, State ), Piece, Width, <<""/utf8>>, 0, <<""/utf8>>, 0} end end end end, Initial = {limit_state, <<""/utf8>>, 0, 0, <<""/utf8>>, 0, <<""/utf8>>, 0, <<""/utf8>>, 0}, State@3 = (fold_raw( Str, Options, Initial, fun(State@1, Piece@1, Width@1) -> Is_last_line@1 = (erlang:element(3, State@1) + 1) >= Max_row, Max_col@1 = case Is_last_line@1 of true -> erlang:element(3, Max_size) - Ellipsis_width; false -> erlang:element(3, Max_size) end, case erlang:element(3, State@1) >= Max_row of true -> case is_ansi_component(Piece@1, Options) of true -> {limit_state, <<(erlang:element(2, State@1))/binary, Piece@1/binary>>, erlang:element(3, State@1), erlang:element(4, State@1), erlang:element(5, State@1), erlang:element(6, State@1), erlang:element(7, State@1), erlang:element(8, State@1), erlang:element(9, State@1), erlang:element(10, State@1)}; false -> State@1 end; false -> case Piece@1 of <<"\n"/utf8>> -> State@2 = Commit(Max_col@1, State@1, <<""/utf8>>, 0), {limit_state, <<(erlang:element(2, State@2))/binary, "\n"/utf8>>, erlang:element(3, State@2) + 1, 0, erlang:element(5, State@2), erlang:element(6, State@2), erlang:element(7, State@2), erlang:element(8, State@2), erlang:element(9, State@2), erlang:element(10, State@2)}; <<"\t"/utf8>> -> Curr_col = limit_state_col(State@1), Width@2 = case Curr_col =< Max_col@1 of true -> tab( Options, erlang:element(6, Options) + Curr_col ); false -> Wrapped_col = erlang:element(8, State@1) + erlang:element( 10, State@1 ), tab( Options, erlang:element(6, Options) + Wrapped_col ) end, Commit(Max_col@1, State@1, Piece@1, Width@2); <<" "/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{1680}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2000}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2001}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2002}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2003}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2004}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2005}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2006}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2008}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{2009}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{200a}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{205f}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); <<"\x{3000}"/utf8>> -> Commit(Max_col@1, State@1, Piece@1, Width@1); _ -> case (limit_state_col(State@1) + Width@1) =< Max_col@1 of true -> {limit_state, erlang:element(2, State@1), erlang:element(3, State@1), erlang:element(4, State@1), erlang:element(5, State@1), erlang:element(6, State@1), <<(erlang:element(7, State@1))/binary, Piece@1/binary>>, erlang:element(8, State@1) + Width@1, erlang:element(9, State@1), erlang:element(10, State@1)}; false -> case ((erlang:element(8, State@1) + erlang:element( 10, State@1 )) + Width@1) > erlang:element(3, Max_size) of true -> {Truncated@1, Overflow, Overflow_width} = limit_state_overflow( State@1, Piece@1, Options ), case Is_last_line@1 of false -> {limit_state, <<<<(erlang:element( 2, State@1 ))/binary, Truncated@1/binary>>/binary, "\n"/utf8>>, erlang:element( 3, State@1 ) + 1, 0, <<""/utf8>>, 0, Overflow, Overflow_width, <<""/utf8>>, 0}; true -> {limit_state, <<<<(erlang:element( 2, State@1 ))/binary, Truncated@1/binary>>/binary, Ellipsis/binary>>, erlang:element( 3, State@1 ) + 1, erlang:element( 3, Max_size ), <<""/utf8>>, 0, <<""/utf8>>, 0, <<""/utf8>>, 0} end; false -> {limit_state, erlang:element(2, State@1), erlang:element(3, State@1), erlang:element(4, State@1), erlang:element(5, State@1), erlang:element(6, State@1), erlang:element(7, State@1), erlang:element(8, State@1), <<(erlang:element(9, State@1))/binary, Piece@1/binary>>, erlang:element(10, State@1) + Width@1} end end end end end )), State@4 = Commit(erlang:element(3, Max_size), State@3, <<""/utf8>>, 0), erlang:element(2, State@4). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1367). -spec view_fold( binary(), integer(), integer(), integer(), integer(), options(), GKU, fun((GKU, binary(), integer()) -> GKU) ) -> GKU. view_fold(Str, Top, Left, Bottom, Right, Options, Initial, Push) -> Total_height = gleam@int:max(0, Bottom - Top), Line_width_offset = gleam@int:max(0, Left), Push_line = fun(State) -> case (erlang:element(4, State) < Top) orelse (erlang:element(4, State) >= Bottom) of true -> {view_state, erlang:element(2, State), erlang:element(3, State), erlang:element(4, State) + 1, 0}; false -> Acc = Push( erlang:element(2, State), erlang:element(3, State), erlang:element(5, State) - Line_width_offset ), {view_state, Acc, <<""/utf8>>, erlang:element(4, State) + 1, 0} end end, Acc@1 = repeat( gleam@int:min(- Top, Total_height), Initial, fun(_capture) -> Push(_capture, <<""/utf8>>, 0) end ), State@2 = (fold_raw( Str, Options, {view_state, Acc@1, <<""/utf8>>, 0, 0}, fun(State@1, Piece, Width) -> Width@1 = case Piece of <<"\t"/utf8>> -> tab( Options, erlang:element(5, State@1) + erlang:element(6, Options) ); _ -> Width end, case Piece of <<"\n"/utf8>> -> Push_line(State@1); _ -> case (((erlang:element(4, State@1) < Top) orelse (erlang:element( 4, State@1 ) >= Bottom)) orelse (erlang:element(5, State@1) < Left)) orelse (erlang:element(5, State@1) >= Right) of true -> case is_ansi_component(Piece, Options) of true -> {view_state, erlang:element(2, State@1), <<(erlang:element(3, State@1))/binary, Piece/binary>>, erlang:element(4, State@1), erlang:element(5, State@1)}; false -> {view_state, erlang:element(2, State@1), erlang:element(3, State@1), erlang:element(4, State@1), erlang:element(5, State@1) + Width@1} end; false -> {view_state, erlang:element(2, State@1), <<(erlang:element(3, State@1))/binary, Piece/binary>>, erlang:element(4, State@1), erlang:element(5, State@1) + Width@1} end end end )), Acc@2 = case (erlang:element(4, State@2) >= Top) andalso (erlang:element( 4, State@2 ) < Bottom) of true -> Push( erlang:element(2, State@2), erlang:element(3, State@2), erlang:element(5, State@2) - Line_width_offset ); false -> Push(erlang:element(2, State@2), erlang:element(3, State@2), -1) end, Missing_bottom = case erlang:element(5, State@2) >= Line_width_offset of true -> (Bottom - erlang:element(4, State@2)) - 1; false -> Bottom - erlang:element(4, State@2) end, repeat( gleam@int:min(Missing_bottom, Total_height), Acc@2, fun(_capture@1) -> Push(_capture@1, <<""/utf8>>, 0) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1233). -spec stack_horizontal_with( list(binary()), placement(), integer(), options(), binary() ) -> binary(). stack_horizontal_with(Blocks, Vertical, Gap, Options, Space) -> guard_list( Blocks, <<""/utf8>>, fun(First, Blocks@1) -> First_size = dimensions_with(First, Options), Measured = (gleam@list:map( Blocks@1, fun(Block) -> {Block, dimensions_with(Block, Options)} end )), Height@1 = gleam@int:max( 1, (gleam@list:fold( Measured, erlang:element(2, First_size), fun(Max, _use1) -> {_, {size, Height, _}} = _use1, gleam@int:max(Max, Height) end )) ), Space_width = spacer_width(Options, Space), Gap_str = gleam@string:repeat(Space, div_up(Gap, Space_width)), Render = fun(Lines, Block@1, Size, Push_column) -> Push = fun(State, Line, Line_width) -> case State of {[Line_so_far | Rest_input], Output} -> Missing_right = div_up( erlang:element(3, Size) - Line_width, Space_width ), Padding_right = gleam@string:repeat( Space, Missing_right ), Line@1 = Push_column( Line_so_far, <> ), {Rest_input, [Line@1 | Output]}; _ -> State end end, Top = case Vertical of top -> 0; bottom -> erlang:element(2, Size) - Height@1; middle -> (erlang:element(2, Size) - Height@1) div 2 end, Bottom = Top + Height@1, Right = erlang:element(3, Size), {_, Formatted_lines} = view_fold( Block@1, Top, 0, Bottom, Right, Options, {Lines, []}, Push ), lists:reverse(Formatted_lines) end, Lines@1 = (Render( gleam@list:repeat(<<""/utf8>>, Height@1), First, First_size, fun(_, Line@2) -> Line@2 end )), Lines@3 = (gleam@list:fold( Measured, Lines@1, fun(Lines@2, _use1@1) -> {Block@2, Size@1} = _use1@1, Render( Lines@2, Block@2, Size@1, fun(Line_so_far@1, Line@3) -> <<<>/binary, Line@3/binary>> end ) end )), gleam@string:join(Lines@3, <<"\n"/utf8>>) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1340). -spec view( binary(), integer(), integer(), integer(), integer(), options(), fun((binary(), integer()) -> binary()) ) -> binary(). view(Str, Top, Left, Bottom, Right, Options, Align) -> Push = fun(Buf, Line, Line_width) -> case Line_width >= 0 of true -> <<<>/binary, (Align(Line, Line_width))/binary>>; false -> <> end end, Result = view_fold( Str, Top, Left, Bottom, Right, Options, <<""/utf8>>, Push ), case Result of <<"\n"/utf8, Result@1/binary>> -> Result@1; _ -> Result end. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 960). -spec align_with(binary(), integer(), alignment(), options(), binary()) -> binary(). align_with(Str, Max_width, Alignment, Options, Space) -> Space_width = spacer_width(Options, Space), Str_size = dimensions_with(Str, Options), Bottom = erlang:element(2, Str_size), Right = gleam@int:max(erlang:element(3, Str_size), Max_width), view( Str, 0, 0, Bottom, Right, Options, fun(Line, Line_width) -> Missing = div_up(Max_width - Line_width, Space_width), case Alignment of left -> <>; right -> <<(gleam@string:repeat(Space, Missing))/binary, Line/binary>>; center -> Left = Missing div 2, Right@1 = Missing - Left, <<<<(gleam@string:repeat(Space, Left))/binary, Line/binary>>/binary, (gleam@string:repeat(Space, Right@1))/binary>> end end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1307). -spec box( binary(), integer(), integer(), integer(), integer(), options(), binary() ) -> binary(). box(Str, Top, Left, Height, Width, Options, Space) -> Space_width = spacer_width(Options, Space), Missing_left = div_up(gleam@int:max(0, - Left), Space_width), Padding_left = gleam@string:repeat(Space, Missing_left), Bottom = Top + Height, Right = Left + Width, view( Str, Top, Left, Bottom, Right, Options, fun(Line, Line_width) -> Missing_right = div_up( (Width - Missing_left) - Line_width, Space_width ), Padding_right = gleam@string:repeat(Space, Missing_right), <<<>/binary, Padding_right/binary>> end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 888). -spec position_with( binary(), size(), alignment(), placement(), options(), binary() ) -> binary(). position_with(Str, Bounding_box, Alignment, Placement, Options, Space) -> Size = dimensions_with(Str, Options), Left = case Alignment of left -> 0; right -> gleam@int:min( erlang:element(3, Size) - erlang:element(3, Bounding_box), 0 ); center -> gleam@int:min( (erlang:element(3, Size) - erlang:element(3, Bounding_box)) div 2, 0 ) end, Top = case Placement of top -> 0; bottom -> gleam@int:min( erlang:element(2, Size) - erlang:element(2, Bounding_box), 0 ); middle -> gleam@int:min( (erlang:element(2, Size) - erlang:element(2, Bounding_box)) div 2, 0 ) end, Width = gleam@int:max( erlang:element(3, Size), erlang:element(3, Bounding_box) ), Height = gleam@int:max( erlang:element(2, Size), erlang:element(2, Bounding_box) ), box(Str, Top, Left, Height, Width, Options, Space). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1040). -spec padding_with( binary(), integer(), integer(), integer(), integer(), options(), binary() ) -> binary(). padding_with(Str, Top, Right, Bottom, Left, Options, Space) -> Size = dimensions_with(Str, Options), Width = (erlang:element(3, Size) + Left) + Right, Height = (erlang:element(2, Size) + Top) + Bottom, box(Str, - Top, - Left, Height, Width, Options, Space). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1102). -spec scroll_with(binary(), integer(), integer(), size(), options(), binary()) -> binary(). scroll_with(Str, Top, Left, Viewport_size, Options, Space) -> {size, Height, Width} = Viewport_size, box(Str, Top, Left, Height, Width, Options, Space). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1153). -spec stack_vertical_with( list(binary()), alignment(), integer(), options(), binary() ) -> binary(). stack_vertical_with(Blocks, Horizontal, Gap, Options, Space) -> guard_list( Blocks, <<""/utf8>>, fun(First, Blocks@1) -> First_size = dimensions_with(First, Options), Measured = (gleam@list:map( Blocks@1, fun(Block) -> {Block, dimensions_with(Block, Options)} end )), Width@1 = (gleam@list:fold( Measured, erlang:element(3, First_size), fun(Max, _use1) -> {_, {size, _, Width}} = _use1, gleam@int:max(Max, Width) end )), Space_width = spacer_width(Options, Space), Gap_line = gleam@string:repeat(Space, div_up(Width@1, Space_width)), Gap_str = gleam@string:repeat(<<"\n"/utf8, Gap_line/binary>>, Gap), Render = fun(Block@1, Size) -> Left = case Horizontal of left -> 0; right -> erlang:element(3, Size) - Width@1; center -> (erlang:element(3, Size) - Width@1) div 2 end, box( Block@1, 0, Left, erlang:element(2, Size), Width@1, Options, Space ) end, gleam@list:fold( Measured, Render(First, First_size), fun(Buf, _use1@1) -> {Block@2, Size@1} = _use1@1, <<<<<>/binary, "\n"/utf8>>/binary, (Render(Block@2, Size@1))/binary>> end ) end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1763). -spec fold_raw_pieces(binary(), options(), GLF, fun((GLF, piece()) -> GLF)) -> GLF. fold_raw_pieces(String, Options, State, Fun) -> Ansi_ranges = case erlang:element(2, Options) of true -> []; false -> string_width@internal@ansi:match(String) end, {State@1, Fun@1} = piece_reducer(State, Options, Fun), On_chars = case erlang:element(4, Options) of mode_wcwidth -> fun(State@2, Str) -> fold_chars_raw(Options, Str, State@2, Fun@1) end; mode2027 -> fun(State@3, Str@1) -> fold_chars_2027(Options, Str@1, State@3, Fun@1) end; mode2027_ext -> fun(State@4, Str@2) -> fold_chars_2027_ext(Options, Str@2, State@4, Fun@1) end end, On_range = fun(State@5, Ansi, _) -> Fun@1(State@5, Ansi, 0) end, {State@6, _, _} = fold_parts( String, 0, Ansi_ranges, State@1, On_chars, On_range ), State@6. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 824). -spec tabs_to_spaces_with(binary(), options()) -> binary(). tabs_to_spaces_with(Str, Options) -> fold_raw_pieces( Str, Options, <<""/utf8>>, fun(Acc, Piece) -> case erlang:element(2, Piece) of <<"\t"/utf8>> -> <>, erlang:element(5, Piece) ))/binary>>; _ -> <> end end ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 131). -spec new() -> options(). new() -> {options, false, false, mode_wcwidth, 8, 0}. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 311). -spec line(binary()) -> integer(). line(Str) -> {size, _, Columns} = dimensions_with( Str, {options, false, false, mode_wcwidth, 8, 0} ), Columns. -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 359). -spec dimensions(binary()) -> size(). dimensions(Str) -> dimensions_with(Str, {options, false, false, mode_wcwidth, 8, 0}). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 456). -spec limit(binary(), size(), binary()) -> binary(). limit(Str, Max_size, Ellipsis) -> limit_with( Str, Max_size, {options, false, false, mode_wcwidth, 8, 0}, Ellipsis ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 804). -spec tabs_to_spaces(binary()) -> binary(). tabs_to_spaces(Str) -> tabs_to_spaces_with(Str, {options, false, false, mode_wcwidth, 8, 0}). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 871). -spec position(binary(), size(), alignment(), placement(), binary()) -> binary(). position(Str, Bounding_box, Alignment, Placement, Space) -> position_with( Str, Bounding_box, Alignment, Placement, {options, false, false, mode_wcwidth, 8, 0}, Space ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 944). -spec align(binary(), integer(), alignment(), binary()) -> binary(). align(Str, Max_width, Alignment, Space) -> align_with( Str, Max_width, Alignment, {options, false, false, mode_wcwidth, 8, 0}, Space ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1016). -spec padding(binary(), integer(), integer(), integer(), integer(), binary()) -> binary(). padding(Str, Top, Right, Bottom, Left, Space) -> Options = {options, false, false, mode_wcwidth, 8, 0}, Size = dimensions_with(Str, Options), Width = (erlang:element(3, Size) + Left) + Right, Height = (erlang:element(2, Size) + Top) + Bottom, box(Str, - Top, - Left, Height, Width, Options, Space). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1083). -spec scroll(binary(), integer(), integer(), size(), binary()) -> binary(). scroll(Str, Top, Left, Viewport_size, Space) -> Options = {options, false, false, mode_wcwidth, 8, 0}, {size, Height, Width} = Viewport_size, box(Str, Top, Left, Height, Width, Options, Space). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1137). -spec stack_vertical(list(binary()), alignment(), integer(), binary()) -> binary(). stack_vertical(Blocks, Horizontal, Gap, Space) -> stack_vertical_with( Blocks, Horizontal, Gap, {options, false, false, mode_wcwidth, 8, 0}, Space ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1217). -spec stack_horizontal(list(binary()), placement(), integer(), binary()) -> binary(). stack_horizontal(Blocks, Vertical, Gap, Space) -> stack_horizontal_with( Blocks, Vertical, Gap, {options, false, false, mode_wcwidth, 8, 0}, Space ). -file("/home/arkan/Projects/private/string-width/src/string_width.gleam", 1632). -spec fold(binary(), GLC, fun((GLC, piece()) -> GLC)) -> GLC. fold(Str, State, Fun) -> fold_with(Str, {options, false, false, mode_wcwidth, 8, 0}, State, Fun).