File: ctrlpanel.lua

package info (click to toggle)
spring 98.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,928 kB
  • ctags: 60,665
  • sloc: cpp: 356,167; ansic: 39,434; python: 12,228; java: 12,203; awk: 5,856; sh: 1,719; xml: 997; perl: 405; php: 253; objc: 194; makefile: 72; sed: 2
file content (44 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (6)
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
local ctrlPanel = {}

local function ParseCtrlPanelTXT(filename)
  local f,it,isFile = nil,nil,false
  f  = io.open(filename,'r')
  if f then
    it = f:lines()
    isFile = true
  else
    f  = VFS.LoadFile(filename)
    it = f:gmatch("%a+.-\n")
  end

  local wp = '%s*([^%s]+)'           -- word pattern
  local wp2 = '%s+([^%s]+)'           -- word pattern
  local cp = '^'..wp..wp2..wp2..wp2..wp2 -- color pattern
  local sp = '^'..wp..wp2             -- single value pattern like queuedLineWidth

  for line in it do
    local _, _, n, r, g, b, a = line:lower():find(cp)

    r = tonumber(r or 1.0)
    g = tonumber(g or 1.0)
    b = tonumber(b or 1.0)
    a = tonumber(a or 1.0)

    if n then
      ctrlPanel[n]= { r,g,b,a }
    else
      _, _, n, r = line:lower():find(sp)
      if n then
        ctrlPanel[n]= r
      end
    end
  end

  if isFile then f:close() end
  f,it,wp,cp,sp=nil,nil,nil,nil,nil
end

ParseCtrlPanelTXT('ctrlpanel.txt')
ParseCtrlPanelTXT('LuaUI/ctrlpanel.txt')

return ctrlPanel