scite-context-theme.lua /size: 6615 b    last modification: 2020-07-01 14:35
1local info = {
2    version   = 1.002,
3    comment   = "theme for scintilla lpeg lexer for context/metafun",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files",
7}
8
9-- context_path = string.split(os.resultof("mtxrun --find-file context.mkiv"))[1] or ""
10
11-- What used to be proper Lua definitions are in 3.42 SciTE properties although
12-- integration is still somewhat half. Also, the indexed style specification is
13-- now a hash (which indeed makes more sense). However, the question is: am I
14-- going to rewrite the style bit? It anyway makes more sense to keep this file
15-- somewhat neutral as we no longer need to be compatible. However, we cannot be
16-- sure of helpers being present yet when this file is loaded, so we are somewhat
17-- crippled. On the other hand, I don't see other schemes being used with the
18-- context lexers.
19
20-- The next kludge is no longer needed which is good!
21--
22-- if GTK then -- WIN32 GTK OSX CURSES
23--     font_name = '!' .. font_name
24-- end
25
26-- I need to play with these, some work ok:
27--
28-- eolfilled noteolfilled
29-- characterset:u|l
30-- visible notvisible
31-- changeable notchangeable (this way we can protect styles, e.g. preamble?)
32-- hotspot nothotspot
33
34if not lexers or not lexers.initialized then
35
36    local font_name = 'Dejavu Sans Mono'
37    local font_size = '14'
38
39    local colors = {
40        red       = { 0x7F, 0x00, 0x00 },
41        green     = { 0x00, 0x7F, 0x00 },
42        blue      = { 0x00, 0x00, 0x7F },
43        cyan      = { 0x00, 0x7F, 0x7F },
44        magenta   = { 0x7F, 0x00, 0x7F },
45        yellow    = { 0x7F, 0x7F, 0x00 },
46        orange    = { 0xB0, 0x7F, 0x00 },
47        --
48        white     = { 0xFF },
49        light     = { 0xCF },
50        grey      = { 0x80 },
51        dark      = { 0x4F },
52        black     = { 0x00 },
53        --
54        selection = { 0xF7 },
55        logpanel  = { 0xE7 },
56        textpanel = { 0xCF },
57        linepanel = { 0xA7 },
58        tippanel  = { 0x44 },
59        --
60        right     = { 0x00, 0x00, 0xFF },
61        wrong     = { 0xFF, 0x00, 0x00 },
62    }
63
64    local styles = {
65
66        ["whitespace"]   = { },
67     -- ["default"]      = { font = font_name, size = font_size, fore = colors.black, back = colors.textpanel },
68     -- ["default"]      = { font = font_name, size = font_size, fore = colors.black },
69        ["default"]      = { font = font_name, size = font_size, fore = colors.black,
70                             back = textadept and colors.textpanel or nil },
71        ["number"]       = { fore = colors.cyan },
72        ["comment"]      = { fore = colors.yellow },
73        ["keyword"]      = { fore = colors.blue, bold = true },
74        ["string"]       = { fore = colors.magenta },
75     -- ["preproc"]      = { fore = colors.yellow, bold = true },
76        ["error"]        = { fore = colors.red },
77        ["label"]        = { fore = colors.red, bold = true  },
78
79        ["nothing"]      = { },
80        ["class"]        = { fore = colors.black, bold = true },
81        ["function"]     = { fore = colors.black, bold = true },
82        ["constant"]     = { fore = colors.cyan, bold = true },
83        ["operator"]     = { fore = colors.blue },
84        ["regex"]        = { fore = colors.magenta },
85        ["preprocessor"] = { fore = colors.yellow, bold = true },
86        ["tag"]          = { fore = colors.cyan },
87        ["type"]         = { fore = colors.blue },
88        ["variable"]     = { fore = colors.black },
89        ["identifier"]   = { },
90
91        ["linenumber"]   = { back = colors.linepanel },
92        ["bracelight"]   = { fore = colors.orange, bold = true },
93        ["bracebad"]     = { fore = colors.orange, bold = true },
94        ["controlchar"]  = { },
95        ["indentguide"]  = { fore = colors.linepanel, back = colors.white },
96        ["calltip"]      = { fore = colors.white, back = colors.tippanel },
97
98        ["invisible"]    = { back = colors.orange },
99        ["quote"]        = { fore = colors.blue, bold = true },
100        ["special"]      = { fore = colors.blue },
101        ["extra"]        = { fore = colors.yellow },
102        ["embedded"]     = { fore = colors.black, bold = true },
103        ["char"]         = { fore = colors.magenta },
104        ["reserved"]     = { fore = colors.magenta, bold = true },
105        ["definition"]   = { fore = colors.black, bold = true },
106        ["okay"]         = { fore = colors.dark },
107        ["warning"]      = { fore = colors.orange },
108        ["standout"]     = { fore = colors.orange, bold = true },
109        ["command"]      = { fore = colors.green, bold = true },
110        ["internal"]     = { fore = colors.orange, bold = true },
111        ["preamble"]     = { fore = colors.yellow },
112        ["grouping"]     = { fore = colors.red  },
113        ["primitive"]    = { fore = colors.blue, bold = true },
114        ["plain"]        = { fore = colors.dark, bold = true },
115        ["user"]         = { fore = colors.green },
116        ["data"]         = { fore = colors.cyan, bold = true },
117
118        -- equal to default:
119
120        ["text"]         = { font = font_name, size = font_size, fore = colors.black, back = colors.textpanel },
121        ["text"]         = { font = font_name, size = font_size, fore = colors.black },
122
123    }
124
125    local properties = {
126        ["fold.by.parsing"]        = 1,
127        ["fold.by.indentation"]    = 0,
128        ["fold.by.line"]           = 0,
129        ["fold.line.comments"]     = 0,
130        --
131        ["lexer.context.log"]      = 1, -- log errors and warnings
132        ["lexer.context.trace"]    = 0, -- show loading, initializations etc
133        ["lexer.context.detail"]   = 0, -- show more detail when tracing
134        ["lexer.context.show"]     = 0, -- show result of lexing
135        ["lexer.context.collapse"] = 0, -- make lexing results somewhat more efficient
136        ["lexer.context.inspect"]  = 0, -- show some info about lexer (styles and so)
137        --
138     -- ["lexer.context.log"]      = 1, -- log errors and warnings
139     -- ["lexer.context.trace"]    = 1, -- show loading, initializations etc
140    }
141
142    ----- lexers  = require("lexer")
143    local lexer   = require("scite-context-lexer")
144    local context = lexer.context
145
146    if context then
147        context.inform("loading context (style) properties")
148        if context.registerstyles then
149            context.registerstyles(styles)
150        end
151        if context.registercolors then
152            context.registercolors(colors)
153        end
154        if context.registerproperties then
155            context.registerproperties(properties)
156        end
157    end
158
159end
160