-
Notifications
You must be signed in to change notification settings - Fork 148
/
wordwrapmenu.lua
29 lines (27 loc) · 994 Bytes
/
wordwrapmenu.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local id = ID("wordwrapmenu.wordwrapmenu")
return {
name = "Wordwrap menu",
description = "Adds word wrap option to the menu.",
author = "Paul Kulchenko",
version = 0.21,
dependencies = "1.0",
onRegister = function(self)
local menu = ide:FindTopMenu("&Edit")
local pos = self:GetConfig().insertat and
self:GetConfig().insertat-1 or menu:GetMenuItemCount()
menu:InsertCheckItem(pos, id, "WordWrap\tAlt-W")
ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, function(event)
local wrap = event:IsChecked() and wxstc.wxSTC_WRAP_WORD or wxstc.wxSTC_WRAP_NONE
local ed = ide:GetEditor()
if ed then ed:SetWrapMode(wrap) end
end)
ide:GetMainFrame():Connect(id, wx.wxEVT_UPDATE_UI, function(event)
local ed = ide:GetEditor()
event:Check(ed and ed:GetWrapMode() ~= wxstc.wxSTC_WRAP_NONE)
event:Enable(ed ~= nil)
end)
end,
onUnRegister = function(self)
ide:RemoveMenuItem(id)
end,
}