Current section
Files
Jump to
Current section
Files
src/etch@cursor.erl
-module(etch@cursor).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/etch/cursor.gleam").
-export([move_to/2, hide/0, show/0, move_to_next_line/1, move_to_previous_line/1, move_to_column/1, move_to_row/1, move_right/1, move_left/1, move_up/1, move_down/1, set_cursor_style/1, save_position/0, restore_position/0]).
-export_type([cursor_style/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" This module provides cursor associated functions like moving it,\n"
" hiding it or setting its style.\n"
).
-type cursor_style() :: default_shape |
blinking_block |
steady_block |
blinking_under_score |
steady_under_score |
blinking_bar |
steady_bar.
-file("src/etch/cursor.gleam", 27).
?DOC(
" Moves cursor to the given position.\n"
" It is prefered not to use this directly. See [`MoveTo`](command.html#MoveTo).\n"
).
-spec move_to(integer(), integer()) -> binary().
move_to(X, Y) ->
<<<<<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(Y + 1))/binary>>/binary,
";"/utf8>>/binary,
(erlang:integer_to_binary(X + 1))/binary>>/binary,
"H"/utf8>>.
-file("src/etch/cursor.gleam", 33).
?DOC(
" Hides cursor.\n"
" It is prefered not to use this directly. See [`Hide`](command.html#Hide).\n"
).
-spec hide() -> binary().
hide() ->
<<"\x{001b}["/utf8, "?25l"/utf8>>.
-file("src/etch/cursor.gleam", 39).
?DOC(
" Shows cursor.\n"
" It is prefered not to use this directly. See [`Show`](command.html#Show).\n"
).
-spec show() -> binary().
show() ->
<<"\x{001b}["/utf8, "?25h"/utf8>>.
-file("src/etch/cursor.gleam", 45).
?DOC(
" Moves cursor to the next line (at the beginning of the line below).\n"
" It is prefered not to use this directly. See [`MoveToNextLine`](command.html#MoveToNextLine).\n"
).
-spec move_to_next_line(integer()) -> binary().
move_to_next_line(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"E"/utf8>>.
-file("src/etch/cursor.gleam", 51).
?DOC(
" Moves cursor to the previous line (at the beginning of the line above).\n"
" It is prefered not to use this directly. See [`MoveToPreviousLine`](command.html#MoveToPreviousLine).\n"
).
-spec move_to_previous_line(integer()) -> binary().
move_to_previous_line(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"F"/utf8>>.
-file("src/etch/cursor.gleam", 57).
?DOC(
" Moves cursor to the given column (the row remains unchainged).\n"
" It is prefered not to use this directly. See [`MoveToColumn`](command.html#MoveToColumn).\n"
).
-spec move_to_column(integer()) -> binary().
move_to_column(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"G"/utf8>>.
-file("src/etch/cursor.gleam", 63).
?DOC(
" Moves cursor to the given row (the column remains unchainged).\n"
" It is prefered not to use this directly. See [`MoveToRow`](command.html#MoveToRow).\n"
).
-spec move_to_row(integer()) -> binary().
move_to_row(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"d"/utf8>>.
-file("src/etch/cursor.gleam", 69).
?DOC(
" Moves cursor n column to the right.\n"
" It is prefered not to use this directly. See [`MoveRight`](command.html#MoveRight).\n"
).
-spec move_right(integer()) -> binary().
move_right(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"C"/utf8>>.
-file("src/etch/cursor.gleam", 75).
?DOC(
" Moves cursor n column to the left.\n"
" It is prefered not to use this directly. See [`MoveLeft`](command.html#MoveLeft).\n"
).
-spec move_left(integer()) -> binary().
move_left(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"D"/utf8>>.
-file("src/etch/cursor.gleam", 81).
?DOC(
" Moves cursor n rows to the up.\n"
" It is prefered not to use this directly. See [`MoveUp`](command.html#MoveUp).\n"
).
-spec move_up(integer()) -> binary().
move_up(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"A"/utf8>>.
-file("src/etch/cursor.gleam", 87).
?DOC(
" Moves cursor n rows to the down.\n"
" It is prefered not to use this directly. See [`MoveDown`](command.html#MoveDown).\n"
).
-spec move_down(integer()) -> binary().
move_down(N) ->
<<<<"\x{001b}["/utf8, (erlang:integer_to_binary(N))/binary>>/binary,
"B"/utf8>>.
-file("src/etch/cursor.gleam", 93).
?DOC(
" Sets cursor style.\n"
" It is prefered not to use this directly. See [`SetCursorStyle`](command.html#SetCursorStyle).\n"
).
-spec set_cursor_style(cursor_style()) -> binary().
set_cursor_style(S) ->
case S of
default_shape ->
<<"\x{001b}["/utf8, "0 q"/utf8>>;
blinking_block ->
<<"\x{001b}["/utf8, "1 q"/utf8>>;
steady_block ->
<<"\x{001b}["/utf8, "2 q"/utf8>>;
blinking_under_score ->
<<"\x{001b}["/utf8, "3 q"/utf8>>;
steady_under_score ->
<<"\x{001b}["/utf8, "4 q"/utf8>>;
blinking_bar ->
<<"\x{001b}["/utf8, "5 q"/utf8>>;
steady_bar ->
<<"\x{001b}["/utf8, "6 q"/utf8>>
end.
-file("src/etch/cursor.gleam", 107).
?DOC(
" Saves current cursor position.\n"
" It is prefered not to use this directly. See [`SavePosition`](command.html#SavePosition).\n"
).
-spec save_position() -> binary().
save_position() ->
<<"\x{001b}"/utf8, "7"/utf8>>.
-file("src/etch/cursor.gleam", 113).
?DOC(
" Restores saved cursor position.\n"
" It is prefered not to use this directly. See [`RestorePosition`](command.html#RestorePosition).\n"
).
-spec restore_position() -> binary().
restore_position() ->
<<"\x{001b}"/utf8, "8"/utf8>>.