Thank you for your answer. I finally chose rex.new method in my plugin and successfully drew styled captures.
Here's my code:
<trigger
enabled = "y"
match = "^[>\s]*Title:【\s+\S+\s*\S*\s+】.*(?:」| )\S+\(\w+\)$"
regexp = "y"
keep_evaluating = "y"
script = "DrawInfo"
sequence = "1"
>
</trigger>
function DrawInfo (_, line, wildcards, styles)
re = rex.new ("^[>\s]*Title:(【\s+\S+\s*\S*\s+】.*(?:」| ))\S+\(\w+\)$")
local _,_,column = re:exec (line)
local column_start,column_end = column[1],column[2]
DrawText (context, line, text_width, text_color, styles, column_start, column_end)
end
function DrawText (context, text, text_width, text_color, styles, column_start, column_end)
local text_x = 1
local text_y = 1
WindowRectOp (context.win, 2, text_x, text_y, text_x + text_width, text_y + text_height, background_colors) -- clear text row
if styles ~= nil then
local column = 0
for _,v in ipairs(styles) do
column = column + v.length
if column_start <= column then
text_color = v.textcolour
local column_text = string.sub (text, column_start, math.min(column, column_end))
WindowText (context.win, context.font.id, column_text, text_x, text_y, 0, 0, text_color)
if column_end > column then
text_x = text_x + WindowTextWidth(context.win, context.font.id, column_text)
column_start = column + 1
else
break
end
end
end
end
end
|