mirror of
https://github.com/Myzel394/easytables.nvim.git
synced 2025-06-18 14:55:26 +02:00
feat: Add poc for writing into cell
This commit is contained in:
parent
bd1c0dba89
commit
8273e5020b
@ -62,6 +62,7 @@ local function a()
|
|||||||
|
|
||||||
window:show()
|
window:show()
|
||||||
window:draw_table(own_table)
|
window:draw_table(own_table)
|
||||||
|
window:register_listeners(own_table)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -88,8 +88,6 @@ function M:_draw_highlight(table)
|
|||||||
local row = 1 + math.max(0, cell.row - 1) * 2
|
local row = 1 + math.max(0, cell.row - 1) * 2
|
||||||
local cell_start, cell_end = table:get_cell_positions(cell.col, cell.row, self.min_value_width)
|
local cell_start, cell_end = table:get_cell_positions(cell.col, cell.row, self.min_value_width)
|
||||||
|
|
||||||
print(cell_start, cell_end, row)
|
|
||||||
|
|
||||||
vim.api.nvim_buf_set_extmark(
|
vim.api.nvim_buf_set_extmark(
|
||||||
self.preview_buffer,
|
self.preview_buffer,
|
||||||
vim.api.nvim_create_namespace("easytables"),
|
vim.api.nvim_create_namespace("easytables"),
|
||||||
@ -133,4 +131,19 @@ function M:draw_table(table)
|
|||||||
self:_draw_highlight(table)
|
self:_draw_highlight(table)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M:register_listeners(table)
|
||||||
|
vim.api.nvim_buf_attach(self.prompt_buffer, false, {
|
||||||
|
on_lines = function(_, handle)
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(handle, 0, -1, false)
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
|
local selected_cell = table:get_highlighted_cell()
|
||||||
|
|
||||||
|
table:insert(selected_cell.col, selected_cell.row, lines[1])
|
||||||
|
self:draw_table(table)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Loading…
x
Reference in New Issue
Block a user