ZeroBranePackage
ZeroBranePackage copied to clipboard
endofline plugin
@pkulchenko Another plugin from me, please review and add to ZeroBranePackage if you like it. :beer:
It takes care about actions mentioned in the
Use 'ide:GetEditor():SetViewEOL(1)' to show line endings and ide:GetEditor():ConvertEOLs(ide:GetEditor():GetEOLMode())' to convert them.
message
:sos: Help is needed :sos: The onUpdateUi
is not functional (does not set checkmark) Do you have a suggestion?
endofline.lua :
local idShowLineEndings = ID("endofline.show")
local idConvertCrLf = ID("endofline.crlf")
local idConvertLf = ID("endofline.lf")
local idConvertCr = ID("endofline.cr")
return
{
name = "endofline",
description = "Adds Menus do show and convert end of lines",
author = "J.Jørgen von Bargen",
version = 0.01,
onRegister = function(self)
local viewMenu = ide:FindTopMenu("&View")
local editMenu = ide:FindTopMenu("&Edit")
local sourceId = editMenu:FindItem("Source")
local sourceMenu = editMenu:FindItem(sourceId)
local sourceSubMenu=sourceMenu:GetSubMenu()
viewMenu:Append(idShowLineEndings,"End of line")
sourceSubMenu:Append(idConvertCrLf,"Convert to CrLf")
sourceSubMenu:Append(idConvertLf,"Convert to Lf")
sourceSubMenu:Append(idConvertCr,"Convert to Cr")
local function onShowLineEndings(event)
ide:GetEditor():SetViewEOL(not ide:GetEditor():GetViewEOL())
ide:GetUIManager():Update()
end
local function onConvertCrLf()
ide:GetEditor():ConvertEOLs(wxstc.wxSTC_EOL_CRLF)
end
local function onConvertLf()
ide:GetEditor():ConvertEOLs(wxstc.wxSTC_EOL_LF)
end
local function onConvertCr()
ide:GetEditor():ConvertEOLs(wxstc.wxSTC_EOL_CR)
end
local function onUpdateUi(event)
ide:GetMenuBar():Check(idShowLineEndings,ide:GetEditor():GetViewEOL())
end
ide:GetMainFrame():Connect(idShowLineEndings,wx.wxEVT_COMMAND_MENU_SELECTED,onShowLineEndings)
ide:GetMainFrame():Connect(idShowLineEndings,wx.wxEVT_UPDATE_UI,onUpdateUi)
ide:GetMainFrame():Connect(idConvertCrLf,wx.wxEVT_COMMAND_MENU_SELECTED,onConvertCrLf)
ide:GetMainFrame():Connect(idConvertLf,wx.wxEVT_COMMAND_MENU_SELECTED,onConvertLf)
ide:GetMainFrame():Connect(idConvertCr,wx.wxEVT_COMMAND_MENU_SELECTED,onConvertCr)
end,
onUnRegister = function(self)
ide:RemoveMenuItem(idShowLineEndings)
ide:RemoveMenuItem(idConvertCrLf)
ide:RemoveMenuItem(idConvertLf)
ide:RemoveMenuItem(idConvertCr)
end,
}