"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/plugins/theme_invert.lua" (12 May 2020, 1483 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "theme_invert.lua": 3.53_vs_3.54.

    1 --[[
    2 
    3 Sample plugin file for highlight 3.1
    4 
    5 Invert colours of the original theme
    6 
    7 USAGE: highlight -I main.cpp --plug-in=plugin.lua
    8 ]]
    9 
   10 Description="Invert colours of the original theme"
   11 
   12 Categories = {"format" }
   13 
   14 
   15 -- function to update theme definition
   16 -- optional parameter: theme description
   17 function 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
   46 end
   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 
   53 Plugins={
   54 
   55   { Type="theme", Chunk=themeUpdate }
   56 
   57 }