Skip to content

Instantly share code, notes, and snippets.

@pkulchenko
Last active April 11, 2022 05:14
Show Gist options
  • Save pkulchenko/cbb0f69926568257fbb98feb8277f78f to your computer and use it in GitHub Desktop.
Save pkulchenko/cbb0f69926568257fbb98feb8277f78f to your computer and use it in GitHub Desktop.
require "wx"
-- this is a minimal example
local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "Demo",
  wx.wxDefaultPosition, wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE )
local e = wxstc.wxStyledTextCtrl(frame, wx.wxID_ANY,
  wx.wxDefaultPosition, wx.wxSize(0, 0), wx.wxBORDER_STATIC)
e:SetText("if true then\n  print '1'\nend\n\nfoo(1,\n  2)\n")
local margin = { LINENUMBER = 0, MARKER = 1, FOLD = 2 }
e:SetMarginType(margin.LINENUMBER, wxstc.wxSTC_MARGIN_NUMBER)
e:SetMarginMask(margin.LINENUMBER, 0)
e:SetMarginWidth(margin.LINENUMBER, e:TextWidth(wxstc.wxSTC_STYLE_DEFAULT, "99999"))
e:SetMarginWidth(margin.MARKER, 18)
e:SetMarginType(margin.MARKER, wxstc.wxSTC_MARGIN_SYMBOL)
e:SetMarginMask(margin.MARKER, bit.bnot(wxstc.wxSTC_MASK_FOLDERS))
e:SetMarginSensitive(margin.MARKER, true)
e:SetMarginWidth(margin.FOLD, 18)
e:SetMarginType(margin.FOLD, wxstc.wxSTC_MARGIN_SYMBOL)
e:SetMarginMask(margin.FOLD, wxstc.wxSTC_MASK_FOLDERS)
e:SetMarginSensitive(margin.FOLD, true)
local w, b = wx.wxColour(255, 255, 255), wx.wxColour(0, 0, 0)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDEROPEN, wxstc.wxSTC_MARK_BOXMINUS, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDER, wxstc.wxSTC_MARK_BOXPLUS, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDERSUB,  wxstc.wxSTC_MARK_VLINE, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDERTAIL, wxstc.wxSTC_MARK_LCORNER, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDEREND, wxstc.wxSTC_MARK_BOXPLUSCONNECTED, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDEROPENMID, wxstc.wxSTC_MARK_BOXMINUSCONNECTED, w, b)
e:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDERMIDTAIL, wxstc.wxSTC_MARK_TCORNER, w, b)
e:SetLexer(wxstc.wxSTC_LEX_LUA)
e:SetProperty("fold", "1")
e:SetKeyWords(0, "if then end do")
frame:Show(true)
wx.wxGetApp():MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment