local fdebug = createForm(false) fdebug.Caption = "Output" --fdebug.FormStyle = "fsNormal" --fdebug.Position = "poDefault" fdebug.ShowInTaskbar = "stNever" local fscript = getForm(1) --local tbox = fscript.findComponentByName("Assemblescreen") local tdebug = createTimer(fscript) tdebug.Interval = 1 fdebug.setBorderStyle(bsToolWindow) local ctbox = createMemo(fdebug) ctbox.BorderStyle = bsSingle local lpos = {Width = 0,Height = 0,Top = 0,Left = 0} local luaEngine = getLuaEngine() luaEngine.parent = fdebug luaEngine.top = -10000 luaEngine.cbShowOnPrint.Checked = false luaEngine.show() luaEngine.OnShow = function(sender) sender.hide() fdebug.show() end luaEngine.OnEnter = luaEngine.OnShow luaEngine.hide() processMessages() local mOutput = luaEngine.mOutput mOutput.Parent = fdebug mOutput.align = alClient mOutput.Visible = true mOutput.OnChange = function(sender) if (not fdebug.visible) then fdebug.show() end end local mPopup = createPopupMenu(mOutput) local menu_items = {} local undo_text = {} local itemData local mOutputPopupItems = { {name = 'Copy', func = function() writeToClipboard(mOutput.Lines.Text) end}, {name = 'Clear', func = function() undo_text = mOutput.Lines.Text mOutput.Lines.Text = '' menu_items['Undo'].enabled = true end}, {name = 'Clear Selection', func = function() undo_text = mOutput.Lines.Text mOutput.clearSelection() menu_items['Undo'].enabled = true end}, {name = 'Undo',enabled = false, func = function() if undo_text then mOutput.Lines.Text = undo_text undo_text = false menu_items['Undo'].enabled = false end end}, } for _,itemData in pairs(mOutputPopupItems) do local item = createMenuItem(mPopup) item.Caption = itemData.name item.OnClick = itemData.func if itemData.enabled ~= nil then item.enabled = itemData.enabled end mPopup.Items.add(item) menu_items[itemData.name] = item end menu_items['Undo'].enabled = false mOutput.PopupMenu = mPopup --[[fdebug.OnClose = function(s) return caHide end]] local function comparePosAndSizeWithPreserved(o) return o.Width == lpos.Width and o.Height == lpos.Height and o.Left == lpos.Left and o.Top == lpos.Top end local function preservePosAndSize(o) lpos.Width = o.Width lpos.Height = o.Height lpos.Top = o.Top lpos.Left = o.Left end fdebug.OnActivate = function(sender) --fscript.bringToFront() --ctbox.setFocus() end --[[fdebug.OnClick = function(sender) fscript.bringToFront() ctbox.focus() end]] fscript.OnDeactivate = function(sender) --fdebug.sendToBack() end function fdebug:updatePosition(parent) --print(tostring(comparePosAndSizeWithPreserved(parent))) if parent.WindowState == "wsNormal" and comparePosAndSizeWithPreserved(parent) == false then self.Width = parent.Width self.Height = 100 self.Top = parent.Top + parent.Height + 31 self.Left = parent.Left + 5 preservePosAndSize(parent) end end tdebug.OnTimer = function(timer) fdebug:updatePosition(fscript) end fdebug:updatePosition(fscript) tdebug.Enabled = true function ctbox:updateSize() local parent = self.getParent() self.Width = parent.Width self.Height = parent.Height end ctbox:updateSize() ctbox.Visible = true fdebug.OnResize = function(s) ctbox:updateSize() end fdebug.OnClose = function(s) return caHide end fscript.OnResize = function(s) fdebug:updatePosition(s) end fscript.OnHide = function(s) fdebug.hide() end fscript.OnClose = function(s) fdebug.close() return caHide end fscript.OnShow = function(s) fdebug.show() end fscript.registerFirstShowCallback(function(s) s.centerScreen() end) fscript.OnWindowStateChange = function(sender) if sender.WindowState == "wsNormal" then fdebug.show() elseif sender.WindowState == "wsMaximized" then fdebug.hide() elseif sender.WindowState == "wsMinimized" then fdebug.hide() elseif sender.WindowState == "wsFullScreen" then fdebug.hide() end end