For a few games, and I'd like to be able to get rid of timestamps as regular text, and instead be able to hover over
text in the MW and have it pull the line timestamp from there.
This would most likely require the ability to call a function with the hotspot tooltip, and the function would need be given the current mouse x/y coordinates as well.
Observe where it says "-- inject timestamp if wanted".
Instead of inserting a styled timestamp string into the styles table, skip down to the next part where it says "-- store the raw lines for use during resizing".
Replace " table.insert(rawlines, styles)" with something like " table.insert(rawlines, {styles, os.date (date_format)}), which then requires you to remember that now rawlines contains a list of pairs of two things, one of which is a raw line, instead of just a list of raw lines. Likewise change " fillBuffer(styles)" to " fillBuffer({styles, os.date(date_format)})"
Note that this now means that "for _,styles in ipairs(rawlines)" in init will be passing a table of both styles and a timestamp to fillBuffer.
Then at the top of fillBuffer, add "local timestamp = rawstyles[2]; local rawstyles = rawstyles[1]" to split them apart and get everything back to functioning.
Then inside fillBuffer change " add_line( line_styles, beginning )" to " add_line( line_styles, beginning, timestamp )".
Then go change the add_line function to take a third argument "timestamp".
Then in add_line, change " table.insert (lines, {line, false} )" to " table.insert (lines, {line, is_beginning_of_message, timestamp} )".
Note here how silly I was when adding the next line, doing an assignment after insertion instead of just inserting the right thing in the first place. Oops. No matter; it doesn't hurt anything.
Finally...
Notice how we find the right line in GetBufferedMessage. (" windowline = math.floor(((ypos-theme.TITLE_HEIGHT)/line_height)+1)-1"; if (#lines > windowline) then local line = windowline+lineStart)").
Thus, lines[windowline+lineStart][3] should give the timestamp you want with WindowInfo(Win,15) as ypos.
Ah, I went ahead and implemented a different way before
seeing your reply Fiendish.
Figured I'd go ahead and share the whole plugin, since I've added some enhancements that may be useful to others.
Some of this is only useful to the MUSH it was meant but, but eh.
* Supports slave windows (unlimited number of them) -- each trigger must be setup in the code though.
* Last 500 lines in each window is saved across sessions
* You can now rename the windows
* Spam filtering for subspace messages: If you get an updated 'status' message, it replaces the old line instead of adding additional spam to your window.
* Toggle-able tooltip timestamps (timestamps show as tooltips when you hover, instead of always visible). You can switch it on the fly.
* You can now search the window for matching text (using lua regex-style matches), it will hilite matching lines and display them.