forked from adbensi/cammill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostprocessor.lua
139 lines (121 loc) · 2.25 KB
/
postprocessor.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
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
136
137
138
139
require("math")
about_text = ""
os.setlocale("C")
ModalTable = {}
scale = 1
function trim(s)
return s:find'^%s*$' and '' or s:match'^%s*(.*%S)'
end
post = {}
post.Text = function (...)
if arg then
for i,v in ipairs(arg) do
out = string.format("%s", v)
append_output(out)
end
end
end
post.ModalText = function (str)
--- if (ModalTable.txt == str) then
--- else
append_output(str)
--- end
--- ModalTable.txt = str
end
post.Number = function (val, nformat)
if (nformat == "0") then
out = string.format("%i", val)
elseif (nformat == nil) then
out = string.format("%f", val)
else
out = ""
vstr = string.format("%0.10f", val)
fstr = nformat:sub(3,-1)
bs = ""
bds = ""
ads = ""
ad = 1
d = 0
fr = 0
for c in vstr:gmatch"." do
if (c == ".") then
d = 1
else
if (d == 1) then
if (fstr:sub(ad,ad) == "#") then
if (c == "0") then
bs = bs..c
else
ads = ads..bs..c
bs = ""
end
elseif (fstr:sub(ad,ad) == "0") then
ads = ads..c
end
if (frc == "#") then
fr = ad
end
ad = ad + 1
else
bds = bds..c
end
end
end
out = bds
if (ads == "") then
else
out = out.."."..ads
end
end
append_output(out)
end
post.ModalNumber = function (str, val, nformat)
mstr = trim(str)
--if (ModalTable[mstr] == val) then
--else
out = string.format("%s", str)
append_output(out)
post.Number(val, nformat)
--end
ModalTable[mstr] = val
end
post.NonModalNumber = function (str, val, nformat)
out = string.format("%s", str)
append_output(out)
post.Number(val, nformat)
end
post.Eol = function ()
append_output("\n")
end
post.Warning = function (str)
io.write("(WARNING: ", str, ")\n")
end
post.SetCommentChars = function (str)
-- io.write("(SetCommentChars: ", str, ")\n")
end
post.ForceExtension = function (str)
set_extension(str)
end
post.ArcAsMoves = function (str)
end
event = {}
function event:GetTextCtrl ()
local res = o or {}
setmetatable(res, self)
self.__index = self
about_text = ""
ModalTable = nil
ModalTable = {}
return res
end
function event:AppendText (str)
about_text = about_text..str
output_info(about_text)
end
function load_post ()
dofile(postfile)
end
function reset_modal ()
ModalTable = nil
ModalTable = {}
end