-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathperipheralsinfo.lua
2085 lines (1815 loc) · 44.5 KB
/
peripheralsinfo.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--Imported from class
-- From http://lua-users.org/wiki/SimpleLuaClasses
-- class.lua
-- Compatible with Lua 5.1 (not 5.0).
local class = { }
function class.class(base, init)
local c = {} -- a new class instance
if not init and type(base) == 'function' then
init = base
base = nil
elseif type(base) == 'table' then
-- our new class is a shallow copy of the base class!
for i,v in pairs(base) do
c[i] = v
end
c._base = base
end
-- the class will be the metatable for all its objects,
-- and they will look up their methods in it.
c.__index = c
-- expose a constructor which can be called by <classname>(<args>)
local mt = {}
mt.__call =
function(class_tbl, ...)
local obj = {}
setmetatable(obj,c)
--if init then
-- init(obj,...)
if class_tbl.init then
class_tbl.init(obj, ...)
else
-- make sure that any stuff from the base class is initialized!
if base and base.init then
base.init(obj, ...)
end
end
return obj
end
c.init = init
c.is_a =
function(self, klass)
local m = getmetatable(self)
while m do
if m == klass then return true end
m = m._base
end
return false
end
setmetatable(c, mt)
return c
end
--Imported from Logger
local Logger = { }
local debugMon
local logServerId
local logFile
local logger = screenLogger
local filteredEvents = {}
local function nopLogger(text)
end
local function monitorLogger(text)
debugMon.write(text)
debugMon.scroll(-1)
debugMon.setCursorPos(1, 1)
end
local function screenLogger(text)
local x, y = term.getCursorPos()
if x ~= 1 then
local sx, sy = term.getSize()
term.setCursorPos(1, sy)
--term.scroll(1)
end
print(text)
end
local function wirelessLogger(text)
if logServerId then
rednet.send(logServerId, {
type = 'log',
contents = text
})
end
end
local function fileLogger(text)
local mode = 'w'
if fs.exists(logFile) then
mode = 'a'
end
local file = io.open(logFile, mode)
if file then
file:write(text)
file:write('\n')
file:close()
end
end
local function setLogger(ilogger)
logger = ilogger
end
function Logger.disableLogging()
setLogger(nopLogger)
end
function Logger.setMonitorLogging(logServer)
debugMon = Util.wrap('monitor')
debugMon.setTextScale(.5)
debugMon.clear()
debugMon.setCursorPos(1, 1)
setLogger(monitorLogger)
end
function Logger.setScreenLogging()
setLogger(screenLogger)
end
function Logger.setWirelessLogging(id)
if id then
logServerId = id
end
setLogger(wirelessLogger)
end
function Logger.setFileLogging(fileName)
logFile = fileName
fs.delete(fileName)
setLogger(fileLogger)
end
function Logger.log(value)
if type(value) == 'table' then
for k,v in pairs(value) do
logger(k .. '=' .. tostring(v))
end
else
logger(tostring(value))
end
end
function Logger.logNestedTable(t, indent)
for _,v in ipairs(t) do
if type(v) == 'table' then
log('table')
logNestedTable(v) --, indent+1)
else
log(v)
end
end
end
function Logger.filterEvent(event)
table.insert(filteredEvents, event)
end
function Logger.logEvent(event, p1, p2, p3, p4, p5)
local function param(p)
if p then
return ', ' .. tostring(p)
end
return ''
end
for _,v in pairs(filteredEvents) do
if event == v then
return
end
end
if event == 'rednet_message' then
local msg = p2
logger(param(event) .. param(p1) .. param(msg.type) .. param(msg.contents))
elseif event ~= 'modem_message' then
logger(param(event) .. param(p1) .. param(p2) .. param(p3) .. param(p4) .. param(p5))
end
end
--Imported from Util
local Util = { }
function Util.loadAPI(name)
local dir = shell.dir()
if fs.exists(dir .. '/' .. name) then
os.loadAPI(dir .. '/' .. name)
elseif shell.resolveProgram(name) then
os.loadAPI(shell.resolveProgram(name))
elseif fs.exists('/rom/apis/' .. name) then
os.loadAPI('/rom/apis/' .. name)
else
os.loadAPI(name)
end
end
function Util.wrap(inP)
local wrapped
for k,side in pairs(redstone.getSides()) do
sideType = peripheral.getType(side)
if sideType then
--Logger.log(sideType .. " on " .. side)
if sideType == inP then
if sideType == "modem" then
rednet.open(side)
return
else
wrapped = peripheral.wrap(side)
end
end
end
end
if not wrapped then
error(inP .. " is not connected")
end
return wrapped
end
function Util.getSide(device)
for k,side in pairs(rs.getSides()) do
if peripheral.getType(side) == device then
return side
end
end
error(device .. " is not connected")
end
function Util.hasDevice(device)
for k,side in pairs(rs.getSides()) do
if peripheral.getType(side) == device then
return true
end
end
return false
end
function Util.tryTimed(timeout, f, ...)
local c = os.clock()
while not f(...) do
if os.clock()-c >= timeout then
return false
end
end
return true
end
function Util.trace(x)
if not x or not x.is_a then
error('Incorrect syntax', 3)
end
end
function Util.printTable(t)
if not t then
error('printTable: nil passed', 2)
end
for k,v in pairs(t) do
print(k .. '=' .. tostring(v))
end
end
function Util.tableSize(t)
local c = 0
for _,_ in pairs(t)
do c = c+1
end
return c
end
--https://github.com/jtarchie/underscore-lua
function Util.each(list, func)
local pairing = pairs
if Util.isArray(list) then pairing = ipairs end
for index, value in pairing(list) do
func(value, index, list)
end
end
function Util.size(list, ...)
local args = {...}
if Util.isArray(list) then
return #list
elseif Util.isObject(list) then
local length = 0
Util.each(list, function() length = length + 1 end)
return length
end
return 0
end
function Util.isObject(value)
return type(value) == "table"
end
function Util.isArray(value)
return type(value) == "table" and (value[1] or next(value) == nil)
end
-- end https://github.com/jtarchie/underscore-lua
function Util.readFile(fname)
local f = fs.open(fname, "r")
if f then
local t = f.readAll()
f.close()
return t
end
end
function Util.readTable(fname)
local t = Util.readFile(fname)
if t then
return textutils.unserialize(t)
end
Logger.log('Util:readTable: ' .. fname .. ' does not exist')
return { }
end
function Util.writeTable(fname, data)
writeFile(fname, textutils.serialize(data))
end
function Util.writeFile(fname, data)
local file = io.open(fname, "w")
if file then
file:write(data)
file:close()
end
end
function Util.shallowCopy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
function Util.split(str)
local t = {}
local function helper(line) table.insert(t, line) return "" end
helper((str:gsub("(.-)\n", helper)))
return t
end
string.lpad = function(str, len, char)
if char == nil then char = ' ' end
return str .. string.rep(char, len - #str)
end
-- http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
function Util.spairs(t, order)
if not t then
error('spairs: nil passed')
end
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t[a], t[b]) end)
else
table.sort(keys)
end
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
function Util.first(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t[a], t[b]) end)
else
table.sort(keys)
end
return keys[1], t[keys[1]]
end
--[[
pbInfo - Libs/lib.WordWrap.lua
v0.41
by p.b. a.k.a. novayuna
released under the Creative Commons License By-Nc-Sa: http://creativecommons.org/licenses/by-nc-sa/3.0/
original code by Tomi H.: http://shadow.vs-hs.org/library/index.php?page=2&id=48
]]
function Util.WordWrap(strText, intMaxLength)
local tblOutput = {};
local intIndex;
local strBuffer = "";
local tblLines = Util.Explode(strText, "\n");
for k, strLine in pairs(tblLines) do
local tblWords = Util.Explode(strLine, " ");
if (#tblWords > 0) then
intIndex = 1;
while tblWords[intIndex] do
local strWord = " " .. tblWords[intIndex];
if (strBuffer:len() >= intMaxLength) then
table.insert(tblOutput, strBuffer:sub(1, intMaxLength));
strBuffer = strBuffer:sub(intMaxLength + 1);
else
if (strWord:len() > intMaxLength) then
strBuffer = strBuffer .. strWord;
elseif (strBuffer:len() + strWord:len() >= intMaxLength) then
table.insert(tblOutput, strBuffer);
strBuffer = ""
else
if (strBuffer == "") then
strBuffer = strWord:sub(2);
else
strBuffer = strBuffer .. strWord;
end;
intIndex = intIndex + 1;
end;
end;
end;
if strBuffer ~= "" then
table.insert(tblOutput, strBuffer);
strBuffer = ""
end;
end;
end;
return tblOutput;
end
function Util.Explode(strText, strDelimiter)
local strTemp = "";
local tblOutput = {};
if not strText then
error('no strText', 4)
end
for intIndex = 1, strText:len(), 1 do
if (strText:sub(intIndex, intIndex + strDelimiter:len() - 1) == strDelimiter) then
table.insert(tblOutput, strTemp);
strTemp = "";
else
strTemp = strTemp .. strText:sub(intIndex, intIndex);
end;
end;
if (strTemp ~= "") then
table.insert(tblOutput, strTemp)
end;
return tblOutput;
end
-- http://lua-users.org/wiki/AlternativeGetOpt
local function getopt( arg, options )
local tab = {}
for k, v in ipairs(arg) do
if string.sub( v, 1, 2) == "--" then
local x = string.find( v, "=", 1, true )
if x then tab[ string.sub( v, 3, x-1 ) ] = string.sub( v, x+1 )
else tab[ string.sub( v, 3 ) ] = true
end
elseif string.sub( v, 1, 1 ) == "-" then
local y = 2
local l = string.len(v)
local jopt
while ( y <= l ) do
jopt = string.sub( v, y, y )
if string.find( options, jopt, 1, true ) then
if y < l then
tab[ jopt ] = string.sub( v, y+1 )
y = l
else
tab[ jopt ] = arg[ k + 1 ]
end
else
tab[ jopt ] = true
end
y = y + 1
end
end
end
return tab
end
-- end http://lua-users.org/wiki/AlternativeGetOpt
function Util.showOptions(options)
for k, v in pairs(options) do
print(string.format('-%s %s', v.arg, v.desc))
end
end
function Util.getOptions(options, args, syntaxMessage)
local argLetters = ''
for _,o in pairs(options) do
argLetters = argLetters .. o.arg
end
local rawOptions = getopt(args, argLetters)
for _,o in pairs(options) do
if rawOptions[o.arg] then
o.value = rawOptions[o.arg]
if o.value and tonumber(o.value) then
o.value = tonumber(o.value)
end
end
end
--[[
for k,v in pairs(options) do
print(k)
Util.printTable(v)
end
read()
--]]
end
--Imported from Event
local Event = { }
local eventHandlers = {
namedTimers = {}
}
local enableQueue = {}
local removeQueue = {}
local function deleteHandler(h)
for k,v in pairs(eventHandlers[h.event].handlers) do
if v == h then
table.remove(eventHandlers[h.event].handlers, k)
break
end
end
--table.remove(eventHandlers[h.event].handlers, h.key)
end
function Event.addHandler(type, f)
local event = eventHandlers[type]
if not event then
event = {}
event.handlers = {}
eventHandlers[type] = event
end
local handler = {}
handler.event = type
handler.f = f
handler.enabled = true
table.insert(event.handlers, handler)
-- any way to retrieve key here for removeHandler ?
return handler
end
function Event.removeHandler(h)
h.deleted = true
h.enabled = false
table.insert(removeQueue, h)
end
function Event.queueTimedEvent(name, timeout, event, args)
Event.addNamedTimer(name, timeout, false,
function()
os.queueEvent(event, args)
end
)
end
function Event.addNamedTimer(name, interval, recurring, f)
Event.cancelNamedTimer(name)
eventHandlers.namedTimers[name] = Event.addTimer(interval, recurring, f)
end
function Event.getNamedTimer(name)
return eventHandlers.namedTimers[name]
end
function Event.cancelNamedTimer(name)
local timer = Event.getNamedTimer(name)
if timer then
timer.enabled = false
timer.recurring = false
end
end
function Event.addTimer(interval, recurring, f)
local timer = Event.addHandler('timer',
function(t, id)
if t.timerId ~= id then
return
end
if t.enabled then
t.cf(t, id)
end
if t.recurring then
t.timerId = os.startTimer(t.interval)
else
removeHandler(t)
end
end
)
timer.cf = f
timer.interval = interval
timer.recurring = recurring
timer.timerId = os.startTimer(interval)
return timer
end
function Event.removeTimer(h)
Event.removeEventHandler(h)
end
function Event.waitForEvent(event, timeout)
local c = os.clock()
while true do
os.queueEvent('dummyEvent')
local e, p1, p2, p3, p4 = Event.pullEvent()
if e == event then
return e, p1, p2, p3, p4
end
if os.clock()-c > timeout then
return
end
end
end
function Event.pullEvents()
while true do
local e = Event.pullEvent()
if e == 'exitPullEvents' then
break
end
end
end
function Event.exitPullEvents()
os.queueEvent('exitPullEvents')
end
function Event.enableHandler(h)
table.insert(enableQueue, h)
end
function Event.pullEvent(type)
local e, p1, p2, p3, p4, p5 = os.pullEvent(type)
Logger.logEvent(e, p1, p2, p3, p4, p5)
local event = eventHandlers[e]
if event then
for k,v in pairs(event.handlers) do
if v.enabled then
v.f(v, p1, p2, p3, p4, p5)
end
end
while #enableQueue > 0 do
table.remove(handlerQueue).enabled = true
end
while #removeQueue > 0 do
Event.deleteHandler(table.remove(removeQueue))
end
end
return e, p1, p2, p3, p4, p5
end
--Imported from UI
local function widthify(s, len)
if not s then
s = ' '
end
return string.lpad(string.sub(s, 1, len) , len, ' ')
end
local console
UI = { }
function UI.setProperties(obj, argTable)
if argTable then
for k,v in pairs(argTable) do
obj[k] = v
end
end
end
-- there can be only one
function UI.getConsole()
if not console then
console = UI.Console()
end
return console
end
--[[-- Console (wrapped term) --]]--
UI.Console = class.class()
function UI.Console:init(args)
self.clear = term.clear
self.width, self.height = term.getSize()
UI.setProperties(self, args)
self.isColor = term.isColor()
if not self.isColor then
term.setBackgroundColor = function(...) end
term.setTextColor = function(...) end
end
end
function UI.Console:reset()
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.black)
self:clear()
end
function UI.Console:advanceCursorY(offset)
local x, y = term.getCursorPos()
term.setCursorPos(1, y+offset)
end
function UI.Console:clearArea(x, y, width, height, bg)
if bg then
term.setBackgroundColor(bg)
end
local filler = string.rep(' ', width+1)
for i = y, y+height-1 do
term.setCursorPos(x, i)
term.write(filler)
end
end
function UI.Console:write(x, y, text, bg)
if bg then
term.setBackgroundColor(bg)
end
term.setCursorPos(x, y)
term.write(tostring(text))
end
function UI.Console:wrappedWrite(x, y, text, len, bg)
for k,v in pairs(Util.WordWrap(text, len)) do
console:write(x, y, v, bg)
y = y + 1
end
return y
end
function UI.Console:prompt(text)
term.write(text)
term.setCursorBlink(true)
local response = read()
term.setCursorBlink(false)
if string.len(response) > 0 then
return response
end
end
--[[-- StringBuffer --]]--
UI.StringBuffer = class.class()
function UI.StringBuffer:init(bufSize)
self.bufSize = bufSize
self.buffer = {}
end
function UI.StringBuffer:insert(s, index)
table.insert(self.buffer, { index = index, str = s })
end
function UI.StringBuffer:append(s)
local str = self:get()
self:insert(s, #str)
end
function UI.StringBuffer:get()
local str = ''
for k,v in Util.spairs(self.buffer, function(a, b) return a.index < b.index end) do
str = str .. string.rep(' ', v.index - string.len(str)) .. v.str
end
local len = string.len(str)
if len < self.bufSize then
str = str .. string.rep(' ', self.bufSize - len)
end
return str
end
function UI.StringBuffer:clear()
self.buffer = {}
end
--[[-- Pager --]]--
UI.Pager = class.class()
function UI.Pager:init(args)
local defaults = {
pages = { }
}
UI.setProperties(self, defaults)
UI.setProperties(self, args)
self.keyHandler = Event.addHandler('mouse_scroll',
function(h, direction)
if direction == 1 then
self.currentPage:keyHandler('down')
else
self.currentPage:keyHandler('up')
end
end
)
self.keyHandler = Event.addHandler('char',
function(h, ch)
if self.currentPage then
self.currentPage:keyHandler(ch)
end
end
)
self.keyHandler = Event.addHandler('key',
function(h, code)
local ch = keys.getName(code)
-- filter out a through z as they will be get picked up
-- as char events
if string.len(ch) > 1 then
if self.currentPage then
self.currentPage:keyHandler(ch)
end
end
end
)
end
function UI.Pager:addPage(name, page)
self.pages[name] = page
end
function UI.Pager:setPages(pages)
self.pages = pages
end
function UI.Pager:getPage(pageName, ...)
local page = self.pages[pageName]
if not page then
error('Pager:getPage: Invalid page: ' .. tostring(pageName), 2)
end
return page
end
-- changing to setNamedPage
function UI.Pager:setPage(pageName)
local page = self:getPage(pageName)
self:setPageRaw(page)
end
-- changing to setPage
function UI.Pager:setPageRaw(page)
if page == self.currentPage then
page:draw()
else
if self.currentPage then
self.currentPage:disable()
self.currentPage.enabled = false
page.previousPage = self.currentPage
end
self.currentPage = page
console:reset()
page.enabled = true
page:enable()
page:draw()
end
end
function UI.Pager:getCurrentPage()
return self.currentPage
end
function UI.Pager:setDefaultPage()
if not self.defaultPage then
error('No default page defined', 2)
end
self:setPage(self.defaultPage)
end
function UI.Pager:setPreviousPage()
if self.currentPage.previousPage then
local previousPage = self.currentPage.previousPage.previousPage
self:setPageRaw(self.currentPage.previousPage)
self.currentPage.previousPage = previousPage
end
end
--[[-- Page --]]--
UI.Page = class.class()
function UI.Page:init(args)
self.defaultPage = 'menu'
UI.setProperties(self, args)
end
function UI.Page:draw()
end
function UI.Page:enable()
end
function UI.Page:disable()
end
function UI.Page:keyHandler(ch)
end
--[[-- Grid --]]--
UI.Grid = class.class()
function UI.Grid:init(args)
local defaults = {
sep = ' ',
sepLen = 1,
x = 1,
y = 1,
pageSize = 16,
pageNo = 1,
index = 1,
inverseSort = false,
disableHeader = false,
selectable = true,
textColor = colors.white,
textSelectedColor = colors.white,
backgroundColor = colors.black,
backgroundSelectedColor = colors.gray,
t = {},
columns = {}
}
UI.setProperties(self, defaults)
UI.setProperties(self, args)
if not self.width then
self.width = self:calculateWidth()
end
if self.autospace then
local colswidth = 0
for _,c in pairs(self.columns) do
colswidth = colswidth + c[3] + 1
end
local spacing = (self.width - colswidth - 1)
spacing = math.floor(spacing / (#self.columns - 1) )
for _,c in pairs(self.columns) do
c[3] = c[3] + spacing
end
end
end
function UI.Grid:setPosition(x, y)
self.x = x
self.y = y
end
function UI.Grid:setPageSize(pageSize)
self.pageSize = pageSize
end
function UI.Grid:setColumns(columns)
self.columns = columns
end
function UI.Grid:getTable()
return self.t
end
function UI.Grid:setTable(t)
self.t = t
end
function UI.Grid:setInverseSort(inverseSort)
self.inverseSort = inverseSort
self:drawRows()
end
function UI.Grid:setSortColumn(column)