Skip to content

Commit

Permalink
feat(line): update types
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim committed Jun 10, 2023
1 parent 9f7666d commit 1a8d824
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/nui/line/init.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
local Object = require("nui.object")
local NuiText = require("nui.text")
local defaults = require("nui.utils").defaults
local is_type = require("nui.utils").is_type

---@class NuiLine
---@field _texts NuiText[]
local Line = Object("NuiLine")

---@param texts? table[] NuiText objects
---@param texts? NuiText[]
function Line:init(texts)
self._texts = defaults(texts, {})
end

---@param content string|NuiText|NuiLine
---@param highlight? string|table data for highlight
---@param highlight? string|nui_text_extmark data for highlight
---@return NuiText|NuiLine
function Line:append(content, highlight)
local block = is_type("string", content) and NuiText(content, highlight) or content
local block = content
if type(block) == "string" then
block = NuiText(block, highlight)
end
if block._texts then
---@cast block NuiLine
for _, text in ipairs(block._texts) do
Expand Down

0 comments on commit 1a8d824

Please sign in to comment.