-
Notifications
You must be signed in to change notification settings - Fork 15
/
Trace_Window.xml
135 lines (96 loc) · 2.79 KB
/
Trace_Window.xml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, February 05, 2009, 3:33 PM -->
<!-- MuClient version 4.37 -->
<!-- Plugin "Trace_Window" generated by Plugin Wizard -->
<muclient>
<plugin
name="Trace_Window"
author="Nick Gammon"
id="9c16895687a6b24f6202ac0c"
language="Lua"
purpose="Redirects trace to a miniwindow"
date_written="2009-02-05 17:00"
requires="4.37"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
-- configuration
-- window size in pixels
WINDOW_WIDTH = 600
WINDOW_HEIGHT = 300 -- 200 is 16 lines of 9-point Lucida Console
-- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9
-- where to put the window
WINDOW_POSITION = 6 -- see below (6 is top right)
--[[
Useful positions:
4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
--]]
-- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("khaki")
WINDOW_TEXT_COLOUR = ColourNameToRGB ("black")
-- offset of text from edge
TEXT_INSET = 5
-- where to store the trace line
lines = {} -- table of recent trace lines
-- display one line
function Display_Line (line, text)
local left = TEXT_INSET
local top = (line - 1) * font_height
WindowText (win, "f", text, left, top, WINDOW_WIDTH - TEXT_INSET, 0, WINDOW_TEXT_COLOUR)
end -- Display_Line
-- here on trace
function OnPluginTrace (line)
-- blank existing window contents
WindowRectOp (win, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
-- remove first line if filled up
if #lines >= max_lines then
table.remove (lines, 1)
end -- if
-- add new line, time-stamped
table.insert (lines, os.date ("%H:%M:%S ") .. line)
-- display all lines
for k, v in ipairs (lines) do
Display_Line (k, v)
end -- for
-- force window redisplay
WindowShow (win, true) -- show it
end -- end OnPluginTrace
-- hide window on removal
function OnPluginClose ()
WindowShow (win, false) -- hide it
end -- OnPluginClose
-- hide window on disable
function OnPluginDisable ()
WindowShow (win, false) -- hide it
end -- OnPluginDisable
-- show window on enable
function OnPluginEnable ()
if #lines > 0 then
WindowShow (win, true) -- show it
end -- if
end -- OnPluginEnable
-- startup stuff
win = GetPluginID () -- get a unique name
-- make the window
WindowCreate (win, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0,
WINDOW_BACKGROUND_COLOUR) -- create window
-- grab a font
WindowFont (win, "f", FONT_NAME, FONT_SIZE) -- define font
-- work out how high it is
font_height = WindowFontInfo (win, "f", 1) -- height of the font
-- work out how many lines will fit
max_lines = math.floor (WINDOW_HEIGHT / font_height)
]]>
</script>
</muclient>