diff options
author | Federico Igne <undyamon@disroot.org> | 2024-01-11 19:31:31 +0100 |
---|---|---|
committer | Federico Igne <undyamon@disroot.org> | 2024-01-11 19:31:31 +0100 |
commit | 055c743c55bde27f4475d3434c26d8383c0c3ea1 (patch) | |
tree | aabf2173a9995f5795da86d5676181b62fee0e9e /lib/text.ml | |
parent | 416c56656af65d656f637dc8c8fdb62d0ba03e29 (diff) | |
download | sandy-055c743c55bde27f4475d3434c26d8383c0c3ea1.tar.gz sandy-055c743c55bde27f4475d3434c26d8383c0c3ea1.zip |
bulk: add PoC of vim-like modular editor
Diffstat (limited to 'lib/text.ml')
-rw-r--r-- | lib/text.ml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/text.ml b/lib/text.ml new file mode 100644 index 0000000..ff1f727 --- /dev/null +++ b/lib/text.ml | |||
@@ -0,0 +1,10 @@ | |||
1 | open Base | ||
2 | open Sequence | ||
3 | open Sequence.Infix | ||
4 | |||
5 | let center ~fill n text = | ||
6 | let padding = repeat fill and len_t = length text in | ||
7 | let len_p = (n - len_t) / 2 in | ||
8 | take (take padding len_p @ text @ padding) n | ||
9 | |||
10 | let extend ~fill n text = take (text @ repeat fill) n | ||