How do I mark changed lines in StyledTextCtrl?

self.SetMarginType( 1, wx.stc.STC_MARGIN_SYMBOL);
self.SetMarginWidth ( 1, 6)
self.SetMarginMask(1,wx.stc.STC_MASK_FOLDERS)
self.MarkerDefineBitmap(wx.stc.STC_MARKNUM_FOLDER, wx.Bitmap( u"icons/textmark.png", wx.BITMAP_TYPE_ANY ))
#Add marker
editor.MarkerAdd(5,wx.stc.STC_MARKNUM_FOLDER)

Picture used: textmark

Hi Daniil,
I think you are doing right. However, a few points should be taken care of.

wxStyledTextCtrl - Markers
Some marker numbers are reserved for use in folding margins (#25#31), although you can certainly use them for your own purposes if you’re not doing folding. There are some defined variables that you can use as constants when referring to the ‘folding’ marker numbers, you could use one of these as the first argument to MarkerDefine:

wxSTC_MARKNUM_FOLDEREND = 25
wxSTC_MARKNUM_FOLDEROPENMID = 26
wxSTC_MARKNUM_FOLDERMIDTAIL = 27
wxSTC_MARKNUM_FOLDERTAIL = 28
wxSTC_MARKNUM_FOLDERSUB = 29
wxSTC_MARKNUM_FOLDER = 30
wxSTC_MARKNUM_FOLDEROPEN = 31

The following part is typo?

- editor.MarkerAdd(5,wx.stc.STC_MARKNUM_FOLDER)
+ self.MarkerAdd(5,wx.stc.STC_MARKNUM_FOLDER)

If you want to detect the text changed, you can use stc.EVT_STC_UPDATEUI event, then check the flag evt.Updated & stc.STC_UPDATE_CONTENT. True indicates that the line number self.LineFromPosition(evt.Position) self.CurrentLine has changed.
(wx.stc.StyledTextEvent — wxPython Phoenix 4.1.1 documentation)

EDIT It seems that evt.Position always returns 0.

2 Likes