"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/plugins/bash_functions.lua" (12 May 2020, 1257 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 "bash_functions.lua": 3.53_vs_3.54.

    1 --[[
    2 Sample plugin file for highlight 3.2
    3 
    4 Adds additional function names to keyword list to recognize them later
    5 without parentheses
    6 ]]
    7 
    8 Description="Add function names to keyword list"
    9 
   10 Categories = {"bash"}
   11 
   12 -- optional parameter: syntax description
   13 function syntaxUpdate(desc)
   14   if desc=="Bash" then
   15 
   16   --add function name pattern ("f_" prefix omitted but maybe reasonable)
   17   table.insert( Keywords,
   18                   { Id=5, Regex=[[(\w+)\s*\(]]
   19                   } )
   20 
   21     -- add keywords to list 5 if pattern matches
   22     function OnStateChange(oldState, newState, token, kwgroup)
   23 
   24       if newState==HL_KEYWORD and kwgroup==5 then
   25     --if string.find(token, "f_%a+") then
   26       AddKeyword(token, 5)
   27     --end
   28     --more patterns could be defined here
   29       end
   30       return newState
   31     end
   32 
   33   end
   34 end
   35 
   36 -- optional parameter: theme description
   37 function themeUpdate(desc)
   38   if #Keywords==4 then
   39     table.insert(Keywords, {Colour= "#ff0000", Bold=true})
   40   end
   41 end
   42 
   43 
   44 --The Plugins array assigns code chunks to themes or language definitions.
   45 --The chunks are interpreted after the theme or lang file were parsed,
   46 --so you can refer to elements of these files
   47 
   48 Plugins={
   49 
   50   { Type="theme", Chunk=themeUpdate },
   51   { Type="lang", Chunk=syntaxUpdate },
   52 
   53 }