|
|
|
<?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="2.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.
|
|
|
|
nnw <reply|new> Opens up an editor box so you can just type the whole note at once.
|
|
|
|
|
|
|
|
##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>
|
|
|
|
|
|
|
|
<alias
|
|
|
|
match="^nnw (new|reply)$"
|
|
|
|
enabled="y"
|
|
|
|
group="NoteHelper"
|
|
|
|
regexp="y"
|
|
|
|
send_to="12"
|
|
|
|
sequence="100"
|
|
|
|
>
|
|
|
|
<send>noteeditor("%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
|
|
|
|
|
|
|
|
function noteeditor(str)
|
|
|
|
local note, note_to, note_subj, note_to_send = false, false, false, false
|
|
|
|
if str == "new" then
|
|
|
|
note_to = utils.inputbox("To whom are you writing the note?", "To list", "all")
|
|
|
|
if note_to then
|
|
|
|
note_to_send = "note write " .. note_to
|
|
|
|
else
|
|
|
|
note_to_send = "note write all"
|
|
|
|
end
|
|
|
|
note_subj = utils.inputbox("What is the subject of your note?", "Subject")
|
|
|
|
if not note_subj then
|
|
|
|
note_subj = ""
|
|
|
|
end
|
|
|
|
elseif str == "reply" then
|
|
|
|
note_to = utils.inputbox("To which note are you replying?", "Note number")
|
|
|
|
note_to_send = "note reply " .. note_to or ""
|
|
|
|
end
|
|
|
|
|
|
|
|
Send(note_to_send)
|
|
|
|
|
|
|
|
if note_subj then
|
|
|
|
Send(note_subj)
|
|
|
|
end
|
|
|
|
|
|
|
|
note = utils.editbox("Write your note.", "Note Writer Box")
|
|
|
|
|
|
|
|
if note then
|
|
|
|
Send(".c")
|
|
|
|
for line in note:gmatch("[^%c]+%c?") do
|
|
|
|
Send(note_wrap(line))
|
|
|
|
Send(" ")
|
|
|
|
end
|
|
|
|
Send(".s")
|
|
|
|
else
|
|
|
|
Send(".q")
|
|
|
|
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>
|