local table = require 'std.table' local M = {} local function new(content, pos, firstc, prompt, indent, level) vim.validate({ content = { content, 'table' }, pos = { pos, 'number' }, firstc = { firstc, 'string' }, prompt = { prompt, 'string' }, indent = { indent, 'number' }, level = { level, 'number' }, }) return setmetatable({ content = content, pos = pos, firstc = firstc, prompt = prompt, indent = indent, level = level, }, { __index = M }) end local function text(self) local parts = {} for _, chunk in ipairs(self.content) do table.insert(parts, chunk[2]) end return table.concat(parts) end local function cursor_byte(self) return self.pos end local function is_search(self) return self.firstc == '/' or self.firstc == '?' end local function is_input(self) return self.prompt ~= nil and self.prompt ~= '' end M.new = new M.text = text M.cursor_byte = cursor_byte M.is_search = is_search M.is_input = is_input return M