-
Notifications
You must be signed in to change notification settings - Fork 147
/
outputclone.lua
72 lines (64 loc) · 2.59 KB
/
outputclone.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
local id = ID("outputclone.outputclone")
local frame
return {
name = "Clone Output window",
description = "Clones Output window to keep it on the screen when the application loses focus (OSX).",
author = "Paul Kulchenko",
version = 0.42,
dependencies = "1.61",
onRegister = function(self)
local menu = ide:FindTopMenu("&View")
local pos = self.GetConfig and self:GetConfig().insertat and
self:GetConfig().insertat-1 or 4
menu:InsertCheckItem(pos, id, "Output Window Clone\tCtrl-Shift-C")
ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED,
function (event)
if not frame then
local output = ide:GetOutput()
frame = wx.wxFrame(ide:GetMainFrame(), wx.wxID_ANY, "Output Clone",
wx.wxDefaultPosition, wx.wxDefaultSize,
wx.wxDEFAULT_FRAME_STYLE + wx.wxFRAME_FLOAT_ON_PARENT)
local pos = self:GetSettings().pos
if pos and pos.x and pos.y and pos.w and pos.h then
frame:SetSize(pos.x, pos.y, pos.w, pos.h)
elseif ide:IsWindowShown(output) then
frame:SetClientSize(output:GetSize():GetWidth(), output:GetSize():GetHeight())
frame:Move(output:GetScreenPosition())
end
frame:Connect(wx.wxEVT_CLOSE_WINDOW,
function(event)
frame:Hide()
menu:Check(id, false)
event:Veto()
end)
local clone = wxstc.wxStyledTextCtrl(frame, wx.wxID_ANY,
wx.wxDefaultPosition, wx.wxSize(0, 0), wx.wxBORDER_STATIC)
local docpointer = output:GetDocPointer()
output:AddRefDocument(docpointer)
clone:SetDocPointer(docpointer)
if self:GetConfig().autoscroll ~= false then
clone:Connect(wxstc.wxEVT_STC_MODIFIED, function(event)
if bit.band(event:GetModificationType(), wxstc.wxSTC_MOD_INSERTTEXT) ~= 0 then
clone:ScrollToLine(clone:GetLineCount()-1)
end
end)
end
-- set styles to make it look similar to the output window
clone:MarkerDefine(StylesGetMarker("message"))
clone:MarkerDefine(StylesGetMarker("prompt"))
StylesApplyToEditor(ide:GetConfig().stylesoutshell,clone,output:GetFont())
end
frame:Show(event:IsChecked())
end)
end,
onUnRegister = function(self)
ide:RemoveMenuItem(id)
end,
onAppClose = function(self, app)
if not frame then return end
frame:Destroy()
local w, h = frame:GetSizeWH()
local x, y = frame:GetPositionXY()
self:SetSettings({pos = {w = w, h = h, x = x, y = y}})
end
}