Since I cleaned up my plugins a bit I created a library that holds commonly used functions and allows the actual functionality I added to be used without having to use my "display" classes, you can do the follow things:
Load the library class:
require("hk")
Convert from RGBA table (255, 255, 255, 255) to cairo format (1, 1, 1, 1)
mycolor = {255, 255, 255, 255 ]
local red, green, blue, alpha = hk.convert_rgb(mycolor)
Get the current IP:
hk.storemyip() -- Will create a file that holds the current IP/Will refresh that file
local myvar = hk.getmyip() -- Will read that file and store the IP in myvar
Execute a program without a cmd.com window popping up:
local mycmd="notepad.exe"
local myparam="C:\test\test.txt"
hk.ExecuteMe(mycmd, myparam)
Break a line into multiple lines (stored as table fields) at most maxlength characters long:
-- font has to be selected before this
mytable=hk.multiline(text,maxlength)
Display a multiline of arbitrary length on screen with only the actually filled lines having a background:
hk.paintmultiline(cr, multiline,width,line) -- width being the width of the plugin and automatically detected; cairo.move_to(cr, 0, line)
Write a text in cairo with one function call instead of lots:
hk.writetextincairo(cr, text, line, hk.text_color, xoffset ) -- see hk.text_color for the format; cairo.move_to(cr, xoffset, line)
Display a scrollbar that scrolls to the end, waits a few calls long and scrolls back:
local currentposition=0
local waitfor=5 -- how many calls to wait at end of text
local tmpwaitfor=waitfor -- sort of ugly
local scrolllength=40 -- how many characters do you expect to be able to display (depends on the font)
loop
text="some text, one liners only"
length=string.len(text)
currentposition, tmpwaitfor = hk.scrollbar_backandforth(text, waitfor, length, scrolllength, currentposition)
hk.writetextincairo(cr, text, 1, hk.text_color, currentposition ) -- see hk.text_color for the format
end
Known Issues:
*utf8 characters are counted as two characters as far as length is concerned
Get the song now playing in foobar2k (requires now playing simple foobar2k component):
local mysong, mysonglengthincharacters = hk.getfb2ksong()
Get any active speakers in your TS3 channel (requires honkiformer TS3 lua plugin):
local issomeonespeaking, whoisspeaking = hk.getts3active()
Miranda (requires msg-export for miranda):
Get the most recent miranda message:
message, nick, hour, minute, message = hk.getmirrecent()
Get the currently "active" message (see displayfor, mynick, mirnickspacer and mirmsgspacer in hk.lua):
message, hour, minute, second, messagelength, msgchanged = hk.getmiractive() --msgchanged is 0 when there is a new message, message is 0 if there is no "active" message at all