@ -6,24 +6,54 @@
<!-- Plugin "RoomCharWindow" generated by Plugin Wizard -->
<!-- Plugin "RoomCharWindow" generated by Plugin Wizard -->
<muclient >
<muclient >
<plugin name= "NoteWindow" author= "Crowley" id= "c49e43d9dce931263263088b" language= "Lua" purpose= "Note output and hyperlinks" save_state= "y" date_written= "2022-03-09 11:02:09" requires= "5.07" version= "1.0" sequence= "10" >
<plugin
name="NoteWindow"
</plugin>
author="Crowley"
<!-- Aliases -->
id="c49e43d9dce931263263088b"
language="Lua"
<aliases >
purpose="Note output and hyperlinks"
<alias match= "^(note(?: read(?: \d+| last| again)?)?)$" enabled= "y" regexp= "y" script= "startNoteRead" sequence= "100" >
save_state="y"
date_written="2022-03-09 11:02:09"
requires="5.07"
version="1.0"
sequence="10"
>
</plugin>
<!-- Aliases -->
<aliases >
<alias
match="^(note(?: read(?: \d+| last| again)?)?)$"
enabled="y"
regexp="y"
script="startNoteRead"
sequence="100"
>
</alias>
</alias>
<alias match= "^notewin (on|off|show|hide|clear|help)$" enabled= "y" regexp= "y" ignore_case= "y" script= "toggleNoteWin" sequence= "100" >
<alias
match="^notewin (on|off|show|hide|clear|help)$"
enabled="y"
regexp="y"
ignore_case="y"
script="toggleNoteWin"
sequence="100"
>
</alias>
</alias>
<alias match= "^(note\s?(?:list(?:\s\d+)?|unread|to\s\w+|from\s\w+|subj\s.+)?)$" enabled= "y" regexp= "y" script= "startNoteList" sequence= "100" >
<alias
match="^(note\s?(?:list(?:\s\d+)?|unread|to\s\w+|from\s\w+|subj\s.+)?)$"
enabled="y"
regexp="y"
script="startNoteList"
sequence="100"
>
</alias>
</alias>
</aliases>
</aliases>
<script >
<script >
< ![CDATA[
< ![CDATA[
local extras = require "aard_lua_extras"
local extras = require "aard_lua_extras"
require "gmcphelper"
require "gmcphelper"
local snapshotV = tonumber(extras.PackageVersion())
local snapshotV = tonumber(extras.PackageVersion())
@ -97,39 +127,35 @@ function addToWindow(lines)
NotesWin:show()
NotesWin:show()
end
end
function findBoundaries(tbl)
local start_idx = 1
while start_idx< = #tbl and not tbl[start_idx][2]:find("~") and not tbl[start_idx][2]:find("No more new posts") do
start_idx = start_idx + 1
end
local end_idx = #tbl
function findBoundaries(lines)
while end_idx >= 1 and not tbl[end_idx][2]:find("~") and not tbl[end_idx][2]:find("There are no new") do
local first_index = nil
end_idx = end_idx - 1
local last_index = nil
end
if start_idx > 1 then
-- Find the first and last indices with ~ in the text field
table.remove(tbl, 1)
for i, v in ipairs(lines) do
start_idx = start_idx - 1
if (string.find(v[1].text, "~") or string.find(v[1].text, "No more new posts")) and not first_index then
first_index = i
end
end
if (string.find(v[1].text, "~") or string.find(v[1].text, "There are no new")) then
if end_idx < #tbl then
last_index = i
table.remove(tbl)
end_idx = end_idx - 1
end
end
for i = end_idx, start_idx, -1 do
table.remove(tbl, i)
end
end
local lines = {}
-- Remove all the entries before the first ~ and after the last ~
for _, entry in ipairs(tbl) do
if first_index and last_index then
table.insert(lines, entry[2])
for i = #lines, last_index + 1, -1 do
table.remove(lines, i)
end
for i = first_index - 1, 1, -1 do
table.remove(lines, i)
end
end
end
return lines
return lines
end
end
function hyperlinknotes(lines)
function hyperlinknotes(lines)
for i,v in ipairs(findBoundaries(lines)) do
for i,v in ipairs(findBoundaries(lines)) do
if i < 5 o r i = = # l i n e s t h e n
if i < 5 o r i = = # l i n e s t h e n
@ -148,36 +174,29 @@ function hyperlinknotes(lines)
end
end
function toggleNoteWin(name, line, wildcards)
function toggleNoteWin(name, line, wildcards)
local noteOpt = wildcards[1]
if wildcards[1] == "on" or wildcards[1] == "show" then
if noteOpt == "on" then
noteShow = "true"
noteShow = "true"
SetVariable("noteShow", noteShow)
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in window." )
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1] )
elseif noteOpt == "off " then
elseif wildcards[1] == "off" or wildcards[1] == "hide " then
noteShow = "false"
noteShow = "false"
SetVariable("noteShow", noteShow)
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in main output.")
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
elseif noteOpt == "show" then
elseif wildcards[1] == "clear" then
NotesWin:fit_contents(850, 500)
NotesWin:show()
elseif noteOpt == "hide" then
NotesWin:hide()
elseif noteOpt == "clear" then
NotesWin:clear(false)
NotesWin:clear(false)
NotesWin:hide()
NotesWin:hide()
elseif noteOpt == "help" then
ColourNote("white", "blue", "Clearing Note Window...")
elseif wildcards[1] == "help" then
onHelp()
onHelp()
end
end
end
end
function onHelp()
function onHelp()
ColourNote("yellow", "", "Basic commands:")
ColourNote("yellow", "", "Basic commands:")
ColourNote("orange", "", string.format("%-30s - %s", "notewin <on | o f f > ", "Toggles where notes are displayed (window or output)."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin <on | s h o w | o f f | h i d e > ", "Toggles the display of the note window."))
ColourNote("orange", "", string.format("%s-30s - %s", "notewin <show | h i d e > ", "Shows or hides the note window."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin clear", "Clears the note window of existing content."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin clear", "Clears the note window of existing content."))
end
end
]]>
]]>
</script>
</script>
</muclient>
</muclient>