function ResizeMoveCallback()
posx, posy = WindowInfo (Win, 17), WindowInfo (Win, 18)
if (WindowTextWidth(Win, "titlefont"..Win, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH <= WINDOW_WIDTH+posx-startx) then
WINDOW_WIDTH = WINDOW_WIDTH+posx-startx
startx = posx
end -- if
if (3*SCROLL_BAR_WIDTH+10+line_height+theme.TITLE_HEIGHT <= WINDOW_HEIGHT+posy-starty) then
WINDOW_HEIGHT = WINDOW_HEIGHT+posy-starty
starty = posy
end -- if
init(false)
end -- function ResizeMoveCallback
function ResizeReleaseCallback()
WINDOW_HEIGHT = theme.TITLE_HEIGHT+(line_height*(WINDOW_LINES-1))+3
init(true)
end -- ResizeReleaseCallback
function OnPluginInstall()
-- Dummy window to get font characteristics
check (WindowCreate (Win, 0, 0, 1, 1, 0, 0, theme.WINDOW_BACKGROUND) )
check (WindowFont(Win, "bodyfont"..Win, BODY_FONT_NAME, BODY_FONT_SIZE))
check (WindowFont(Win, "titlefont"..Win, theme.TITLE_FONT_NAME, theme.TITLE_FONT_SIZE))
font_height = WindowFontInfo (Win, "bodyfont"..Win, 1) - WindowFontInfo (Win, "bodyfont"..Win, 4) + 1
line_height = font_height+1
font_width = WindowTextWidth (Win, "bodyfont"..Win, "W")
-- install the window movement handler, get back the window position
windowinfo = movewindow.install (Win, miniwin.pos_top_right, miniwin.create_absolute_location, true)
-- check for Echo/Timestamp/date_format/window size (in pixels) variables, if not there, set them
if date_format == nil then
date_format = "[%d %b %H:%M:%S] "
end -- if
if WINDOW_WIDTH == nil then
WINDOW_WIDTH = (font_width*80)+SCROLL_BAR_WIDTH -- 80 columns
end
if WINDOW_HEIGHT == nil then
WINDOW_HEIGHT = theme.TITLE_HEIGHT+(line_height*6)+2 -- 6 lines
end -- if
init(true)
OnPluginEnable () -- do initialization stuff
end -- function OnPluginInstall
function init(firstTime)
-- how many lines and columns will fit?
WINDOW_LINES = math.ceil((WINDOW_HEIGHT-theme.TITLE_HEIGHT)/line_height)
WINDOW_COLUMNS = math.ceil((WINDOW_WIDTH-SCROLL_BAR_WIDTH)/font_width)
if firstTime then
WindowCreate(Win, windowinfo.window_left, windowinfo.window_top, WINDOW_WIDTH, WINDOW_HEIGHT, windowinfo.window_mode, windowinfo.window_flags, theme.WINDOW_BACKGROUND)
-- catch for right-click menu and line selection
WindowAddHotspot(Win, "textarea", 0, theme.TITLE_HEIGHT, WINDOW_WIDTH-SCROLL_BAR_WIDTH,0,
"", "", "MouseDown", "CancelMouseDown", "MouseUp", "",
miniwin.cursor_ibeam, 0)
-- add the drag handler so they can move the window around
movewindow.add_drag_handler (Win, 0, 0, 0, theme.TITLE_HEIGHT)
-- scroll bar up/down buttons
WindowAddHotspot(Win, "up", WINDOW_WIDTH-SCROLL_BAR_WIDTH, theme.TITLE_HEIGHT, 0, theme.TITLE_HEIGHT+SCROLL_BAR_WIDTH,
"MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
miniwin.cursor_hand, 0)
WindowAddHotspot(Win, "down", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-(2*SCROLL_BAR_WIDTH), 0, WINDOW_HEIGHT-SCROLL_BAR_WIDTH,
"MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
miniwin.cursor_hand, 0)
-- add the resize widget hotspot
WindowAddHotspot(Win, "resizer", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-SCROLL_BAR_WIDTH, WINDOW_WIDTH, WINDOW_HEIGHT,
"MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
miniwin.cursor_nw_se_arrow, 0)
WindowDragHandler(Win, "resizer", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
else
WindowResize(Win, WINDOW_WIDTH, WINDOW_HEIGHT, theme.WINDOW_BACKGROUND)
WindowMoveHotspot(Win, "textarea", 0, theme.TITLE_HEIGHT, WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0)
WindowMoveHotspot(Win, "up", WINDOW_WIDTH-SCROLL_BAR_WIDTH, theme.TITLE_HEIGHT, 0, theme.TITLE_HEIGHT+SCROLL_BAR_WIDTH)
WindowMoveHotspot(Win, "down", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-(2*SCROLL_BAR_WIDTH), 0, WINDOW_HEIGHT-SCROLL_BAR_WIDTH)
WindowMoveHotspot(Win, "resizer", WINDOW_WIDTH-SCROLL_BAR_WIDTH, WINDOW_HEIGHT-SCROLL_BAR_WIDTH, WINDOW_WIDTH, 0)
end -- if
WindowShow(Win, true)
if (firstTime == true) then
lines = {}
for _,styles in ipairs(rawlines) do
fillBuffer(styles)
end -- for each line
end -- if
lineStart = math.max(1, #lines-WINDOW_LINES+2)
lineEnd = math.max(1, #lines)
refresh()
end -- function init
Continues... |