diff --git a/lua/Trans/component/content.lua b/lua/Trans/component/content.lua index 3c6f907..86c7e3b 100644 --- a/lua/Trans/component/content.lua +++ b/lua/Trans/component/content.lua @@ -38,6 +38,7 @@ function M:insert(items) indent = items.indent, highlight = items.highlight, } + local highlight = {} diff --git a/lua/Trans/component/items.lua b/lua/Trans/component/items.lua new file mode 100644 index 0000000..d1c775e --- /dev/null +++ b/lua/Trans/component/items.lua @@ -0,0 +1,20 @@ +local M = {} +M.__index = M +M.len = 0 + +function M:new() + local items = {} + setmetatable(items, self) + return items +end + +function M:insert(item, highlight) + table.insert(self, item) + self.len = self.len + #item +end + +function M:format(win_width) + +end + +return M diff --git a/lua/Trans/core/process.lua b/lua/Trans/core/process.lua index 71f91fa..dd2ef48 100644 --- a/lua/Trans/core/process.lua +++ b/lua/Trans/core/process.lua @@ -1,25 +1,28 @@ local type_check = require("Trans.util.debug").type_check -local function format(items, interval) +local function format(component, interval) end local function process (opts) type_check { opts = { opts, 'table' }, - ['opts.field'] = { opts.field, 'table' }, - ['opts.order'] = { opts.order, 'table' }, - ['opts.win'] = { opts.win, 'table' }, - ['opts.engine'] = { opts.engine, 'table' }, + ['opts.field'] = { opts.field , 'table' }, + ['opts.order'] = { opts.order , 'table' }, + ['opts.win'] = { opts.win , 'table' }, + ['opts.engine'] = { opts.engine , 'table' }, } local content = require('Trans.component.content'):new() for _, v in ipairs(opts.order) do - local items = format(require("Trans.component." .. opts.engine .. '.' .. v), 4) - content:insert(items) + local component = require("Trans.component." .. opts.engine .. '.' .. v) + for _, items in ipairs(component) do + format(items) + content:insert(items) + end end local lines, __highlight = content:data() diff --git a/lua/Trans/util/test/test.lua b/lua/Trans/util/test/test.lua index 7fa1b76..a5bd3c3 100644 --- a/lua/Trans/util/test/test.lua +++ b/lua/Trans/util/test/test.lua @@ -1,8 +1,8 @@ -local a = 'test' +local a = { + 'test1', + 'test2', + 'test3' +} -local b = a - -b = b .. 'test' - print(a, b)