So off the top of my head...
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. |