Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for k, v in pairs(file) do
- local y = k * font:getHeight(" ")
- local x = 0
- local string = v
- local words = {}
- for w in string:gmatch("%S+") do table.insert(words, w) end
- while string:len() > 0 do
- local index = string:find(" ") or string:len()+1
- local char = string:sub(1, 1)
- if index == 1 or char == "(" or char == ")" or char == '"' then
- love.graphics.setColor(0, 0, 0)
- if char == "(" then
- love.graphics.print("(", x, y)
- isFunction = false
- elseif char == ")" then
- love.graphics.print(")", x, y)
- isFunction = false
- elseif char == '"' then
- love.graphics.setColor(unpack(theme["string"]))
- love.graphics.print('"', x, y)
- isString = (not isString)
- end
- string = string:sub(2)
- x = x + font:getWidth(" ")
- else
- local word = string:sub(1, index-1)
- local key = word
- if isString then
- love.graphics.setColor(unpack(theme["string"]))
- elseif isFunction then
- love.graphics.setColor(unpack(theme["newFunction"]))
- isFunction = false
- else
- if tonumber(word) ~= nil then
- love.graphics.setColor(unpack(theme["constant"]))
- elseif keywords[key] then
- love.graphics.setColor(unpack(theme[keywords[key]] ) )
- else
- love.graphics.setColor( unpack( theme.normal ) )
- end
- if word == "function" then
- isFunction = true
- else
- isFunction = false
- end
- end
- love.graphics.print(word, x, y)
- x = x + font:getWidth(word)
- string = string:sub(word:len()+1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement