stylecsv.lua
npp.AddEventHandler("OnSwitchFile", function(filename, bufferid)
if npp:GetExtPart() == ".csv" then
npp.AddEventHandler("OnStyle", StyleCSV)
editor.Lexer = SCLEX_CONTAINER
editor.StyleBack[1] = 0xffffff
editor.StyleBack[2] = 0xC0D9AF
editor.StyleEOLFilled[1] = true
editor.StyleEOLFilled[2] = true
editor:ClearDocumentStyle()
editor:Colourise(0, -1)
editor.CaretLineVisible = false
else
npp.RemoveEventHandler("OnStyle", StyleCSV)
editor.CaretLineVisible = true
end
return false
end)
function StyleCSV(styler)
local lineStart = editor:LineFromPosition(styler.startPos)
local lineEnd = editor:LineFromPosition(styler.startPos + styler.lengthDoc)
editor:StartStyling(styler.startPos, 0 )
for line=lineStart,lineEnd,1 do
local lengthLine = editor:PositionFromLine(line+1) - editor:PositionFromLine(line)
if line % 2 == 0 then
editor:SetStyling(lengthLine, 1)
else
editor:SetStyling(lengthLine, 2)
end
end
end