Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endofline plugin #75

Open
jjvbsag opened this issue Nov 18, 2018 · 0 comments
Open

endofline plugin #75

jjvbsag opened this issue Nov 18, 2018 · 0 comments

Comments

@jjvbsag
Copy link

jjvbsag commented Nov 18, 2018

@pkulchenko Another plugin from me, please review and add to ZeroBranePackage if you like it. 🍺

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

🆘 Help is needed 🆘 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,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant