1--[[ 2 3Sample plugin file for highlight 3.1 4 5Invert colours of the original theme 6 7USAGE: highlight -I main.cpp --plug-in=plugin.lua 8]] 9 10Description="Invert colours of the original theme" 11 12Categories = {"format" } 13 14 15-- function to update theme definition 16-- optional parameter: theme description 17function themeUpdate() 18 19 function invert(colour) 20 if string.match(colour, "#%x+")==nil then 21 return "#000000" 22 end 23 rr=255 - ("0x"..string.match(colour, "%x%x", 2)) 24 gg=255 - ("0x"..string.match(colour, "%x%x", 4)) 25 bb=255 - ("0x"..string.match(colour, "%x%x", 6)) 26 return string.format("#%02x%02x%02x", rr, gg, bb) 27 end 28 29 Description = Description .. " (inverted)" 30 31 Default.Colour=invert(Default.Colour) 32 Canvas.Colour=invert(Canvas.Colour) 33 Number.Colour=invert(Number.Colour) 34 Escape.Colour=invert(Escape.Colour) 35 String.Colour=invert(String.Colour) 36 StringPreProc.Colour=invert(StringPreProc.Colour) 37 BlockComment.Colour=invert(BlockComment.Colour) 38 LineComment.Colour=invert(LineComment.Colour) 39 PreProcessor.Colour=invert(PreProcessor.Colour) 40 LineNum.Colour=invert(LineNum.Colour) 41 Operator.Colour=invert(Operator.Colour) 42 43 for k, v in pairs(Keywords) do 44 v.Colour=invert(v.Colour) 45 end 46end 47 48 49--The Plugins array assigns code chunks to themes or language definitions. 50--The chunks are interpreted after the theme or lang file were parsed, 51--so you can refer to elements of these files 52 53Plugins={ 54 55 { Type="theme", Chunk=themeUpdate } 56 57} 58