mirror of
https://github.com/Myzel394/easytables.nvim.git
synced 2025-06-18 23:05:27 +02:00
71 lines
1.5 KiB
Lua
71 lines
1.5 KiB
Lua
local Input = require("nui.input")
|
|
local event = require("nui.utils.autocmd").event
|
|
local table = require("easytables.table")
|
|
local window = require("easytables.window")
|
|
|
|
local function create_win()
|
|
end
|
|
|
|
local function show_table_builder(rows, cols)
|
|
create_win()
|
|
end
|
|
|
|
local function get_size()
|
|
local dialog_input = Input({
|
|
position = "50%",
|
|
size = {
|
|
width = 60,
|
|
},
|
|
border = {
|
|
style = "single",
|
|
text = {
|
|
top = "[What's the size of your table?]",
|
|
top_align = "center",
|
|
},
|
|
},
|
|
win_options = {
|
|
winhighlight = "Normal:Normal,FloatBorder:Normal",
|
|
},
|
|
}, {
|
|
prompt = "> ",
|
|
default_value = "3x3",
|
|
on_submit = function(value)
|
|
_, _, rows, create_singular, cols = string.find(value, "(%d+)(x?)(%d*)")
|
|
|
|
if cols == "" then
|
|
if create_singular == "x" then
|
|
cols = "1"
|
|
else
|
|
cols = rows
|
|
end
|
|
end
|
|
|
|
rows = tonumber(rows)
|
|
cols = tonumber(cols)
|
|
|
|
show_table_builder(rows, cols)
|
|
end,
|
|
})
|
|
|
|
dialog_input:mount()
|
|
|
|
dialog_input:on(event.BufLeave, function()
|
|
dialog_input:unmount()
|
|
end)
|
|
end
|
|
|
|
local function a()
|
|
local own_table = table:create(6, 3)
|
|
|
|
local window = window:create(own_table)
|
|
|
|
window:show()
|
|
window:draw_table()
|
|
window:register_listeners()
|
|
end
|
|
|
|
return {
|
|
a = a,
|
|
get_size = get_size,
|
|
}
|