"Fossies" - the Fresh Open Source Software Archive

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

    1 --[[
    2 Sample plugin file for highlight 3.9
    3 ]]
    4 
    5 Description="Add tooltips based on a ctags file (default input file: tags)"
    6 
    7 Categories = {"ctags", "html" }
    8 
    9 -- optional parameter: syntax description
   10 function syntaxUpdate(desc)
   11 
   12   if (HL_OUTPUT ~= HL_FORMAT_HTML and HL_OUTPUT ~= HL_FORMAT_XHTML) then
   13       return
   14   end
   15 
   16   function string:split(sep)
   17     local sep, fields = sep or ":", {}
   18     local pattern = string.format("([^%s]+)", sep)
   19     self:gsub(pattern, function(c) fields[#fields+1] = c end)
   20     return fields
   21   end
   22 
   23 --tbd:
   24 --case 'F': return  "file";
   25 --case 'g': return  "enumeration name";
   26 --case 'n': return  "namespace";
   27 --case 'p': return  "function prototype";
   28 --case 's': return  "structure name";
   29 --case 't': return  "typedef";
   30 --case 'u': return  "union name";
   31 --case 'v': return  "variable";
   32 
   33   knowntags={}
   34 
   35   if #HL_PLUGIN_PARAM==0 then HL_PLUGIN_PARAM='tags' end
   36   --print("file:" .. HL_PLUGIN_PARAM)
   37   file = assert(io.open(HL_PLUGIN_PARAM, "r"))
   38 
   39   for line in file:lines() do
   40     if line[1]~='!' then
   41       items=string.split(line, '\t')
   42       if #items==4 then
   43         if items[4]=='d' then
   44           knowntags[items[1]] = 'define | '.. items[2]
   45         end
   46             elseif #items==6 then
   47         if items[5]=='e' then
   48           knowntags[items[1]] = 'enumerator | '..items[6] ..' | '.. items[2]
   49         elseif items[5]=='m' then
   50           knowntags[items[1]] = 'member | '..items[6] ..' | '.. items[2]
   51         elseif items[5]=='c' then
   52           knowntags[items[1]] = 'class | '..items[6] ..' | '.. items[2]
   53         elseif items[5]=='f' then
   54           knowntags[items[1]] = 'function | '..items[6] ..' | '.. items[2]
   55         end
   56       end
   57     end
   58   end
   59 
   60 
   61   function Decorate(token, state, kwclass)
   62 
   63     if ( state ~= HL_STANDARD and state ~= HL_KEYWORD and state ~=HL_PREPROC) then
   64       return
   65     end
   66 
   67     for k,v in pairs(knowntags) do
   68       if k==token  then
   69   return '<span title="'..v..'">'..token .. '</span>'
   70       end
   71     end
   72 
   73   end
   74 end
   75 
   76 
   77 Plugins={
   78 
   79   { Type="lang", Chunk=syntaxUpdate },
   80 
   81 }