You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
2.9 KiB
132 lines
2.9 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<!-- Saved on Sunday, August 16, 2015, 9:00 AM -->
|
|
<!-- MuClient version 4.98 -->
|
|
|
|
<!-- Plugin "Note_Write_Helper" generated by Plugin Wizard -->
|
|
|
|
<muclient>
|
|
<plugin
|
|
name="Note_Write_Helper"
|
|
author="Arcidayne"
|
|
id="291e6a78b7457b70ebf24375"
|
|
language="Lua"
|
|
purpose="Preformats long lines to break at 79 characters with respect to full words."
|
|
save_state="y"
|
|
date_written="2015-08-16 08:56:28"
|
|
requires="4.00"
|
|
version="1.0"
|
|
>
|
|
<description trim="y">
|
|
<![CDATA[
|
|
Instead of using the note formatter tool, or figuring out how long your line of text is, this plugin will do it for you!
|
|
|
|
nw <text> No indent character; takes a long line and formats linewraps it.
|
|
nwi <char> <text> Same as above, except it takes an indent character.
|
|
|
|
##Examples##
|
|
|
|
nw This is a long line of text that would be formatted to break at 79 characters with respect to the word boundaries.
|
|
|
|
returns
|
|
|
|
This is a long line of text that would be formatted to break at 79 characters with
|
|
respect to the word boundaries.
|
|
|
|
nwi > This is a long line of text that would be formatted to break at 79 characters with respect to the word boundaries.
|
|
|
|
returns
|
|
|
|
>This is a long line of text that would be formatted to break at 79 characters with
|
|
>respect to the word boundaries.
|
|
|
|
]]>
|
|
</description>
|
|
|
|
</plugin>
|
|
|
|
|
|
<!-- Aliases -->
|
|
|
|
<aliases>
|
|
<alias
|
|
match="^nw (.*)$"
|
|
enabled="y"
|
|
group="NoteHelper"
|
|
regexp="y"
|
|
send_to="12"
|
|
sequence="100"
|
|
>
|
|
<send>Send(note_wrap("%1"))</send>
|
|
</alias>
|
|
<alias
|
|
match="^nwi\s(.*?)\s(.*)$"
|
|
enabled="y"
|
|
group="NoteHelper"
|
|
regexp="y"
|
|
send_to="12"
|
|
sequence="100"
|
|
>
|
|
<send>Send(note_wrap("%2", 79, "%1"))</send>
|
|
</alias>
|
|
</aliases>
|
|
|
|
<!-- Script -->
|
|
|
|
|
|
<script>
|
|
<![CDATA[
|
|
function note_wrap(str, limit, indent, indent1)
|
|
indent = indent or ""
|
|
indent1 = indent1 or indent
|
|
limit = limit or 79
|
|
local here = 1-#indent1
|
|
local last_color = ''
|
|
return indent1..str:gsub("(%s+)()(%S+)()",
|
|
function(sp, st, word, fi)
|
|
local delta = 0
|
|
local color_before_current_word = last_color
|
|
word:gsub('()@([@%a])',
|
|
function(pos, c)
|
|
if c == '@' then
|
|
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)
|
|
here = here + delta
|
|
if fi-here > limit then
|
|
here = st - #indent + delta
|
|
return "\n"..indent..color_before_current_word..word
|
|
end
|
|
end)
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
|
|
<!-- Plugin help -->
|
|
|
|
<aliases>
|
|
<alias
|
|
script="OnHelp"
|
|
match="nw:help"
|
|
enabled="y"
|
|
>
|
|
</alias>
|
|
</aliases>
|
|
|
|
<script>
|
|
<![CDATA[
|
|
function OnHelp ()
|
|
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
</muclient>
|