@ -6,54 +6,24 @@
<!-- Plugin "RoomCharWindow" generated by Plugin Wizard -->
<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>
<!-- Aliases -->
<aliases >
<alias
match="^(note(?: read(?: \d+| last| again)?)?)$"
enabled="y"
regexp="y"
script="startNoteRead"
sequence="100"
>
</alias>
<alias
match="^notewin (on|off|show|hide|clear|help)$"
enabled="y"
regexp="y"
ignore_case="y"
script="toggleNoteWin"
sequence="100"
>
</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>
</aliases>
<script >
< ![CDATA[
<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>
<!-- Aliases -->
<aliases >
<alias match= "^(note(?: read(?: \d+| last| again)?)?)$" enabled= "y" regexp= "y" script= "startNoteRead" sequence= "100" >
</alias>
<alias match= "^notewin (on|off|show|hide|clear|help)$" enabled= "y" regexp= "y" ignore_case= "y" script= "toggleNoteWin" sequence= "100" >
</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>
</aliases>
<script >
< ![CDATA[
local extras = require "aard_lua_extras"
require "gmcphelper"
local snapshotV = tonumber(extras.PackageVersion())
@ -127,37 +97,41 @@ function addToWindow(lines)
NotesWin:show()
end
function findBoundaries(lines)
local first_index = nil
local last_index = nil
-- Find the first and last indices with ~ in the text field
for i, v in ipairs(lines) do
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
if (string.find(v[1].text, "~") or string.find(v[1].text, "There are no new")) then
last_index = i
end
end
-- Remove all the entries before the first ~ and after the last ~
if first_index and last_index then
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
return lines
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
while end_idx >= 1 and not tbl[end_idx][2]:find("~") and not tbl[end_idx][2]:find("There are no new") do
end_idx = end_idx - 1
end
if start_idx > 1 then
table.remove(tbl, 1)
start_idx = start_idx - 1
end
if end_idx < #tbl then
table.remove(tbl)
end_idx = end_idx - 1
end
for i = end_idx, start_idx, -1 do
table.remove(tbl, i)
end
local lines = {}
for _, entry in ipairs(tbl) do
table.insert(lines, entry[2])
end
return lines
end
function hyperlinknotes(lines)
for i,v in ipairs(findBoundaries(lines)) do
for i,v in ipairs(extract_lin es(lines)) do
if i < 5 o r i = = # l i n e s t h e n
Simulate(stylesToANSI(v) .. "\n")
else
@ -174,31 +148,36 @@ function hyperlinknotes(lines)
end
function toggleNoteWin(name, line, wildcards)
if wildcards[1] == "on" or wildcards[1] == "show" then
local noteOpt = wildcards[1]
if noteOpt == "on" then
noteShow = "true"
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
NotesWin:show()
elseif wildcards[1] == "off" or wildcards[1] == "hide" then
ColourNote("white", "blue", "Note Extender: Displaying notes in window.")
elseif noteOpt == "off" then
noteShow = "false"
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
ColourNote("white", "blue", "Note Extender: Displaying notes in main output.")
elseif noteOpt == "show" then
NotesWin:fit_contents(850, 500)
NotesWin:show()
elseif noteOpt == "hide" then
NotesWin:hide()
elseif wildcards[1] == "clear" then
elseif noteOpt == "clear" then
NotesWin:clear(false)
NotesWin:hide()
ColourNote("white", "blue", "Clearing Note Window...")
elseif wildcards[1] == "help" then
elseif noteOpt == "help" then
onHelp()
end
end
function onHelp()
ColourNote("yellow", "", "Basic commands:")
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("%-30s - %s", "notewin <on | o f f > ", "Toggles where notes are displayed (window or output)."))
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."))
end
]]>
</script>
</script>
</muclient>