|
|
@ -81,20 +81,27 @@ function note_wrap(str, limit, indent, indent1)
|
|
|
|
indent1 = indent1 or indent
|
|
|
|
indent1 = indent1 or indent
|
|
|
|
limit = limit or 79
|
|
|
|
limit = limit or 79
|
|
|
|
local here = 1-#indent1
|
|
|
|
local here = 1-#indent1
|
|
|
|
|
|
|
|
local last_color = ''
|
|
|
|
return indent1..str:gsub("(%s+)()(%S+)()",
|
|
|
|
return indent1..str:gsub("(%s+)()(%S+)()",
|
|
|
|
function(sp, st, word, fi)
|
|
|
|
function(sp, st, word, fi)
|
|
|
|
local delta = 0
|
|
|
|
local delta = 0
|
|
|
|
word:gsub('@([@%a])',
|
|
|
|
local color_before_current_word = last_color
|
|
|
|
function(c)
|
|
|
|
word:gsub('()@([@%a])',
|
|
|
|
if c == '@' then delta = delta + 1
|
|
|
|
function(pos, c)
|
|
|
|
elseif c == 'x' then delta = delta + 5
|
|
|
|
if c == '@' then
|
|
|
|
else delta = delta + 2
|
|
|
|
delta = delta + 1
|
|
|
|
|
|
|
|
elseif c == 'x' then
|
|
|
|
|
|
|
|
delta = delta + 5
|
|
|
|
|
|
|
|
last_color = word:sub(pos, pos+4)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
delta = delta + 2
|
|
|
|
|
|
|
|
last_color = word:sub(pos, pos+1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
here = here + delta
|
|
|
|
here = here + delta
|
|
|
|
if fi-here > limit then
|
|
|
|
if fi-here > limit then
|
|
|
|
here = st - #indent + delta
|
|
|
|
here = st - #indent + delta
|
|
|
|
return "\n"..indent..word
|
|
|
|
return "\n"..indent..color_before_current_word..word
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|