Merge remote-tracking branch 'rxi/master' into agg-font-renderer

This commit is contained in:
Francesco Abbate 2020-06-11 23:22:49 +02:00
commit 4d3693479d
6 changed files with 14 additions and 7 deletions

View File

@ -56,7 +56,8 @@ end
function Doc:reset_syntax() function Doc:reset_syntax()
local syn = syntax.get(self.filename or "") local header = self:get_text(1, 1, self:position_offset(1, 1, 128))
local syn = syntax.get(self.filename or "", header)
if self.syntax ~= syn then if self.syntax ~= syn then
self.syntax = syn self.syntax = syn
self.highlighter:reset() self.highlighter:reset()

View File

@ -11,14 +11,19 @@ function syntax.add(t)
end end
function syntax.get(filename) local function find(string, field)
for i = #syntax.items, 1, -1 do for i = #syntax.items, 1, -1 do
local t = syntax.items[i] local t = syntax.items[i]
if common.match_pattern(filename, t.files) then if common.match_pattern(string, t[field] or {}) then
return t return t
end end
end end
return plain_text_syntax end
function syntax.get(filename, header)
return find(filename, "files")
or find(header, "headers")
or plain_text_syntax
end end

View File

@ -2,6 +2,7 @@ local syntax = require "core.syntax"
syntax.add { syntax.add {
files = "%.lua$", files = "%.lua$",
headers = "^#!.*[ /]lua",
comment = "--", comment = "--",
patterns = { patterns = {
{ pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { '"', '"', '\\' }, type = "string" },

View File

@ -2,6 +2,7 @@ local syntax = require "core.syntax"
syntax.add { syntax.add {
files = "%.py$", files = "%.py$",
headers = "^#!.*[ /]python",
comment = "#", comment = "#",
patterns = { patterns = {
{ pattern = { "#", "\n" }, type = "comment" }, { pattern = { "#", "\n" }, type = "comment" },

View File

@ -2,6 +2,7 @@ local syntax = require "core.syntax"
syntax.add { syntax.add {
files = { "%.xml$", "%.html?$" }, files = { "%.xml$", "%.html?$" },
headers = "<%?xml",
patterns = { patterns = {
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" }, { pattern = { "<!%-%-", "%-%->" }, type = "comment" },
{ pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" }, { pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" },

View File

@ -7,8 +7,6 @@
#include <windows.h> #include <windows.h>
#elif __linux__ #elif __linux__
#include <unistd.h> #include <unistd.h>
#elif __APPLE__
#include <mach-o/dyld.h>
#endif #endif
@ -102,7 +100,7 @@ int main(int argc, char **argv) {
} }
lua_setglobal(L, "ARGS"); lua_setglobal(L, "ARGS");
lua_pushstring(L, "1.06"); lua_pushstring(L, "1.07");
lua_setglobal(L, "VERSION"); lua_setglobal(L, "VERSION");
lua_pushstring(L, SDL_GetPlatform()); lua_pushstring(L, SDL_GetPlatform());