2022-10-01 21:16:22 +08:00
|
|
|
--=============================================================================
|
|
|
|
-- messletters.lua --- messletters api
|
2023-03-26 13:50:22 +08:00
|
|
|
-- Copyright (c) 2016-2023 Wang Shidong & Contributors
|
2022-10-01 21:16:22 +08:00
|
|
|
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
|
|
|
-- URL: https://spacevim.org
|
|
|
|
-- License: GPLv3
|
|
|
|
--=============================================================================
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
2024-06-09 10:37:42 +08:00
|
|
|
function M.circled_letter(c)
|
|
|
|
local nr = vim.fn.char2nr(c)
|
|
|
|
if nr - 64 >= 1 and nr - 64 <= 26 then
|
|
|
|
return vim.fn.nr2char(9397 + nr - 64)
|
|
|
|
elseif nr - 96 >= 1 and nr - 96 <= 26 then
|
|
|
|
return vim.fn.nr2char(9423 + nr - 96)
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
end
|
2022-10-01 21:16:22 +08:00
|
|
|
function M.bubble_num(num, t)
|
2024-06-09 10:37:42 +08:00
|
|
|
local list = {}
|
2022-10-01 21:16:22 +08:00
|
|
|
|
2024-06-09 10:37:42 +08:00
|
|
|
table.insert(list, { '➊', '➋', '➌', '➍', '➎', '➏', '➐', '➑', '➒', '➓' })
|
|
|
|
table.insert(list, { '➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', '➈', '➉' })
|
|
|
|
table.insert(list, { '⓵', '⓶', '⓷', '⓸', '⓹', '⓺', '⓻', '⓼', '⓽', '⓾' })
|
2022-10-01 21:16:22 +08:00
|
|
|
|
2024-06-09 10:37:42 +08:00
|
|
|
local n = ''
|
2022-10-01 21:16:22 +08:00
|
|
|
|
2024-06-09 10:37:42 +08:00
|
|
|
pcall(function()
|
|
|
|
n = list[t + 1][num]
|
|
|
|
end)
|
2022-10-01 21:16:22 +08:00
|
|
|
|
2024-06-09 10:37:42 +08:00
|
|
|
return n
|
2022-10-01 21:16:22 +08:00
|
|
|
end
|
|
|
|
|
2022-10-01 21:31:03 +08:00
|
|
|
function M.circled_num(num, t)
|
2024-06-09 10:37:42 +08:00
|
|
|
local nr2char = vim.fn.nr2char
|
|
|
|
local range = vim.fn.range
|
|
|
|
local index = vim.fn.index
|
|
|
|
if t == 0 then
|
|
|
|
if num == 0 then
|
|
|
|
return nr2char(9471)
|
|
|
|
elseif index(range(1, 10), num) ~= -1 then
|
|
|
|
return nr2char(10102 + num - 1)
|
|
|
|
elseif index(range(11, 20), num) ~= -1 then
|
|
|
|
return nr2char(9451 + num - 11)
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
elseif t == 1 then
|
|
|
|
if index(range(20), num) ~= -1 then
|
|
|
|
if num == 0 then
|
|
|
|
return nr2char(9450)
|
|
|
|
else
|
|
|
|
return nr2char(9311 + num)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
elseif t == 2 then
|
|
|
|
if index(range(1, 10), num) ~= -1 then
|
|
|
|
return nr2char(9461 + num - 1)
|
|
|
|
else
|
|
|
|
return ''
|
2022-10-01 21:31:03 +08:00
|
|
|
end
|
2024-06-09 10:37:42 +08:00
|
|
|
elseif t == 3 then
|
|
|
|
return num
|
|
|
|
end
|
2022-10-01 21:31:03 +08:00
|
|
|
end
|
|
|
|
|
2022-10-01 22:00:18 +08:00
|
|
|
function M.index_num(num)
|
2024-06-09 10:37:42 +08:00
|
|
|
local nums = { 8304, 185, 178, 179, 8308, 8309, 8310, 8311, 8312, 8313 }
|
|
|
|
if vim.fn.index(vim.fn.range(1, 10), num) ~= -1 then
|
|
|
|
return vim.fn.nr2char(nums[num + 1])
|
|
|
|
end
|
|
|
|
return ''
|
2022-10-01 22:00:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.parenthesized_num(num)
|
2024-06-09 10:37:42 +08:00
|
|
|
if vim.fn.index(vim.fn.range(1, 20), num) ~= -1 then
|
|
|
|
return vim.fn.nr2char(9331 + num)
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
2022-10-01 22:00:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.num_period(num)
|
2024-06-09 10:37:42 +08:00
|
|
|
if vim.fn.index(vim.fn.range(1, 20), num) ~= -1 then
|
|
|
|
return vim.fn.nr2char(9351 + num)
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
2022-10-01 22:00:18 +08:00
|
|
|
end
|
2022-10-01 21:16:22 +08:00
|
|
|
|
|
|
|
return M
|