refactor: remove conf.query, use conf.frontend.query
This commit is contained in:
@@ -7,6 +7,10 @@ local util = require('Trans').util
|
||||
|
||||
---@class TransItem : TransNode
|
||||
local item_meta = {
|
||||
---@param self TransItem
|
||||
---@param buffer TransBuffer
|
||||
---@param line integer
|
||||
---@param col integer
|
||||
render = function(self, buffer, line, col)
|
||||
if self[2] then
|
||||
buffer:add_highlight(line, self[2], col, col + #self[1])
|
||||
@@ -25,7 +29,7 @@ local text_meta = {
|
||||
render = function(self, buffer, line, col)
|
||||
local nodes = self.nodes
|
||||
local step = self.step
|
||||
local len = step and #step or 0
|
||||
local len = step and #step or 0
|
||||
|
||||
for _, node in ipairs(nodes) do
|
||||
node:render(buffer, line, col)
|
||||
@@ -48,7 +52,7 @@ end
|
||||
|
||||
|
||||
---@param nodes {[number]: TransNode, step: string?}
|
||||
---@return table
|
||||
---@return TransText
|
||||
local function text(nodes)
|
||||
return setmetatable({
|
||||
[1] = table.concat(util.list_fields(nodes, 1), nodes.step),
|
||||
@@ -59,6 +63,7 @@ end
|
||||
|
||||
|
||||
---@param args {[number]: TransNode, width: integer, spin: string?}
|
||||
---@return TransText
|
||||
local function format(args)
|
||||
local width = args.width
|
||||
local spin = args.spin or " "
|
||||
@@ -68,11 +73,11 @@ local function format(args)
|
||||
wid = wid + args[i][1]:width()
|
||||
end
|
||||
|
||||
local space = math.max(math.floor((width - wid) / (size - 1)), 0)
|
||||
|
||||
args.step = spin:rep(space)
|
||||
args.width = nil
|
||||
args.spin = nil
|
||||
local space = math.max(math.floor((width - wid) / (size - 1)), 0)
|
||||
args.step = spin:rep(space)
|
||||
args.width = nil
|
||||
args.spin = nil
|
||||
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
return text(args)
|
||||
|
Reference in New Issue
Block a user